Submission #711243

# Submission time Handle Problem Language Result Execution time Memory
711243 2023-03-16T11:03:37 Z rrrr10000 Flight to the Ford (BOI22_communication) C++17
0 / 100
36 ms 1764 KB
#include <bits/stdc++.h>
#include "communication.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef vector<P> vp;
typedef vector<vp> vvp;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define pb emplace_back
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){for(auto x:v)outv(x);}
template<class T> void outvp(T v){rep(i,v.size()){cout<<'('<<v[i].fi<<','<<v[i].se<<')';}cout<<endl;}
template<class T> void outvvp(T v){for(auto x:v)outvp(x);}
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

void encode(int N,int X){
    vi v={1,0,0,0,0,1,1,0,0,0,1,1,0,1,0,0,0,0,1,0,1,1,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,0,1,1,1,1,0,0,0,0,1,1,1,1,1,0,1,0,0,0,0,1,0,1,1,0,1,1,1,0,0,0,1,0,1,0,0,0,0,1,0,1,1,0,1,0,1,1,0,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,0,1,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0,0,0,0,1,1,1,0,0,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,1,1,0,1,0,1,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,1,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,1,1};
    vi v2={1,0,1,0,0,1,1,0,1,1,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0,1,1,0,0,0,0,1,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,0,0,0,1,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,1,0,0,1,0,0,1,0,1,1,1,1,1,0,0,1,1,0,0,1,1,0,1,1,1,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,1,0,0,0,1,1,1,1,1,1,0,1,1,1,1,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,0,1,1,0,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1,0,0,0,0,1,0,0,1,1,0,1,0,1,1,0,1,1,0,1,1,1,1,1,1,0,1,1};
    ll cnt=0;
    rep(i,1){
        int d=(X>>i&1)^v2[cnt++];
        while(true){
            if(v[cnt]==1){
                if(send(v2[cnt])==v2[cnt]){
                    cnt++;
                    continue;
                }
                else{
                    send(d);
                    cnt++;
                    break;
                }
            }
            else{
                if(send(d)==d){
                    if(send(v2[cnt])==v2[cnt]){
                        cnt++;
                        break;
                    }
                    else{
                        cnt++;continue;
                    }
                }
                else{
                    send(1-v2[cnt]);
                    cnt++;continue;
                }
            }
        }
    }
}
pair<int,int> decode(int N){
    vi v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1,1,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,0,1,1,0,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1,0,0,0,0,1,0,0,1,1,0,1,0,1,1,0,1,1,0,1,1,1,1,1,1,0,1,1};
    ll cnt=0;
    int res=0;
    rep(i,1){
        int t=v2[cnt++];
        while(true){
            if(v[cnt]==1){
                if(receive()==v2[cnt]){
                    cnt++;continue;
                }
                else{
                    if(t!=receive())res+=1<<i;
                    cnt++;break;
                }
            }
            else{
                int tmp=receive();
                if(receive()==v2[cnt]){
                    if(t!=tmp)res+=1<<i;
                    cnt++;break;
                }
                else{
                    cnt++;continue;
                }
            }
        }
    }
    if(res==1)return make_pair(1,3);
    return make_pair(2,2);
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1720 KB Output is correct
2 Correct 14 ms 1688 KB Output is correct
3 Correct 23 ms 1720 KB Output is correct
4 Correct 14 ms 1700 KB Output is correct
5 Correct 6 ms 1764 KB Output is correct
6 Incorrect 3 ms 192 KB Not correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 200 KB Not correct
2 Halted 0 ms 0 KB -