Submission #155357

# Submission time Handle Problem Language Result Execution time Memory
155357 2019-09-27T16:19:56 Z mdn2002 Remittance (JOI19_remittance) C++14
0 / 100
1000 ms 380 KB
#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==30)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 time Memory Grader output
1 Execution timed out 1053 ms 380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 380 KB Time limit exceeded
2 Halted 0 ms 0 KB -