#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=105413504+7;
ll n,m,k;
vector<int>a,b;
bool used[N];
int verjval;
const int MAXVAL=14;
int value(const vector<int>& p){
int cur=1;
int res=0;
for(int x:p){
res+=cur*x;
cur*=MAXVAL;
}
return res;
}
vector<int> deval(int val){
vector<int>ans;
while(val!=0){
ans.push_back(val%MAXVAL);
val/=MAXVAL;
}
return ans;
}
void recurs(int val){
if(val==verjval){
cout<<"Yes"<<endl;
exit(0);
}
if(used[val])return;
used[val]=true;
vector<int>p=deval(val);
for(int i=0;i<p.size();i++){
for(int j=0;j<p.size();j++){
if(i!=j){
int t1=p[i];
int t2=p[j];
for(int vl=1;vl<=p[i]/2;vl++){
p[i]-=2*vl;
p[j]+=vl;
recurs(value(p));
p[i]=t1;
p[j]=t2;
}
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("output.txt","w",stdout);
cin>>n;
for(int i=0;i<n;i++){
int x,y;
cin>>x>>y;
a.push_back(x);
b.push_back(y);
}
verjval=value(b);
recurs(value(a));
cout<<"No"<<endl;
return 0;
}
Compilation message
remittance.cpp: In function 'void recurs(int)':
remittance.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(int i=0;i<p.size();i++){
| ~^~~~~~~~~
remittance.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int j=0;j<p.size();j++){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
4052 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
4052 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
4052 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |