Submission #231848

# Submission time Handle Problem Language Result Execution time Memory
231848 2020-05-15T05:04:24 Z jiahng Remittance (JOI19_remittance) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 1000001
typedef long double ld;

int N;
ld X[maxn],Y[maxn];
ld A[maxn],B[maxn];

int main(){
	fast;
	
	cin>>N;
	
	FOR(i,0,N-1) cin>>X[i]>>Y[i];
	
	int fi=-1;
	
	FOR(i,0,N-1){
		if (X[i] - Y[i] >= 0){
			fi = i;
			break;
		}
	}
	if (fi == -1){
		cout<<"No";
		return 0;
	}
	
	rotate(X,X+fi,X+N);
	rotate(Y,Y+fi,Y+N);
	
	B[0] = X[0] - Y[0];
	A[1] = (X[0] - Y[0]) / 2;
	
	FOR(i,1,N - 1){
		B[i] = X[i] - Y[i] + A[i];
		A[(i + 1) % N] = B[i]/2;
	}

	ld z = - B[0] + A[0] - Y[0] + X[0];
	if (z == 0){
		FOR(i,0,N-1){
			if (ll(B[i]) % 2 != 0 || ll(B[i]) != B[i] || B[i] < 0){
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes";
		return 0;
	}
	
	ld a = 1;
	FOR(i,1,N) a /= 2;
	
	ld k = 1/z - (a * (1/z));
	k = 1/k;
	
	

	FOR(i,0,N-1){
		B[i] += k;
		k /= 2;
	}
	int num = 0;
	FOR(i,0,N-1){
		A[i] = B[(i - 1 + N) % N] / 2;
		
		if (ll(B[i]) != B[i] || ll(B[i]) % 2 != 0 || B[i] < 0 || ll(A[i]) != A[i]){
			cout<<"No";
			return 0;
		}
		
		if (X[i] >= B[i]) num++;
		if (A[i] + X[i] < B[i]){
			cout<<"No";
			return 0;
		}
	}
	if (num == 0) cout<<"No";
	else cout<<"Yes";
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Incorrect 5 ms 384 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Incorrect 5 ms 384 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Incorrect 5 ms 384 KB Output isn't correct
25 Halted 0 ms 0 KB -