Submission #773691

# Submission time Handle Problem Language Result Execution time Memory
773691 2023-07-05T07:50:22 Z gagik_2007 Remittance (JOI19_remittance) C++17
0 / 100
53 ms 2812 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> 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<ll>a,b;
unordered_map<ll,bool>used;
ll verjval;
const ll MAXVAL=24;

ll value(const vector<ll>& p){
    ll cur=1;
    ll res=0;
    for(ll x:p){
        res+=cur*x;
        cur*=MAXVAL;
    }
    return res;
}

vector<ll> deval(ll val){
    vector<ll>ans;
    while(val!=0){
        ans.push_back(val%MAXVAL);
        val/=MAXVAL;
    }
    return ans;
}

void recurs(ll val){
    if(val==verjval){
        cout<<"Yes"<<endl;
        exit(0);
    }
    if(used[val])return;
    used[val]=true;
    vector<ll>p=deval(val);
    for(ll i=0;i<p.size();i++){
        for(ll j=0;j<p.size();j++){
            if(i!=j){
                ll t1=p[i];
                ll t2=p[j];
                for(ll 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(ll i=0;i<n;i++){
        ll 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(ll)':
remittance.cpp:49:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(ll i=0;i<p.size();i++){
      |                ~^~~~~~~~~
remittance.cpp:50:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(ll j=0;j<p.size();j++){
      |                    ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2812 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 212 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2812 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 212 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2812 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 212 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -