Submission #1297997

#TimeUsernameProblemLanguageResultExecution timeMemory
1297997bangchan메시지 (IOI24_message)C++20
0 / 100
139 ms816 KiB
#include "message.h" #include <iostream> #include <vector> #include <map> #include <algorithm> #include <limits.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<char> vc; typedef vector<vi> vvi; typedef pair<int,int> pii; typedef vector<pii> vii; typedef map<int, int> mii; typedef vector<vl> vvl; typedef pair<ll, ll> pll; typedef vector<pll> vpl; #define F first #define S second #define yes cout << "YES" << endl #define no cout << "NO" << endl #define pb push_back #define forn(i, x, n) for (ll i = x; i < ll(n); i++) #define fornl(i, x, n) for(ll i = x; i >= ll(n); i--) #define all(x) x.begin(), x.end() #define mod 1000000007 #define inf 10000000000000 void send_message(const vector<bool> M, vector<bool> C) { vb a(31, 0); vl idx; ll cl = 0; forn(i, 0, 31){ forn(j, 0, 31) a[j] = C[j]; if(!C[i]){cl += (i < 19); idx.pb(i);} if(i < 19) send_packet(a); } if(cl > 4){ ll h = 19, j = 0; while(h < 31){ a.assign(31, 0); ll x = 0; for(ll i = 0; i < cl && h < 31; i++){ if(C[h] == 0) x++; h++; a[idx[i]] = C[h]; } cl += x; send_packet(a); j++; } } vb b(31, 0); forn(i, 0, 11){ b[idx[i]] = (b.size() & (1 << i)) != 0; } send_packet(b); ll t = 0; for(ll i = 0; i < (M.size() + 15) / 16; i++){ //+= 16 ll p = 0; forn(j, 0, 16){ if(p < idx.size()){ a[idx[p]] = M[t]; p++; t++; } } send_packet(a); } } vector<bool> receive_message(vector<vector<bool>> R) { vb a; vl idx; forn(i, 0, 19){ ll qo = 0, qn = 0; forn(j, 0, R[i].size()){ if(R[i][j]) qo++; else qn++;} if(qn > qo) idx.pb(i); } ll x = 19, act = idx.size(); if(act > 4){ ll h = 19; while(h < 31){ act = idx.size(); for(ll i = 0; i < act && h < 31; i++){ if(!R[x][idx[i]]) idx.pb(h); h++; } x++; } } else { forn(j, 19, 31) idx.pb(j); } ll y = 0; forn(i, 0, 11) if(R[x][idx[i]]) y += (1 << i); x++; vb an(y); ll t = 0; for(ll i = 0; i < (y + 15) / 16; i++){ //+= 16 ll p = 0; forn(j, 0, 16){ if(p < idx.size()){an[j] = R[x][idx[p]]; p++; t++;} } x++; } return an; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...