제출 #590754

#제출 시각아이디문제언어결과실행 시간메모리
590754tutisFlight to the Ford (BOI22_communication)C++17
0 / 100
667 ms1776 KiB
#include <bits/stdc++.h> using namespace std; #include "communication.h" void encode(int N, int X) { X--; int Y = X; mt19937_64 rng(1832); set<int>S; for (int t = 0; t < 1000; t++) { int i = rng() % 250; if (S.count(i) || S.count(i - 1) || S.count(i + 1)) continue; S.insert(i); } bool ok = true; for (int i = 0; i < 250; i++) { if (S.count(i)) { int v = 0; int x = send(v); ok = (v == x); } else if (S.count(i - 1)) { if (ok) { send(X % 2); X /= 2; } else { send(Y % 2); Y /= 2; } } else { int x = send(rng() % 2); } } } pair<int, int> decode(int N) { mt19937_64 rng(1832); set<int>S; for (int t = 0; t < 1000; t++) { int i = rng() % 250; if (S.count(i) || S.count(i - 1) || S.count(i + 1)) continue; S.insert(i); } int a = 0; int b = 0; int ba = 1; int bb = 1; bool ok = true; int cnta = 0; int cntb = 0; for (int i = 0; i < 250; i++) { int rec = receive(); if (S.count(i)) { int v = 0; int x = rec; ok = (v == x); } else if (S.count(i - 1)) { if (ok) { if (cnta < 30) { a += rec * ba; ba *= 2; cnta++; } } else { if (cntb < 30) { b += rec * bb; bb *= 2; cntb++; } } } } a = max(a, 0); a = min(a, N - 1); b = max(b, 0); b = min(b, N - 1); return {a + 1, b + 1}; } // int main() // { // encode(15, 5); // pair<int, int>v = decode(15); // cout << v.first << " " << v.second << endl; // }

컴파일 시 표준 에러 (stderr) 메시지

communication.cpp: In function 'void encode(int, int)':
communication.cpp:41:8: warning: unused variable 'x' [-Wunused-variable]
   41 |    int x = send(rng() % 2);
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...