QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#265711 | #6843. PTSD | kokomiisbest | WA | 3ms | 3848kb | C++14 | 558b | 2023-11-25 20:35:52 | 2023-11-25 20:35:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin>>n;
string s;
cin>>s;
int ans=0,cnt0=0;
for(int i=n-1;i>=0;i--){
if(s[i]=='0'){
cnt0++;
}else{
if(cnt0){
cnt0--;
ans+=i+1;
// cout<<ans<<endl;
}else{
cnt0++;
}
}
}
cout<<ans<<"\n";
}
int main(){
ios::sync_with_stdio(false);
int t;
cin>>t;
// t=1;
while(t--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
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: 3848kb
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: 3ms
memory: 3552kb
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: 3648kb
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: 3556kb
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: -100
Wrong Answer
time: 1ms
memory: 3668kb
input:
1 100000 110101100111111011001110001010010000101001010111001011111000110010101010001110100000010011001111101010011100110001010101010000011110001010111001000001101010011011000110110011101010111011101110000000100100010101011100101010111101110010010111010000000110110100110010101110110011011101101111100...
output:
-1800242551
result:
wrong answer 1st lines differ - expected: '2494724745', found: '-1800242551'