Submission #999665

#TimeUsernameProblemLanguageResultExecution timeMemory
999665pccFlight to the Ford (BOI22_communication)C++17
15 / 100
28 ms2900 KiB
#include"communication.h" #include <bits/stdc++.h> // // --- 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 // using namespace std; string arr[3] = {"0000","1111","1001"}; void encode(int N, int X) { for(auto &i:arr[X-1])send(i-'0'); return; } bool check(string a,string b){ vector<int> dif; for(int i = 0;i<a.size();i++){ if(a[i] != b[i])dif.push_back(i); } for(int i = 1;i<dif.size();i++){ if(dif[i]-dif[i-1]<=1)return false; } return true; } std::pair<int, int> decode(int N) { string s; for(int i = 0;i<4;i++)s += '0'+receive(); vector<int> ans; for(int i = 0;i<3;i++){ if(check(arr[i],s))ans.push_back(i+1); } assert(ans.size()<=2); if(ans.size()<2)ans.push_back(ans.back() ==1?2:1); return make_pair(ans[0],ans[1]); }

Compilation message (stderr)

communication.cpp: In function 'bool check(std::string, std::string)':
communication.cpp:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i = 0;i<a.size();i++){
      |                ~^~~~~~~~~
communication.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i = 1;i<dif.size();i++){
      |                ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...