/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;
int n, A[N], B[N], x[N], nx[N];
void solve(){
cin >> n;
ll SA = 0, SB = 0;
for(int i = 1; i <= n; ++i){
cin >> A[i] >> B[i];
x[i] = 0;
SA += A[i];
SB += B[i];
}
// if(SA % 2 != SB % 2){
// cout << "No";
// return;
// }
bool OK = 1;
for(int bit = 0; bit < 50; bit++){
OK = 0;
for(int i = 1; i <= n; ++i){
ll val = (A[i] % 2) + (B[i] % 2) + x[i];
int b = i == 1 ? n : i - 1;
nx[b] = (-val+8)%2;
A[i] += nx[b] - x[i];
if(A[i]<0 || B[i]<0){
cout << "No";
return;
}
A[i] >>= 1;
B[i] >>= 1;
if(x[b] != nx[b]){
OK = 1;
}
}
for(int i = 1; i <= n; ++i){
x[i] = nx[i];
// cout << A[i] << ' ' << B[i] << '\n';
// cout << x[i] << ' ';
}
// en;
}
if(OK){
cout << "No";
return;
}
cout << "Yes";
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(tt--){
solve();
en;
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
return 0;
}
Compilation message
remittance.cpp: In function 'int main()':
remittance.cpp:66:15: warning: unused variable 'aa' [-Wunused-variable]
66 | int tt = 1, aa;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6480 KB |
Output is correct |
2 |
Correct |
1 ms |
6480 KB |
Output is correct |
3 |
Correct |
2 ms |
6652 KB |
Output is correct |
4 |
Correct |
1 ms |
6480 KB |
Output is correct |
5 |
Correct |
2 ms |
6480 KB |
Output is correct |
6 |
Correct |
2 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
2 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6652 KB |
Output is correct |
11 |
Correct |
2 ms |
6648 KB |
Output is correct |
12 |
Correct |
1 ms |
6480 KB |
Output is correct |
13 |
Correct |
1 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
6480 KB |
Output is correct |
15 |
Correct |
1 ms |
6480 KB |
Output is correct |
16 |
Correct |
1 ms |
6480 KB |
Output is correct |
17 |
Correct |
1 ms |
6480 KB |
Output is correct |
18 |
Correct |
1 ms |
6480 KB |
Output is correct |
19 |
Correct |
1 ms |
6480 KB |
Output is correct |
20 |
Incorrect |
2 ms |
6480 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6480 KB |
Output is correct |
2 |
Correct |
1 ms |
6480 KB |
Output is correct |
3 |
Correct |
2 ms |
6652 KB |
Output is correct |
4 |
Correct |
1 ms |
6480 KB |
Output is correct |
5 |
Correct |
2 ms |
6480 KB |
Output is correct |
6 |
Correct |
2 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
2 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6652 KB |
Output is correct |
11 |
Correct |
2 ms |
6648 KB |
Output is correct |
12 |
Correct |
1 ms |
6480 KB |
Output is correct |
13 |
Correct |
1 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
6480 KB |
Output is correct |
15 |
Correct |
1 ms |
6480 KB |
Output is correct |
16 |
Correct |
1 ms |
6480 KB |
Output is correct |
17 |
Correct |
1 ms |
6480 KB |
Output is correct |
18 |
Correct |
1 ms |
6480 KB |
Output is correct |
19 |
Correct |
1 ms |
6480 KB |
Output is correct |
20 |
Incorrect |
2 ms |
6480 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6480 KB |
Output is correct |
2 |
Correct |
1 ms |
6480 KB |
Output is correct |
3 |
Correct |
2 ms |
6652 KB |
Output is correct |
4 |
Correct |
1 ms |
6480 KB |
Output is correct |
5 |
Correct |
2 ms |
6480 KB |
Output is correct |
6 |
Correct |
2 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
2 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6652 KB |
Output is correct |
11 |
Correct |
2 ms |
6648 KB |
Output is correct |
12 |
Correct |
1 ms |
6480 KB |
Output is correct |
13 |
Correct |
1 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
6480 KB |
Output is correct |
15 |
Correct |
1 ms |
6480 KB |
Output is correct |
16 |
Correct |
1 ms |
6480 KB |
Output is correct |
17 |
Correct |
1 ms |
6480 KB |
Output is correct |
18 |
Correct |
1 ms |
6480 KB |
Output is correct |
19 |
Correct |
1 ms |
6480 KB |
Output is correct |
20 |
Incorrect |
2 ms |
6480 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |