제출 #1231852

#제출 시각아이디문제언어결과실행 시간메모리
1231852Sir_Ahmed_Imran메시지 (IOI24_message)C++17
0 / 100
170 ms844 KiB
#include "message.h"
#include <bits/stdc++.h>
using namespace std;
#define N 100001
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define ld long double
#define terminator main
#define pll pair<ll,ll>
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

vector<int> v {1030205859, 1117277788, 930800459, 1216683188, 1802617219, 344866428, 1881899938, 265583709, 553072512, 1594411135, 1626599314, 520884333, 1763392206, 384091441, 1539655910, 607827737, 50611628, 2096872019, 1329762898, 817720749, 135996102, 2011487545, 1840536745, 306946902, 1870352401, 277131246, 245652166, 1901831481};
int p[31];

void send_message(vector<bool> M, vector<bool> c) {
    vector<bool> a(31, 0);
    p[0] = 1;
    for(int i = 1; i < 31; i++)
        p[i] = p[i - 1] * 2;
    for(auto & i : v){
        for(int j = 0; j < 31; j++){
            if(c[j]) continue;
            a[j] = ((i & p[j]) == p[j]);
        }
        send_packet(a);
    }
    int s = M.size(), t = 0;
    for(int i = 0; i < 31; i++){
        if(c[i]) continue;
        a[i] = ((s & p[t]) == p[t]);
        t++;
    }
    send_packet(a);
    t = 0;
    while(t < s){
        for(int i = 0; i < 31; i++){
            if(c[i] || t == s) continue;
            a[i] = M[t];
            t++;
        }
        send_packet(a);
    }
}

vector<bool> receive_message(vector<vector<bool>> R) {
    vector<bool> M, c(31, 0);
    for(int i = 0; i < v.size(); i++)
        for(int j = 0; j < 31; j++)
            if(bool((v[i] & p[j]) == p[j]) != R[i][j])
                c[j] = 1;
    int s = 0, t = 0;
    for(int i = 0; i < 31; i++){
        if(c[i]) continue;
        if(R[v.size()][i]) s += p[t];
        t++;
    }
    t = 0;
    for(int i = v.size() + 1; i < R.size(); i++){
        for(int j = 0; j < 31; j++){
            if(c[j] || t == s) continue;
            M.append(R[i][j]);
            t++; 
        }
    }
    return M;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...