QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#398274 | #3761. 2020 | xlwang# | AC ✓ | 14ms | 4256kb | C++14 | 1.5kb | 2024-04-25 10:14:16 | 2024-04-25 10:14:16 |
Judging History
answer
#include<bits/stdc++.h>
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
using namespace std;
inline int read(){
int x=0;
bool f=0;
char c=getchar();
while(!isdigit(c)) f|=(c=='-'),c=getchar();
while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
//inline void init(){
// int t=read();
// while(t--) work();
//}
const int Maxn=1e5+10;
char c[Maxn];
int f[Maxn];
int n;
inline bool check(int x){
if(x<4) return false;
return c[x]=='0' && c[x-1]=='2' && c[x-2]=='0' && c[x-3]=='2';
}
inline void work(){
scanf("%s",c+1);
fr(i,1,n){
f[i]=f[i-1];
if(check(i)) f[i]=max(f[i],f[i-4]+1);
}
int ans=0;
fr(i,1,n) ans=max(ans,f[i]);
writeln(ans);
}
inline void init(){
while(cin>>n) work();
}
signed main(){
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
init();
// printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 14ms
memory: 4256kb
input:
4 2020 6 202020 10 1202012020 10 2222220000 10 0221200202 10 2202021022 10 0200222200 10 2222022122 10 2122222220 10 2200200002 10 2022222222 10 0000020220 10 0220022200 10 2020012000 10 0020020022 10 2220000020 10 0100220202 10 2202021022 10 0220222022 10 0220020000 10 0200000002 10 0202020002 10 2...
output:
1 1 2 0 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 2 0 1 1 0 0 0 0 1 1 0 1 1 0 0 0 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 2 1 ...
result:
ok 11116 lines