Submission #1051973

#TimeUsernameProblemLanguageResultExecution timeMemory
1051973Zbyszek99Parrots (IOI11_parrots)C++17
17 / 100
1 ms1320 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i <= b; i++) void encode(int n, int M[]) { vector<int> m; rep(i,0,n-1) m.push_back(M[i]); if(n > 0) { rep(j,0,(n%4)-1) m.push_back(255); for(int i = 0; i < (n+3)/4; i++) { int w = 0; int poz = i*4; if(m[poz] == 255) w += 1; if(m[poz+1] == 255) w += 2; if(m[poz+2] == 255) w += 4; if(m[poz+3] == 255) w += 8; int ans = i + (w << 4); if(w == 0) continue; send(ans); send(ans); send(ans); send(ans); } rep(i,0,n/2-1) { if(m[i] == 255) { continue; } rep(bit,0,7) { if(m[i] & (1 << bit)) { send(bit + (i << 3)); } } } rep(i,n/2,n-1) { if(m[i] == 255) { continue; } rep(bit,0,7) { if(m[i] & (1 << bit)) { send(bit + ((i-(n/2)) << 3)); send(bit + ((i-(n/2)) << 3)); } } } return; } rep(i,0,n-1) { rep(bit,0,7) { if(m[i] & (1 << bit)) { send(bit + (i << 3)); } } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i <= b; i++) void decode(int n, int l, int x[]) { vector<int> ans(n+4,0); if(n <= 0) { rep(i,0,l-1) { int bit = 0; if(x[i] & 1) bit += 1; if(x[i] & 2) bit += 2; if(x[i] & 4) bit += 4; int poz = x[i] >> 3; ans[poz] |= (1 << bit); } } else { map<int,int> zlicz; rep(i,0,l-1) zlicz[x[i]]++; rep(i,0,l-1) { cerr << x[i] << " zap\n"; if(zlicz[x[i]] == 1 || zlicz[x[i]] == 3) { int bit = 0; if(x[i] & 1) bit += 1; if(x[i] & 2) bit += 2; if(x[i] & 4) bit += 4; int poz = x[i] >> 3; ans[poz] |= (1 << bit); } if(zlicz[x[i]] == 2 || zlicz[x[i]] == 3) { int bit = 0; if(x[i] & 1) bit += 1; if(x[i] & 2) bit += 2; if(x[i] & 4) bit += 4; int poz = x[i] >> 3; ans[poz + n/2] |= (1 << bit); } if(zlicz[x[i]] == 4) { int blok = x[i] & (1+2+4+8); int is = x[i] & (16+32+64+128); int p = 0; cerr << blok << " " << is << " info255"; rep(j,blok*4,blok*4+3) { if(is & (1 << p)) ans[j] = 255; p++; } } } } cerr << "ans: "; rep(i,0,n-1) cerr << ans[i] << " "; cerr << "\n"; rep(i,0,n-1) output(ans[i]); }
#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...