답안 #1103280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103280 2024-10-20T16:31:08 Z Ahmed57 메시지 (IOI24_message) C++17
100 / 100
1363 ms 1104 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<66;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++){
        if(C[i])continue;
        int j = 0;
        while(v[j][i]==0){
            j++;
        }
        j++;
        for(;j<66;j++){
            if(it==M.size()){
                v[j][i] = !M.back();
            }else{
                v[j][i] = M[it++];
            }
        }
    }
    for(int i = 0;i<66;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<66&&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<66;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:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             if(it==M.size()){
      |                ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 656 KB Used 66 days
# 결과 실행 시간 메모리 Grader output
1 Correct 1234 ms 848 KB Used 66 days
2 Correct 1363 ms 844 KB Used 66 days
3 Correct 1142 ms 868 KB Used 66 days
4 Correct 1064 ms 860 KB Used 66 days
5 Correct 857 ms 844 KB Used 66 days
6 Correct 666 ms 1104 KB Used 66 days
7 Correct 784 ms 864 KB Used 66 days
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 656 KB Used 66 days
2 Correct 1234 ms 848 KB Used 66 days
3 Correct 1363 ms 844 KB Used 66 days
4 Correct 1142 ms 868 KB Used 66 days
5 Correct 1064 ms 860 KB Used 66 days
6 Correct 857 ms 844 KB Used 66 days
7 Correct 666 ms 1104 KB Used 66 days
8 Correct 784 ms 864 KB Used 66 days
9 Correct 1220 ms 864 KB Used 66 days
10 Correct 1194 ms 844 KB Used 66 days
11 Correct 1200 ms 848 KB Used 66 days
12 Correct 1238 ms 1100 KB Used 66 days
13 Correct 1266 ms 844 KB Used 66 days
14 Correct 915 ms 864 KB Used 66 days
15 Correct 652 ms 864 KB Used 66 days
16 Correct 848 ms 1104 KB Used 66 days
17 Correct 821 ms 1100 KB Used 66 days
18 Correct 1170 ms 868 KB Used 66 days
19 Correct 1138 ms 1100 KB Used 66 days
20 Correct 1236 ms 868 KB Used 66 days
21 Correct 1172 ms 868 KB Used 66 days
22 Correct 1203 ms 996 KB Used 66 days
23 Correct 1128 ms 848 KB Used 66 days
24 Correct 1241 ms 940 KB Used 66 days
25 Correct 1218 ms 872 KB Used 66 days
26 Correct 1238 ms 852 KB Used 66 days
27 Correct 1200 ms 940 KB Used 66 days
28 Correct 1191 ms 860 KB Used 66 days