Submission #1231843

#TimeUsernameProblemLanguageResultExecution timeMemory
1231843Sir_Ahmed_Imran메시지 (IOI24_message)C++17
0 / 100
271 ms848 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 {186461322, 1961022325, 1688014719, 459468928, 1784766788, 362716859, 542923229, 1604560418, 1870898801, 276584846, 2143346255, 4137392, 1767359506, 380124141, 1816653205, 330830442, 610554887, 1536928760, 300871699, 1846611948, 666585931, 1480897716, 901685245, 1245798402, 802168644, 1345315003, 293532275, 1853951372, 797907561, 1349576086, 283583852, 1863899795, 1778288767, 369194880, 1031748925, 1115734722, 1978495661, 168987986, 585708333, 1561775314, 359924403, 1787559244, 835687811, 1311795836, 1330748458, 816735189, 698380750, 1449102897, 1359327003, 788156644};
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...