This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include"communication.h"
#include <bits/stdc++.h>
using namespace std;
bool can(string &s, string &t){
if (s.size() != t.size()) return false;
for (int i = 0; i + 1 < s.size(); i++){
if (s[i] != t[i] && s[i + 1] != t[i + 1]) return false;
}
return true;
}
void encode(int N, int X) {
if (X == 1) send(0), send(0), send(0), send(0);
if (X == 2) send(0), send(1), send(1), send(0);
if (X == 3) send(1), send(1), send(1), send(1);
}
pair<int, int> decode(int N) {
string s(4, '0');
s[0] += receive();
s[1] += receive();
s[2] += receive();
s[3] += receive();
vector<string> v = {"0000", "0110", "1111"};
vector<int> ans;
for (int i = 0; i < 3; i++){
if (can(v[i], s)) ans.push_back(i + 1);
}
return make_pair(ans.front(), ans.back());
}
Compilation message (stderr)
communication.cpp: In function 'bool can(std::string&, std::string&)':
communication.cpp:8:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | for (int i = 0; i + 1 < s.size(); i++){
| ~~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |