Submission #223036

#TimeUsernameProblemLanguageResultExecution timeMemory
223036spacewalkerRemittance (JOI19_remittance)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
	int n; scanf("%d", &n);
	vector<ll> before(n), after(n);
	for (int i = 0; i < n; ++i) {
		scanf("%lld %lld", &before[i], &after[i]);
	}
	vector<ll> negDelta(n);
	for (int i = 0; i < n; ++i) negDelta[i] = before[i] - after[i];
	vector<ll> ans(n, -1);
	for (int i = 0; i < n; ++i) {
		ll multiplier = (1 << (n - 1));
		ll potValue = 0;
		for (int offset = 0; offset < n; ++offset) {
			potValue += multiplier * negDelta[(i - offset + n) % n];
			multiplier /= 2;
		}
//		printf("%d att potValue %lld\n", i, potValue);
		if (potValue >= 0 && potValue % ((1 << n) - 1) == 0) {
			ans[i] = potValue / ((1 << n) - 1);	
		}
	}
	for (int i = 0; i < n; ++i) {
		if (ans[i] == -1) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:7:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d", &n);
         ~~~~~^~~~~~~~~~
remittance.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &before[i], &after[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...