QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#579354#9229. Juliet Unifies OnesHDU-T12#WA 0ms3608kbC++20900b2024-09-21 12:48:132024-09-21 12:48:25

Judging History

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

  • [2024-09-21 12:48:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-09-21 12:48:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define X first
#define Y second
#define umap unordered_map
using ll = long long;
using ull = unsigned long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int maxn = 2e5 + 5, mod = 1e9 + 7, maxp = 31, inf = 1e9;
const ll INF = 1e18;
const double eps = 1e-6;

void solve() {
	string s;
	cin >> s;
	const int n = s.size();
	int ans = n;
	for (int l = 0; l < n; l++) {
		for (int r = l; r < n; r++) {
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				if (i >= l && i <= r) {
					if (s[i] == '0') cnt++;
				}
				else {
					if (s[i] == '1') cnt++;
				}
			}
			ans = min(ans, cnt);
		} 
	}

	cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    // cin >> tt;
    while (tt--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

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

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

00000000000000000000000000000000000000000000000000

output:

1

result:

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