제출 #1121135

#제출 시각아이디문제언어결과실행 시간메모리
1121135woohyun_jng메시지 (IOI24_message)C++17
0 / 100
731 ms1092 KiB
#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, cor; int X, S = M.size(), cur = 0, cnt = 0, K = 0; for (int i = 0; i < 30; i++) { if (C[i] == 0 && C[i + 1] == 0) { for (int j = 0; j < 5; j++) { fill(A.begin(), A.end(), i & (1 << j)); send_packet(A), K++; } X = i; break; } } for (int i = 0; i < 31; i++) { if (i == X || i == X + 1) continue; if (C[i] == 0) cor.push_back(i); B.push_back(i); } for (int i = 0; i < 14; i++) { A[X] = !C[B[i * 2]], A[X + 1] = !C[B[i * 2 + 1]]; for (int j = 0; j < 14 && cur + j < S; j++) A[cor[j]] = M[cur + j]; cur += 14; send_packet(A), K++; } cor.push_back(X), cor.push_back(X + 1); sort(cor.begin(), cor.end()); for (int i = 0; i < 10; i++) A[cor[i]] = (S - 1) & (1 << i); send_packet(A), K++; while (cur < S) { for (int i = 0; i < 16; i++) { if (cur + i < S) A[cor[i]] = M[cur + i]; } send_packet(A); cur += 16; } } vector<bool> receive_message(vector<vector<bool>> R) { int cnt, X = 0, Y = 0, S = 0, cur = 0; vector<int> B, cor, cor2; vector<bool> C(31, 0), res; for (int i = 4; i >= 0; i--) { cnt = 0; for (bool j : R[i]) cnt += j; X = (X << 1) | (cnt >= 16); } C[X] = C[X + 1] = 1; for (int i = 0; i < 31; i++) { if (i == X || i == X + 1) continue; B.push_back(i); } for (int i = 5; i < 19; i++) C[B[Y++]] = R[i][X], C[B[Y++]] = R[i][X + 1]; Y = 0; for (int i = 0; i < 31; i++) { if (i == B[28]) continue; Y += C[i]; } if (Y == 15) C[B[28]] = 1; for (int i = 0; i < 31; i++) if (C[i]) { if (!(i == X || i == X + 1)) cor2.push_back(i); cor.push_back(i); } for (int i = 9; i >= 0; i--) S = (S << 1) | R[19][cor[i]]; S++; cnt = 5; while (cnt < 19 && cur < S) { for (int i = 0; i < 14 && cur + i < S; i++) { res.push_back(R[cnt][cor2[i]]); } cnt++, cur += 14; } cnt = 20; while (cur < S) { for (int i = 0; i < 16; i++) res.push_back(R[cnt][cor[i]]); cnt++, cur += 16; } return res; }

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

message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:9:35: warning: unused variable 'cnt' [-Wunused-variable]
    9 |     int X, S = M.size(), cur = 0, cnt = 0, K = 0;
      |                                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...