QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#398272 | #3761. 2020 | Graphcity# | AC ✓ | 43ms | 4504kb | C++20 | 561b | 2024-04-25 10:13:05 | 2024-04-25 10:13:06 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=2e5;
int n,f[Maxn+5],a[Maxn+5];
inline void Solve()
{
For(i,1,n) scanf("%1d",&a[i]);
For(i,0,n) f[i]=0; f[0]=0;
For(i,1,n)
{
f[i]=f[i-1];
if(i>=4 && a[i]==0 && a[i-1]==2 && a[i-2]==0 && a[i-3]==2)
f[i]=max(f[i],f[i-4]+1);
} cout<<f[n]<<endl;
}
int main()
{
// freopen("1.in","r",stdin);
while(cin>>n) Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 43ms
memory: 4504kb
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