QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#549301 | #9229. Juliet Unifies Ones | gogo11# | WA | 0ms | 3532kb | C++20 | 835b | 2024-09-06 14:08:34 | 2024-09-06 14:08:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
constexpr int INF=0x3f3f3f3f;
constexpr int MXN=1e6+5;
void solve()
{
string s;
cin>>s;
int n=s.size(),ans=INF;
for(int l=0;l<n;l++)
{
for(int r=l;r<n;r++)
{
int cnt=0;
for(int i=0;i<l;i++)
if(s[i]=='1')
cnt++;
for(int i=r+1;i<n;i++)
if(s[i]=='1')
cnt++;
for(int i=l;i<=r;i++)
if(s[i]=='0')
cnt++;
ans=min(ans,cnt);
}
}
cout<<ans<<"\n";
}
int main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int _=1;
// cin>>_;
while(_--)
solve();
return 0;
}
详细
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: 3528kb
input:
11101111111111111101001011110111111110011101010110
output:
11
result:
ok 1 number(s): "11"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
00000000100000000000100000010001000
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3460kb
input:
00000000000000000000000000000000000000000000000000
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'