QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#549323#9229. Juliet Unifies Onesclearlove13#WA 0ms3860kbC++231.5kb2024-09-06 14:23:222024-09-06 14:23:24

Judging History

你现在查看的是最新测评结果

  • [2024-09-06 14:23:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3860kb
  • [2024-09-06 14:23:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ull = unsigned long long;
#define ff(x) fixed << setprecision(x)
#define vel vector<long long>
#define vei vector<int>
#define ves vector<string>
#define asn ans
constexpr int inf = 0x3f3f3f3f;
constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr db EPS = 1.0e-9;
constexpr ll MOD = 998244353LL;
constexpr ll SZ = 1e6;
constexpr ll MAXN5 = 2e5 + 5;
constexpr ll MAXN6 = 2e6 + 5;
ll n, m;

void Solve(void) {
    string s;
    cin >> s;
    ll a[s.size()+1];
    fill(a,a+s.size()+1,0);
    vector<int> xia;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1'){
            a[i+1]=1;
            xia.push_back(i+1);
        }
    }
    for(int i=1;i<=s.size();i++){
        a[i]+=a[i-1];
    }
    int ans=INT_MAX;
    // for(auto x:xia){
    //     cout<<x<< ' ' ;
    //     cout<<a[x]<<'\n';
    // }
    for(int i=0;i<xia.size();i++){
        for(int j=i+1;j<xia.size();j++){
             int zuo=a[xia[i]-1]-a[0];
             int you=a[s.size()]-a[xia[j]];
             int mid=min(a[xia[j]]-a[xia[i]-1],xia[j]-xia[i]+1+a[xia[i]-1]-a[xia[j]]);
             ans=min({ans,zuo+you+mid});
        }
    }
    cout<<ans;

    
}
int main(void) {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // 	freopen("mine.in", "r", stdin);
    // 	freopen("mine.out", "w", stdout);

    int cas = 1;
    // cin >> cas;
    while (cas--)
        Solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3556kb

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3860kb

input:

00000000100000000000100000010001000

output:

4

result:

wrong answer 1st numbers differ - expected: '3', found: '4'