제출 #651099

#제출 시각아이디문제언어결과실행 시간메모리
651099TimDeeFlight to the Ford (BOI22_communication)C++17
0 / 100
636 ms1752 KiB
#include"communication.h"
#include <bits/stdc++.h>
using namespace std;
pair<int,int> decode(int n) {
    mt19937 rng(n);
    int x=rng();
    if (x&1) {
        for (int i=0; i<100; ++i) {
            int f=receive(), s=receive();
            if (f==s) {
                if (f==0) return {1,2};
                else return {2,3};
            }
        }
    } else {
        for (int i=0; i<100; ++i) {
            int f=receive(), s=receive();
            if (f==s) {
                if (f==1) return {1,2};
                else return {2,3};
            }
        }
    }
    x=rng();
    if (x&1) return {1,3};
    else return {2,3};
}

void encode(int n, int x) {
    mt19937 rng(n);
    int p=rng();
    if (p&1) {
        for (int i=0; i<100; ++i) {
            if (x<=2) send(0);
            else send(1);
            if (x<=2) send(0);
            else send(1);
        }
    } else {
        for (int i=0; i<100; ++i) {
            if (x>=2) send(0);
            else send(1);
            if (x>=2) send(0);
            else send(1);
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...