This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define pii pair<int,int>
#define mpr make_pair
typedef long long ll;
const int maxn = 2e5+10;
const int mod = 1e9+7;
const ll inf = 1e18;
int n, m;
int a[maxn], b[maxn], pw2[maxn], c[maxn];
signed main()
{
int swa = 0, swb = 0;
pw2[0] = 1;
cin>> n;
for(int i = 1; i <= n; i++)
{
pw2[i] = pw2[i-1] * 2;
cin>> a[i] >> b[i];
if(a[i]) swa = 1;
if(b[i]) swb = 1;
c[i] = a[i] - b[i];
}
if(!swb)
{
if(swa) cout<<"No";
else cout<<"Yes";
return 0;
}
for(int i = 1; i <= n; i++)
{
int sum = 0;
int M = n;
int j = i, power = 0;
while(M--)
{
sum += c[j] * pw2[power];
j = j%n+1;
power++;
}
//cout<< sum <<"\n";
if(sum % (pw2[n]-1)) return cout<<"No", 0;
if(sum < 0) return cout<<"No", 0;
}
cout<<"Yes";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |