제출 #351912

#제출 시각아이디문제언어결과실행 시간메모리
351912talant117408앵무새 (IOI11_parrots)C++17
81 / 100
8 ms1548 KiB
#include "encoder.h" #include "encoderlib.h" #ifndef EVAL #include "grader.cpp" #endif #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) int((v).size()) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define OK cout << "OK" << endl; void encode(int N, int M[]){ if(N < 33){ for(int i = 0; i < N; i++) for(int bit = 0; bit < 8; bit++) if(M[i]&(1<<bit)) send(bit+i*8); } else{ vector <int> zero, one; for(int i = 0; i < N; i++){ int num = i; for(int bit = 0; bit < 4; bit++){ if(M[i]&(1<<bit)){ if(!bit) one.pb(num); else if(bit == 1) one.pb(num+64); else if(bit == 2) one.pb(num+128); else one.pb(num+192); } else{ if(!bit) zero.pb(num); else if(bit == 1) zero.pb(num+64); else if(bit == 2) zero.pb(num+128); else zero.pb(num+192); } } for(int bit = 0; bit < 4; bit++){ if(M[i]&(1<<(bit+4))){ if(!bit){ one.pb(num); one.pb(num); } else if(bit == 1){ one.pb(num+64); one.pb(num+64); } else if(bit == 2){ one.pb(num+128); one.pb(num+128); } else{ one.pb(num+192); one.pb(num+192); } } else{ if(!bit){ zero.pb(num); zero.pb(num); } else if(bit == 1){ zero.pb(num+64); zero.pb(num+64); } else if(bit == 2){ zero.pb(num+128); zero.pb(num+128); } else{ zero.pb(num+192); zero.pb(num+192); } } } } if(sz(zero) <= sz(one)){ for(auto to : zero) send(to); } else{ for(auto to : one) send(to); for(int i = 0; i < 4; i++) send(255); } } }
#include "decoder.h" #include "decoderlib.h" #ifndef EVAL #include "grader.cpp" #endif #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) int((v).size()) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define OK cout << "OK" << endl; void decode(int N, int L, int X[]){ if(N < 33){ vector <int> ans(N); for(int i = 0; i < L; i++) ans[X[i]/8] |= (1<<(X[i]%8)); for(auto to : ans) output(to); } else{ vector <int> cnt(256), ans(N); int flag = 0; if(cnt[255] > 3){ flag = 1; cnt[255] -= 4; } for(int i = 0; i < L; i++){ cnt[X[i]]++; } for(int i = 0; i < 256; i++){ if(cnt[i] > 1){ cnt[i] -= 2; int ind = 0, which = 0; for(int bit = 0; bit < 6; bit++){ if(i&(1<<bit)) ind |= (1<<bit); } if((i&(1<<6)) && (i&(1<<7))) which = 7; else if(i&(1<<7)) which = 6; else if(i&(1<<6)) which = 5; else which = 4; ans[ind] |= (1<<which); } if(cnt[i]){ cnt[i]--; int ind = 0, which = 0; for(int bit = 0; bit < 6; bit++){ if(i&(1<<bit)) ind |= (1<<bit); } if((i&(1<<6)) && (i&(1<<7))) which = 3; else if(i&(1<<7)) which = 2; else if(i&(1<<6)) which = 1; else which = 0; ans[ind] |= (1<<which); } } for(auto &to : ans){ if(!flag) to ^= 255; } for(auto to : ans) output(to); } } /* 8 0 0 1 1 0 0 1 0 6 1 255 13 26 49 216 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...