Submission #770161

#TimeUsernameProblemLanguageResultExecution timeMemory
770161teamariaaParrots (IOI11_parrots)C++17
81 / 100
4 ms1188 KiB
#include <bits/stdc++.h> #include "encoder.h" #include "encoderlib.h" using namespace std; /// ratio 6N + 8(flaguri) void encode(int n, int m[]) { bitset <256> code; if(n == 1) { send(m[0]); return; } for(int i = 0; i < 8 * n; i ++) code[i] = 0; int j; for(int i = 0; i < n; i ++) { j = 0; int copie = m[i]; while(copie) { code[8 * (i + 1) - 1 - j] = copie % 2; copie >>= 1; j ++; } } // for(int i = 0; i < 8 * n; i ++) // cout << code[i] << " "; // cout << "\n"; int cnt1 = 0, cnt0 = 0, flag = 0; for(int i = 0; i < 4 * n; i ++) { if(code[i] == 1) cnt1 ++; else cnt0 ++; } if(cnt1 <= cnt0) { flag = 1; send(1); send(1); send(1); send(1); } // cout << "flag " << flag << "\n"; for(int i = 0; i < 4 * n; i ++) { if(code[i] == flag) send(i); } /////////////////////////////////// cnt1 = 0, cnt0 = 0; for(int i = 4 * n; i < 8 * n; i ++) { if(code[i] == 1) cnt1 ++; else cnt0 ++; } flag = 0; if(cnt1 <= cnt0) { flag = 1; send(0); send(0); send(0); send(0); } for(int i = 4 * n; i < 8 * n; i ++) { if(code[i] == flag) { // cout << "code " << i - 4 * n << " " << i - 4 * n << "\n"; send(i - 4 * n); send(i - 4 * n); } } }
#include <bits/stdc++.h> #include "decoder.h" #include "decoderlib.h" using namespace std; void decode(int n, int l, int x[]) { if(l == 1) { output(x[0]); return; } bitset <256> code; // for(int i = 0; i < 8 * n; i ++) // code[i] = 0; // for(int i = 0; i < l; i ++) // cout << x[i] << " "; // cout << "\n"; sort(x, x + l); int cnt, flag1 = 0, flag2 = 0, i; cnt = 1, i = 0; if(x[i] == 0) { while(i < l - 1 && x[i] == x[i + 1]) { i ++; cnt ++; } if(cnt >= 4) flag2 = 1; i ++; } cnt = 1; if(x[i] == 1) { while(i < l - 1 && x[i] == x[i + 1]) { i ++; cnt ++; } if(cnt >= 4) flag1 = 1; // cout << cnt << " "; i ++; } // cout << "flag " << flag1 << "\n"; // cout << "flag " << flag2 << "\n"; for(int i = 0; i < 4 * n; i ++) code[i] = 1 - flag1; for(int i = 4 * n; i < 8 * n; i ++) code[i] = 1 - flag2; i = 0; for(int i = 0; i < l; i ++) { cnt = 1; while(i < l - 1 && x[i] == x[i + 1]) { i ++; cnt ++; } if((x[i] == 0 || x[i] == 1) && cnt >= 4) cnt -=4; if(cnt == 1 || cnt == 3) code[x[i]] = flag1; if(cnt == 2 || cnt == 3) code[4 * n + x[i]] = flag2; } // // for(int i = 0; i < 8 * n; i ++) // cout << code[i] << " "; // cout << "\n"; for(int i = 7; i < 8 * n; i +=8) { int pow = 1, nr = 0; for(int j = 0; j <= 7; j ++, pow <<= 1) nr += code[i - j] * pow; output(nr); } }
#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...