QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534171#9229. Juliet Unifies OnesjayketWA 0ms3812kbC++231.2kb2024-08-26 21:34:352024-08-26 21:34:37

Judging History

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

  • [2024-08-26 21:34:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3812kb
  • [2024-08-26 21:34:35]
  • 提交

answer

#include<bits/stdc++.h>

#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse4,popcnt,abm,mmx")

using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f64 = long double;
using i128 = __int128;
using f128 = __float128;

#ifndef ONLINE_JUDGE
#include "algo\debug.hpp"
#else
#define debug(...) (void)42
#endif

template<class T>
void chmax(T& x, T y) {
	x = std::max(x, y);
}

template<class T>
void chmin(T& x, T y) {
	x = std::min(x, y);
}

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::string s;
	std::cin >> s;

	int n = s.size();
	if (std::ranges::count(s, '0') == n) {
		std::cout << 0 << '\n';
	} else {
		int j = 0;
		while (j < n and s[j] == '0') {
			j += 1;
		}
		int ans = 0;
		for (;;) {
			int u = s.find('0', j + 1);
			if (u == s.npos) {
				break;
			}
			int v = s.find('1', u + 1);
			if (v == s.npos) {
				break;
			}
			int w = s.find('0', v + 1);
			if (w == s.npos) {
				w = n;
			}
			int a = v - u;
			int b = w - v;
			ans += std::min(a, b);
			j = w;
		}
		std::cout << ans << '\n';
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

5

result:

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