Submission #727238

#TimeUsernameProblemLanguageResultExecution timeMemory
727238dxz05Flight to the Ford (BOI22_communication)C++17
15 / 100
46 ms1836 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...