QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#529016#9229. Juliet Unifies Onesucup-team2894#AC ✓1ms3936kbC++201.1kb2024-08-24 08:23:342024-08-24 08:23:34

Judging History

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

  • [2024-08-24 08:23:34]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3936kb
  • [2024-08-24 08:23:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
 
using ll = long long;
const int inf = 1e9 + 100;
const ll linf = 1e18 + 100;
using vi = vector<int>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
 
mt19937 rnd(time(0));
 
#define TIME (clock() * 1. / CLOCKS_PER_SEC)
 
using ld = double;
const ld PI = acosl(-1.L);
 
const int maxn = 1e6+10;
// const ll mod = 998244353;

ll a[maxn];

void solvee() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  for(int l=0;l<n;l++){
    for(int r=l-1;r<n;r++){
      int sc = 0;
      for(int i=0;i<n;i++){
        if(l<=i&&i<=r){
          sc += (s[i]=='0');
        }
        else {
          sc += (s[i]=='1');
        }
      }
      ans = min(ans,sc);
    }
  }
  cout << ans << "\n";
}
 
void solve() {
  int tc = 1;
  // cin >> tc;
  while(tc--){
    solvee();
  }
}
 
signed main() {
	// cin.tie(0)->sync_with_stdio(0);
	// cin.exceptions(cin.failbit);
	cout << fixed;
	cout.precision(9);
  solve();
}

详细

Test #1:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

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

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

00000000000000000000000000000000000000000000000000

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

00000000100000000000100000011000

output:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

11000010100100000011101100000001000100000000000000

output:

8

result:

ok 1 number(s): "8"

Test #7:

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

input:

01100100111011110101010110000100001111110001110001

output:

19

result:

ok 1 number(s): "19"

Test #8:

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

input:

1110101111001

output:

3

result:

ok 1 number(s): "3"

Test #9:

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

input:

1

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

1001

output:

1

result:

ok 1 number(s): "1"

Test #11:

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

input:

11111111111111111111111111111111111111111111111111

output:

0

result:

ok 1 number(s): "0"

Test #12:

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

input:

11111100000000001101010101100011

output:

9

result:

ok 1 number(s): "9"

Test #13:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #14:

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

input:

11011

output:

1

result:

ok 1 number(s): "1"

Test #15:

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

input:

100011011

output:

2

result:

ok 1 number(s): "2"

Test #16:

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

input:

0

output:

0

result:

ok 1 number(s): "0"

Test #17:

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

input:

1010101010011011001101100110011101101011100110110

output:

19

result:

ok 1 number(s): "19"

Test #18:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

01110100000000111100000011000000000110010001110101

output:

14

result:

ok 1 number(s): "14"

Test #19:

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

input:

01100001000000010000000000010010000100100101001000

output:

9

result:

ok 1 number(s): "9"

Test #20:

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

input:

1101010101010101010101010101010101010101010101011

output:

23

result:

ok 1 number(s): "23"

Extra Test:

score: 0
Extra Test Passed