QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#278300 | #6843. PTSD | rageOfThunder# | AC ✓ | 7ms | 11076kb | C++14 | 1.3kb | 2023-12-07 14:41:32 | 2023-12-07 14:41:33 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define mk make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
int x=0,f=1;char c=getchar();
for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
return x*f;
}
const int mod=998244353;
int ksm(int x,int y,int p=mod){
int ans=1;
for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
void cmax(int &x,int v){x=max(x,v);}
void cmin(int &x,int v){x=min(x,v);}
signed main(void){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
#endif
int tt=read();while(tt--){
int n=read();
vector<int>can(n+1,0);
for(int i=1;i<=n;i++){
char c=getchar();while(c!='0'&&c!='1')c=getchar();
can[i]=(c=='1');
}
int cnt=0,ans=0;
for(int i=n;i>=1;i--){
if(!can[i]){cnt++;continue;}
if(cnt>=1)cnt--,ans+=i;
else cnt++;
}
cout<<ans<<'\n';
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3512kb
input:
4 5 10101 8 11111111 4 1100 4 0110
output:
4 16 3 3
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
14 1 0 1 1 2 00 2 01 2 10 2 11 3 000 3 001 3 010 3 011 3 100 3 101 3 110 3 111
output:
0 0 0 0 1 1 0 0 2 2 1 1 2 2
result:
ok 14 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
2046 1 0 1 1 2 00 2 01 2 10 2 11 3 000 3 001 3 010 3 011 3 100 3 101 3 110 3 111 4 0000 4 0001 4 0010 4 0011 4 0100 4 0101 4 0110 4 0111 4 1000 4 1001 4 1010 4 1011 4 1100 4 1101 4 1110 4 1111 5 00000 5 00001 5 00010 5 00011 5 00100 5 00101 5 00110 5 00111 5 01000 5 01001 5 01010 5 01011 5 01100 5 0...
output:
0 0 0 0 1 1 0 0 2 2 1 1 2 2 0 0 3 3 2 2 3 3 1 1 4 4 3 3 4 4 0 0 4 4 3 3 4 4 2 2 6 6 5 5 6 6 1 1 5 5 4 4 5 5 3 3 6 6 5 5 6 6 0 0 5 5 4 4 5 5 3 3 8 8 7 7 8 8 2 2 7 7 6 6 7 7 5 5 8 8 7 7 8 8 1 1 6 6 5 5 6 6 4 4 9 9 8 8 9 9 3 3 8 8 7 7 8 8 6 6 9 9 8 8 9 9 0 0 6 6 5 5 6 6 4 4 10 10 9 9 10 10 3 3 9 9 8 8 ...
result:
ok 2046 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
5000 20 00111010010110111001 20 10010011111010101000 20 00010111100100000110 20 00100001011100011100 20 01111101100001000111 20 11111111001111010110 20 10101101101010111111 20 10001100110001011110 20 01110010001110110011 20 01010010101010011011 20 00010110111100100110 20 00110101101010110100 20 0001...
output:
90 87 65 79 70 97 99 81 90 82 87 95 92 88 94 43 87 53 38 87 66 86 85 98 98 93 84 92 95 95 77 73 85 70 75 80 73 56 73 90 66 75 54 86 96 94 66 67 66 69 98 80 97 67 88 80 86 94 78 84 61 88 85 69 92 92 94 93 94 92 90 61 93 69 88 87 95 87 85 80 95 95 96 78 81 75 97 62 57 89 74 93 87 86 95 78 99 84 78 98 ...
result:
ok 5000 lines
Test #5:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
100 1000 011000000000100100011000010000100000101011101101001000000100101100010110100001001101111001100110000101100110011111000100000011001011101110100000011010010011010100101110110011000011000001111011011000000100001000101111011010001100010011110010100100000110110010001000000110010001001110101110010...
output:
234602 243039 244012 245117 246145 245863 243437 236433 244688 236651 241886 229573 244349 235715 243163 243356 242377 241669 246219 240577 245717 243012 246876 244004 245984 247795 240421 247122 231424 247216 243569 240919 244124 220237 242291 245922 243454 243471 236283 246241 242644 246814 244583...
result:
ok 100 lines
Test #6:
score: 0
Accepted
time: 2ms
memory: 4000kb
input:
1 100000 110101100111111011001110001010010000101001010111001011111000110010101010001110100000010011001111101010011100110001010101010000011110001010111001000001101010011011000110110011101010111011101110000000100100010101011100101010111101110010010111010000000110110100110010101110110011011101101111100...
output:
2494724745
result:
ok single line: '2494724745'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3852kb
input:
1 100000 110010000110010001001011011011001010101001000011101101010100010111110111100011101110110100001101111001011001001010010111011110001001000100110111001011110001100110101000100000111101100001101101000010011100011110000101111011110010110101000111110100111010010100011010100101101001001001101111000...
output:
2489784303
result:
ok single line: '2489784303'
Test #8:
score: 0
Accepted
time: 6ms
memory: 11076kb
input:
1 1000000 01101101110111101001111011111000000011110001110001110001000111010100011010000101111100110100101100101001110100010011100011011110100110110000101100000111101110110100101100101000111000010100100010101101001011100110100010101011100011011011110010100100001011110111110001100010101101001100001101...
output:
249484810648
result:
ok single line: '249484810648'
Test #9:
score: 0
Accepted
time: 6ms
memory: 10844kb
input:
1 1000000 00101101100011110011010101100011011110110000011001000110100000100100011000101110100100000001110011100000100011111010110111100001100111010111010001010000000010000110100111110001000100111100111000110010111100111101010011111010010011100000010001101000111010001000001101100100111101010010010011...
output:
249734019860
result:
ok single line: '249734019860'
Test #10:
score: 0
Accepted
time: 7ms
memory: 11048kb
input:
1 1000000 10110000000110000000001000001000001110011000011000110011100101111010110111101100000101111111001011011010011111110000101001111100010000101001101110010010110001110111110000100101000011010101001010011010110101000100110011010001110110110000110100111011111001100010010001101010101101000000001010...
output:
249656813708
result:
ok single line: '249656813708'