Submission #1108901

#TimeUsernameProblemLanguageResultExecution timeMemory
1108901Ghulam_JunaidMessage (IOI24_message)C++17
79.64 / 100
2870 ms1088 KiB
#include <bits/stdc++.h> #include "message.h" using namespace std; void send_message(vector<bool> M, vector<bool> C) { vector<int> allowed; for (int i = 0; i < 31; i ++) if (!C[i]) allowed.push_back(i); int fbit = allowed[0]; for (int i = 0; i < 4; i ++){ if ((1 << i) & fbit){ vector<bool> A(31, 1); send_packet(A); } else{ vector<bool> A(31, 0); send_packet(A); } } int p = 0; vector<bool> A(31, 0); for (int i = 0; i < 31; i ++){ if (C[i]) A[fbit] = 1; else A[fbit] = 0; for (int j = 1; j < allowed.size(); j ++){ A[allowed[j]] = M[p % M.size()]; p++; } send_packet(A); } for (int i = 0; i < allowed.size(); i ++){ if ((1 << i) & M.size()) A[allowed[i]] = 1; else A[allowed[i]] = 0; } send_packet(A); while (p < M.size()){ for (int j = 0; j < allowed.size(); j ++){ A[allowed[j]] = M[p % M.size()]; p++; } send_packet(A); } } vector<bool> receive_message(vector<vector<bool>> R) { int fbit = 0; int q = 0; for (int i = q; i < q + 4; i ++){ int cnt = 0; for (bool x : R[i]) cnt += x; if (cnt >= 16) fbit += (1 << i); } q += 4; vector<int> allowed; for (int i = q; i < q + 31; i ++) if (!R[i][fbit]) allowed.push_back(i - 4); vector<bool> res; for (int i = q; i < q + 31; i ++){ for (int j = 1; j < allowed.size(); j ++){ res.push_back(R[i][allowed[j]]); } } q += 31; int sz = 0; for (int i = 0; i < allowed.size(); i ++) if (R[q][allowed[i]]) sz += (1 << i); q++; while (q < R.size()){ for (int x : allowed) res.push_back(R[q][x]); q++; } while (res.size() > sz) res.pop_back(); return res; }

Compilation message (stderr)

message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:31:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (int j = 1; j < allowed.size(); j ++){
      |                         ~~^~~~~~~~~~~~~~~~
message.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < allowed.size(); i ++){
      |                     ~~^~~~~~~~~~~~~~~~
message.cpp:46:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     while (p < M.size()){
      |            ~~^~~~~~~~~~
message.cpp:47:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int j = 0; j < allowed.size(); j ++){
      |                         ~~^~~~~~~~~~~~~~~~
message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:75:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         for (int j = 1; j < allowed.size(); j ++){
      |                         ~~^~~~~~~~~~~~~~~~
message.cpp:83:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for (int i = 0; i < allowed.size(); i ++)
      |                     ~~^~~~~~~~~~~~~~~~
message.cpp:88:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     while (q < R.size()){
      |            ~~^~~~~~~~~~
message.cpp:94:23: warning: comparison of integer expressions of different signedness: 'std::vector<bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   94 |     while (res.size() > sz)
      |            ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...