Submission #1121012

#TimeUsernameProblemLanguageResultExecution timeMemory
1121012woohyun_jngMessage (IOI24_message)C++17
Compilation error
0 ms0 KiB
#include <cassert> #include <cstdio> #include <cstdlib> #include "message.h" #include <bits/stdc++.h> using namespace std; void send_message(vector<bool> M, vector<bool> C) { vector<bool> A(31, 0); vector<int> B; for (int i = 0; i < 31; i++) { fill(A.begin(), A.end(), !C[i]); send_packet(A); if (!C[i]) B.push_back(i); if (B.size() == 5) { for (int j = i + 1; j < 31; j++) { if (!C[j]) { B.push_back(j); continue; } for (int k = 0; k < 5; k++) A[B[k]] = j & (1 << k); send_packet(A); } break; } } int S = M.size(); for (int j = 0; j < 10; j++) A[B[j]] = S & (1 << j); send_packet(A); for (int i = 0; i < (S + 15) / 16; i++) { for (int j = 0; j < 16 && 16 * i + j < S; j++) A[B[j]] = M[16 * i + j]; send_packet(A); } } vector<bool> receive_message(vector<vector<bool>> R) { vector<bool> res, C(31, 1); vector<int> cor, nt; int cnt = 0, val, S = 0; for (int i = 0; i < R.size(); i++) { cnt = 0; for (bool j : R[i]) cnt += j; if (cnt >= 16) cor.push_back(i); else nt.push_back(i); if (cor.size() == 5) { for (int j = i + 1; j < 20; j++) { val = 0; for (int k = 4; k >= 0; k--) val = (val << 1) | R[j][cor[k]]; nt.push_back(val); } break; } } for (int i : nt) C[i] = 0; cor.clear(); for (int i = 0; i < 31; i++) if (C[i]) cor.push_back(i); for (int i = 9; i >= 0; i--) S = S << 1 | R[20][cor[i]]; for (int i = 21; i < R.size(); i++) for (int j = 0; j < 16; j++) if ((i - 21) * 16 + j < S) res.push_back(R[i][cor[j]]); return res; } namespace { const int PACKET_SIZE = 31; const int CALLS_CNT_LIMIT = 100; int calls_cnt; std::vector<bool> C(PACKET_SIZE); std::vector<std::vector<bool>> R; void quit(const char *message) { printf("%s\n", message); exit(0); } void run_scenario() { R.clear(); calls_cnt = 0; int S; assert(1 == scanf("%d", &S)); std::vector<bool> M(S); for (int i = 0; i < S; i++) { int bit; assert(1 == scanf("%d", &bit)); assert((bit == 0) || (bit == 1)); M[i] = bit; } for (int i = 0; i < PACKET_SIZE; i++) { int bit; assert(1 == scanf("%d", &bit)); assert((bit == 0) || (bit == 1)); C[i] = bit; } send_message(M, C); std::vector<bool> D = receive_message(R); int K = (int)R.size(); int L = (int)D.size(); printf("%d %d\n", K, L); for (int i = 0; i < L; i++) printf("%s%d", (i == 0 ? "" : " "), (D[i] ? 1 : 0)); printf("\n"); } std::vector<bool> taint(const std::vector<bool> &A) { std::vector<bool> B = A; bool bit = 0; for (int i = 0; i < PACKET_SIZE; i++) if (C[i] == 1) { B[i] = bit; bit = !bit; } return B; } } // namespace std::vector<bool> send_packet(std::vector<bool> A) { calls_cnt++; if (calls_cnt > CALLS_CNT_LIMIT) quit("Too many calls"); if ((int)A.size() != PACKET_SIZE) quit("Invalid argument"); std::vector<bool> B = taint(A); R.push_back(B); return B; } int main() { int T; assert(1 == scanf("%d", &T)); for (int i = 1; i <= T; i++) run_scenario(); }

Compilation message (stderr)

message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i = 0; i < R.size(); i++) {
      |                     ~~^~~~~~~~~~
message.cpp:81:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for (int i = 21; i < R.size(); i++)
      |                      ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccGnAaZa.o: in function `send_packet(std::vector<bool, std::allocator<bool> >)':
stub.cpp:(.text+0x230): multiple definition of `send_packet(std::vector<bool, std::allocator<bool> >)'; /tmp/ccPmAhi9.o:message.cpp:(.text+0x960): first defined here
/usr/bin/ld: /tmp/ccGnAaZa.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccPmAhi9.o:message.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status