# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1103262 |
2024-10-20T15:58:25 Z |
Ahmed57 |
Message (IOI24_message) |
C++17 |
|
1148 ms |
656 KB |
#include <bits/stdc++.h>
using namespace std;
vector<vector<bool>> X;
vector<bool> send_packet(vector<bool> A);
void send_message(std::vector<bool> M, std::vector<bool> C){
vector<vector<bool>> v;
for(int i = 0;i<64;i++){
v.push_back(vector<bool>(31,0));
}
for(int i = 0;i<31;i++){
int la = -1;
for(int j = 1;j<31;j++){
if(C[i]==C[(i+j)%31]){
la = j;
break;
}
}
for(int j = 0;j<la-1;j++){
v[j][i] = 0;
}
v[la-1][i] = 1;
}
int it = 0;
for(int i = 0;i<31;i++){
int j = 0;
while(v[j][i]==0){
j++;
}
j++;
for(;j<64;j++){
if(it==M.size()){
v[j][i] = !M.back();
}else{
v[j][i] = M[it++];
}
}
}
for(int i = 0;i<64;i++){
send_packet(v[i]);
}
}
std::vector<bool> receive_message(std::vector<std::vector<bool>> R){
int nxt[31];
for(int i = 0;i<31;i++){
int j = 0;
while(j<64&&R[j][i]==0)j++;
j++;
if(j<31){
nxt[i] = (i+j)%31;
}else{
nxt[i] = -1;
}
}
vector<int> ans;
for(int i = 0;i<31;i++){
int x = i;
vector<int> v = {i};
int sz = 1;
while(nxt[x]!=i&&sz<40){
if(nxt[x]==-1){
sz = 40;
continue;
}
x = nxt[x];
v.push_back(x);
sz++;
}
if(sz==16){
ans = v;
}
}
sort(ans.begin(),ans.end());
vector<bool> M;
for(auto i:ans){
int j = 0;
while(R[j][i]==0)j++;
j++;
for(;j<64;j++){
M.push_back(R[j][i]);
}
}
bool v = M.back();
while(M.back()==v)M.pop_back();
return M;
}
// signed main(){
// send_message({1,0,0,1,1},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1});
// for(auto i:receive_message(X)){
// cout<<i<<endl;
// }
// }
Compilation message
message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if(it==M.size()){
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
656 KB |
Used 64 days |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1148 ms |
428 KB |
decoded message is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
656 KB |
Used 64 days |
2 |
Incorrect |
1148 ms |
428 KB |
decoded message is incorrect |
3 |
Halted |
0 ms |
0 KB |
- |