思路1:
暴力枚举数组中长度为8的子序列,然后去判断是否为2023年的某一天。
一看复杂度O(2^100),用自己的电脑算估计得算5202年去了。
思路2:
想了半天,发现在数组中先匹配出2023实际上到数组5、60多位去了,2023的在原数组中的个数非常有限,即前面好多数据无用,仅需要再后40多位去找月和日,可以优化到O(2^30~2^40)。但这么做还是太费时费力了。
思路3:
看了别人的代码后,大彻大悟,终于找到了正解:枚举 2023中的日期,判断数组中是否存在该子序列。
#include<bits/stdc++.h>
using namespace std;
void __p(int x) {cerr<<x;}
void __p(long long x){cerr<<x;}
void __p(double x){cerr<<x;}
void __p(string s){cerr<<s;}
void __p(char s){cerr<<s;}
void _print(){cerr<<"]\n";}
template<typename T,typename... V>//定义类模版
void _print(T t,V... v){__p(t);if(sizeof...(v))cerr<<",";_print(v...);}
#define debug(x...) cerr<<"["<<#x<<"] = ["; _print(x)
#define see1 cout<<"-------------\n";
#define see2 cerr<<"-------------\n";
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
signed main()
{
vector<int>a(120);
for(int i=1;i<=100;i++){
cin>>a[i];
}
int ans=0;
vector<int>d={0,31,28,31,30,31,30,31,31,30,31,30,31};
for(int i=1;i<=12;i++){
for(int k=1;k<=d[i];k++){
vector<int>time={2,0,2,3,i/10,i%10,k/10,k%10};
int idx=0;
for(int j=1;j<=100;j++){
if(a[j]==time[idx]){
idx++;
}
if(idx==8){
ans++;
break;
}
}
}
}
cout<<ans;
}
25/2/25