QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#549256 | #9229. Juliet Unifies Ones | z10# | WA | 0ms | 3628kb | C++23 | 2.3kb | 2024-09-06 13:26:37 | 2024-09-06 13:26:37 |
Judging History
answer
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <numeric>
#include <stack>
#include <map>
#include <iterator>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cmath>
#include <bitset>
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;
void sol(){
string s;
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";
/*
for (ll i = 0; i < s.size(); ++i) {
if (st.empty()){
if (s[i]=='0'){
continue;
}
else{
st.push(s[i]);
}
}
else{
if (s[i]=='0'){
}
else{
st.push(s[i]);
}
}
}
*/
/*
for (i=0;i<n;i++){
}
*/
//cout<<"Yes\n";
//cout<<"No\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t=1;
//cin>>t;
while (t--){
sol();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
00011011001
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3560kb
input:
11101111111111111101001011110111111110011101010110
output:
9
result:
wrong answer 1st numbers differ - expected: '11', found: '9'