Submission #859053

#TimeUsernameProblemLanguageResultExecution timeMemory
859053vgtcrossFlight to the Ford (BOI22_communication)C++17
15 / 100
18 ms2936 KiB
#include <bits/stdc++.h>

#define MODE 0

using namespace std;
using ll = long long;

int send(int s)
#if MODE
{
    cout << "send " << s << endl;
    cin >> s;
    return s;
}
#else
;
#endif

int receive()
#if MODE
{
    cout << "receive: " << flush;
    int s;
    cin >> s;
    return s;
}
#else
;
#endif

void encode(int n, int x) {
    if (x == 1) {
        send(1);
        send(1);
        send(1);
    } else {
        if (send(0)) send(3 - x);
        if (send(0)) send(3 - x);
    }
}

pair<int, int> decode(int n) {
    if (receive()) return {1, 3 - receive()};
    if (receive()) return {1, 3 - receive()};
    return {2, 3};
}

#if MODE
int main() {
    cin.tie(0) -> sync_with_stdio(0);
    
    int n, x;
    cin >> n >> x;
    encode(n, x);
    cout << "\n\nmode swich\n\n\n";
    pair<int, int> p = decode(n);
    cout << "! " << p.first << ' ' << p.second << endl;
}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...