Submission #155358

#TimeUsernameProblemLanguageResultExecution timeMemory
155358mdn2002Remittance (JOI19_remittance)C++14
0 / 100
1080 ms376 KiB
#include<bits/stdc++.h> using namespace std; long long mod=1e9+7; int n,a[10],b[10]; bool t=false; void f(int num) { if(num==20)return; bool tt=true; for(int i=0; i<n; i++) { if(a[i]!=b[i])tt=false; } t=tt; if(t==true) { cout<<"YES"; exit(0); } for(int i=0; i<n; i++) { for(int j=2; j<=a[i]; j+=2) { for(int z=0; z<n; z++) { if(i==z)continue; int dis=abs(i-z); int diz=min(i,z)+1+((n-1)-max(i,z)); if(pow(2,dis)<=j) { a[i]-=pow(2,dis); a[z]+=pow(2,dis)/2; f(num+1); a[i]+=pow(2,dis); a[z]-=pow(2,dis)/2; } if(pow(2,diz)<=j) { a[i]-=pow(2,diz); a[z]+=pow(2,diz)/2; f(num+1); a[i]+=pow(2,diz); a[z]-=pow(2,diz)/2; } } } } } int main() { cin>>n; for(int i=0; i<n; i++)cin>>a[i]>>b[i]; f(0); cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...