QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#549255 | #9229. Juliet Unifies Ones | clearlove13# | WA | 0ms | 3652kb | C++23 | 1.7kb | 2024-09-06 13:26:23 | 2024-09-06 13:26:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
typedef double db;
#define vel vector<long long>
#define ves vector<string>
typedef unsigned long long ull;
const double pi= std::acos(-1.0);
const ll lens=1e4+5;
const ll MAXN5=1e5+5;
//typedef pair<ll,ll> PLL;
ll xi[lens];
const ll M = 1e9+7;
ll yi[lens];
//ll bo[lens];
ll l,r,y;
ll n,m,r1,r2,i,j,k;
string na,te,ss,s;
void sol(){
cin>>s;
stack<char> st;
string gd="";
string ans="";
for (ll i = 0; i < s.size(); ++i){
if (gd.size()==0){
gd+=s[i];
}
else{
if (s[i]==gd[gd.size()-1]){
gd+=s[i];
}
else{
if (ans.size()==0){
if (gd[0]=='1'){
ans+='1';
}
}
else{
ans+=gd[0];
}
gd="";
gd+=s[i];
}
}
}
if (gd.size()!=0){
if (gd[0]=='1'){
if (ans[ans.size()-1]=='0'){
ans+='1';
}
}
}
ll rq=0;
for (ll i = 0; i < ans.size(); ++i){
if (ans[i]=='0'){
if (i==ans.size()-1){
continue;
}
else{
if (ans[i+1]=='1'&&ans[i-1]=='1'){
rq++;
}
}
}
}
cout<<rq<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t=1;
//cin>>t;
while (t--){
sol();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
input:
00011011001
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3552kb
input:
11101111111111111101001011110111111110011101010110
output:
9
result:
wrong answer 1st numbers differ - expected: '11', found: '9'