Submission #651106

#TimeUsernameProblemLanguageResultExecution timeMemory
651106TimDeeFlight to the Ford (BOI22_communication)C++17
0 / 100
687 ms1756 KiB
#include"communication.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
pair<int,int> decode(int n) {
    for (int i=0; i<100; ++i) {
        int f=receive();
        int s=receive();
        if (f==1 && s==1) continue;
        if (f==1 && s==0) return {1,3};
        if (f==0 && s==1) return {2,3};
        if (f==0 && s==0) return {1,2};
    }
    return {1+rng()&1,3};
}

void encode(int n, int x) {
    for (int i=0; i<100; ++i) {
        if (x&1) send(1); else send(0);
        if (x&2) send(1); else send(0);
    }
}

Compilation message (stderr)

communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:14:14: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   14 |     return {1+rng()&1,3};
      |             ~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...