Submission #254678

#TimeUsernameProblemLanguageResultExecution timeMemory
254678SortingParrots (IOI11_parrots)C++14
98 / 100
11 ms1792 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; void encode(int N, int M[]){ if(N >= 16){ mt19937 mt(8); auto rnd = [&](int mod){ return mt() % mod; }; int p[64]; for(int i = 0; i < N; ++i) p[i] = i; random_shuffle(p, p + N, rnd); int prev = 0; for(int i = 0; i < N; ++i){ for(int j = 0; j <= 7; ++j){ if((M[p[i]] ^ prev) & (1 << j)){ if(i >= 32){ send((i - 32) * 8 + j); send((i - 32) * 8 + j); } else send(i * 8 + j); } } prev = M[p[i]]; } return; } for(int i = 0; i < N; ++i){ for(int j = 0; j <= 7; ++j){ if(M[i] & (1 << j)) send(i * 8 + j); } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; static int e[256]; void decode(int N, int L, int X[]){ for(int i = 0; i < 256; ++i) e[i] = 0; if(N >= 16){ for(int i = 0; i < L; ++i) e[X[i]]++; mt19937 mt(8); auto rnd = [&](int mod){ return mt() % mod; }; int p[64]; for(int i = 0; i < N; ++i) p[i] = i; random_shuffle(p, p + N, rnd); int ans[64]; int prev = 0; for(int i = 0; i < N; ++i){ int curr = 0; for(int j = 0; j <= 7; ++j){ if(i >= 32){ if(e[(i - 32) * 8 + j] & 2) curr += (1 << j); } else{ if(e[i * 8 + j] & 1) curr += (1 << j); } } prev ^= curr; ans[p[i]] = prev; } for(int i = 0; i < N; ++i) output(ans[i]); return; } for(int i = 0; i < L; ++i) e[X[i]] = true; for(int i = 0; i < N; ++i){ int curr = 0; for(int j = 0; j <= 7; ++j){ if(e[i * 8 + j]) curr += (1 << j); } output(curr); } }
#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...