제출 #1370828

#제출 시각아이디문제언어결과실행 시간메모리
1370828edga1메시지 (IOI24_message)C++20
79.64 / 100
298 ms836 KiB
#include <bits/stdc++.h>
#include "message.h"
#define fi first
#define se second
#define pb push_back
#define ll long long
using namespace std;

void send_message(vector<bool> m, vector<bool> c) {
    int n=(int)m.size();
    vector<bool> z(31,0), o(31,1);
    int f=-1,p=0;
    while(f==-1){
        if(!c[p]) f=p;
        p++;
    }
    for(int i=0; i<4; i++){
        if(f&(1<<i)) send_packet(o);
        else send_packet(z);
    }
    vector<bool> nm;
    for(int i=0; i<11; i++){
        if(n&(1<<i)) nm.pb(1);
        else nm.pb(0);
    }
    for(auto au : m) nm.pb(au);
    p=0;
    int pos=0;
    while(p<(int)nm.size() || pos<31){
        vector<bool> me(31,0);
        for(int i=0; i<31; i++){
            if(p==(int)nm.size()) break;
            if(pos<31 && i==f) continue;
            if(c[i]==0){
                me[i]=nm[p];
                p++;
            }
            if(p==(int)nm.size()) break;
        }
        if(pos<31){
            me[f]=c[pos];
            pos++;
        }
        send_packet(me);
    }
    return;
}

vector<bool> receive_message(vector<vector<bool>> r) {
    int n=(int)r.size();
    int f=0;
    for(int i=0; i<4; i++){
        int o=0;
        for(int j=0; j<31; j++){
            if(r[i][j]==1) o++;
        }
        if(o>=16) f+=(1<<i);
    }
    vector<bool> c(31);
    for(int i=4; i<35; i++){
        c[i-4]=r[i][f];
    }
    vector<bool> m;
    for(int i=4; i<n; i++){
        for(int j=0; j<31; j++){
            if((j!=f || i>=35) && c[j]==0) m.pb(r[i][j]);
        }
    }
    int l=0;
    for(int i=0; i<11; i++){
        if(m[i]==1) l+=(1<<i);
    }
    vector<bool> atb;
    for(int i=11; i<11+l; i++) atb.pb(m[i]);
    return atb;
}

/*
1
10
0 1 1 0 0 1 1 1 0 0
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
*/
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…