#include"communication.h"
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
//
// --- Sample implementation for the task communication ---
//
// To compile this program with the sample grader, place:
// communication.h communication_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
// g++ -std=c++17 communication_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
void encode(int N, int X) {
int r;
if(X == 1) {
send(1);
send(0);
send(0);
}
if(X == 2) {
send(0);
send(1);
send(0);
}
if(X == 3) {
r = send(0);
if(r == 0) send(1);
else send(0);
send(1);
}
}
ii decode(int N) {
int a = receive();
int b = receive();
int c = receive();
if(a == 0 && b == 0 && c == 0) return {1, 2};
if(a == 0 && b == 0 && c == 1) return {1, 3};
if(a == 0 && b == 1 && c == 0) return {2, 3};
if(a == 0 && b == 1 && c == 1) return {2, 3};
if(a == 1 && b == 0 && c == 0) return {1, 3};
if(a == 1 && b == 0 && c == 1) return {1, 3};
if(a == 1 && b == 1 && c == 0) return {1, 2};
if(a == 1 && b == 1 && c == 1) return {2, 2};
}
Compilation message
communication.cpp: In function 'ii decode(int)':
communication.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
57 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1864 KB |
Output is correct |
2 |
Correct |
13 ms |
1824 KB |
Output is correct |
3 |
Correct |
13 ms |
1728 KB |
Output is correct |
4 |
Correct |
7 ms |
1720 KB |
Output is correct |
5 |
Correct |
12 ms |
1712 KB |
Output is correct |
6 |
Correct |
25 ms |
1924 KB |
Output is correct |
7 |
Correct |
35 ms |
1724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
200 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |