Submission #987554

#TimeUsernameProblemLanguageResultExecution timeMemory
987554cig32Flight to the Ford (BOI22_communication)C++17
0 / 100
372 ms332 KiB
#include"communication.h" #include "bits/stdc++.h" using namespace std; // // --- 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 // const int q = 180; void encode(int N, int X) { int a[180] = { 0, 27, 26, 21, 20, 3, 13, 12, 24, 25, 21, 21, 2, 28, 27, 1, 23, 7, 20, 15, 0, 28, 17, 2, 3, 18, 10, 10, 25, 11, 28, 2, 6, 13, 18, 20, 2, 16, 0, 16, 22, 18, 5, 9, 1, 29, 29, 29, 21, 15, 29, 28, 4, 8, 6, 26, 22, 19, 9, 17, 7, 13, 1, 7, 16, 0, 6, 1, 6, 4, 4, 7, 22, 18, 11, 23, 11, 7, 12, 25, 17, 28, 9, 15, 6, 17, 20, 8, 6, 4, 27, 25, 18, 29, 23, 4, 23, 12, 14, 13, 16, 25, 12, 27, 24, 7, 27, 3, 16, 15, 20, 14, 8, 11, 5, 0, 5, 12, 19, 26, 14, 23, 12, 5, 19, 8, 11, 11, 17, 19, 3, 19, 10, 0, 14, 29, 10, 8, 2, 1, 10, 8, 20, 22, 21, 23, 22, 28, 26, 21, 5, 5, 2, 22, 26, 17, 19, 16, 10, 24, 24, 24, 18, 14, 9, 1, 24, 15, 13, 9, 13, 27, 3, 4, 26, 9, 14, 3, 15, 25 }; for(int i=0; i<q; i++) send((X & (1 << a[i])) ? 1 : 0); } std::pair<int, int> decode(int N) { int a[180] = { 0, 27, 26, 21, 20, 3, 13, 12, 24, 25, 21, 21, 2, 28, 27, 1, 23, 7, 20, 15, 0, 28, 17, 2, 3, 18, 10, 10, 25, 11, 28, 2, 6, 13, 18, 20, 2, 16, 0, 16, 22, 18, 5, 9, 1, 29, 29, 29, 21, 15, 29, 28, 4, 8, 6, 26, 22, 19, 9, 17, 7, 13, 1, 7, 16, 0, 6, 1, 6, 4, 4, 7, 22, 18, 11, 23, 11, 7, 12, 25, 17, 28, 9, 15, 6, 17, 20, 8, 6, 4, 27, 25, 18, 29, 23, 4, 23, 12, 14, 13, 16, 25, 12, 27, 24, 7, 27, 3, 16, 15, 20, 14, 8, 11, 5, 0, 5, 12, 19, 26, 14, 23, 12, 5, 19, 8, 11, 11, 17, 19, 3, 19, 10, 0, 14, 29, 10, 8, 2, 1, 10, 8, 20, 22, 21, 23, 22, 28, 26, 21, 5, 5, 2, 22, 26, 17, 19, 16, 10, 24, 24, 24, 18, 14, 9, 1, 24, 15, 13, 9, 13, 27, 3, 4, 26, 9, 14, 3, 15, 25 }; int ans[q]; for(int i=0; i<q; i++) { ans[i] = receive(); } int b[q], c[q], d[q], e[q]; for(int i=1; i<q; i++) { b[i] = a[i-1]; c[i] = ans[i-1]; d[i] = a[i]; e[i] = ans[i]; } for(int i=1; i<=N; i++) { bool bad = 0; for(int j=1; j<q; j++) { int buh1 = ((i & (1<<a[j-1])) > 0); int buh2 = ((i & (1<<a[j])) > 0); if(buh1 != ans[j-1] && buh2 != ans[j]) { bad = 1; break; } } if(!bad) return {i, i}; } return {0, 0}; } /* g++ -std=c++17 -O2 -o T2442 sample_grader.cpp T2442.cpp ./T2442 < input.txt */

Compilation message (stderr)

communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:33:7: warning: variable 'b' set but not used [-Wunused-but-set-variable]
   33 |   int b[q], c[q], d[q], e[q];
      |       ^
communication.cpp:33:13: warning: variable 'c' set but not used [-Wunused-but-set-variable]
   33 |   int b[q], c[q], d[q], e[q];
      |             ^
communication.cpp:33:19: warning: variable 'd' set but not used [-Wunused-but-set-variable]
   33 |   int b[q], c[q], d[q], e[q];
      |                   ^
communication.cpp:33:25: warning: variable 'e' set but not used [-Wunused-but-set-variable]
   33 |   int b[q], c[q], d[q], e[q];
      |                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...