QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#650505 | #9229. Juliet Unifies Ones | mwh# | WA | 0ms | 3812kb | C++20 | 1.3kb | 2024-10-18 15:25:51 | 2024-10-18 15:25:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i128 = __int128_t;
typedef long long ll;
typedef unsigned long long ULL;
typedef array<int,3> node;
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
const int INF = 0x3f3f3f3f;
const ll p1=131,p2=13331;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
void work(){
string s;
cin>>s;
ll sum=0;
int cnt=0;
int num[60];
for(int i=0;i<s.size();i++){
if(s[i]=='1')cnt++;
num[i]=cnt;
}
int len=s.size();
// for(int i=0;i<len;i++)cout<<num[i]<<endl;
for(int i=0;i<len;i++){
int f2=1;
int j=i;
if(s[i]=='1'){
while(s[j+1]=='1'&&j+1<len){
j++;
}
if(j+1>=len)break;
j++;
// cout<<j<<endl;
while(s[j+1]=='0'&&j+1<len){
j++;
f2++;
}
// cout<<j<<endl;
int t=(num[len-1]-num[j]);
// cout<<t<<endl;
if(f2<t)sum+=f2;
else{
sum+=t;
break;
}
i=j;
}
}
cout<<sum<<endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t=1;
// cin>>t;
while(t--){
work();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
00011011001
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
11101111111111111101001011110111111110011101010110
output:
11
result:
ok 1 number(s): "11"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
00000000100000000000100000010001000
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
00000000000000000000000000000000000000000000000000
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
00000000100000000000100000011000
output:
3
result:
wrong answer 1st numbers differ - expected: '2', found: '3'