QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#383921#6748. Spin the Wheelqzhfx#WA 0ms3588kbC++231.4kb2024-04-09 18:51:452024-04-09 18:51:45

Judging History

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

  • [2024-04-09 18:51:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-04-09 18:51:45]
  • 提交

answer

#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math,no-stack-protector")
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = int64_t;
using LL = long long;
using ull = uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using pii = pair<ll, ll>;
const int mod = 998244353;
const int N = 1e7 + 7;
const int maxn = 1e5 + 100;


void solve() {
	int n;
	cin >> n;
	vector<int>s(n + 1, 0);
	set<int>st;
	ll sum = 0;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		sum += s[i];
	}
	if (sum == 0) {
		cout << 0 << '\n';
		return;
	}
	auto a = s;
	for (int i = 2; i <= n; i++) {
		st.insert(((s[i] - s[i - 1]) % n + n) % n);

	}
	st.insert(((s[1] - s[n]) % n + n) % n);
	if (st.size() > 1 || *st.begin() == 0) {
		cout << -1 << '\n';
	} else {
		for (int i = n; i >= 1; i--) {
			a[i] -= a[i - 1];
			a[i] += n;
			a[i] %= n;
		}
		int cnt = 0;
		for (int i = n; i >= 1; i--) {
			a[i] -= a[i - 1];
			a[i] += n;
			a[i] %= n;
		}
		for (auto x : a) {
			if (x > 0) {
				cnt ++;
			}
			// cout << x << " " ;
		}
		// cout << '\n';
		if(s[1]==0)cnt --;
		// cout << cnt << '\n';
		cout << cnt + *st.begin()<< '\n';

	}

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

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3588kb

input:

5
1 3 0 2 4

output:

4

result:

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