Submission #18403

#TimeUsernameProblemLanguageResultExecution timeMemory
18403suhgyuho_williamParrots (IOI11_parrots)C++98
88 / 100
16 ms2536 KiB
#include "encoder.h" #include "encoderlib.h" void encode(int N, int M[]){ int i,j,tt; int tmp[100]; int a[100]; for(i=0; i<N; i++) tmp[i] = M[i]; if(N <= 32){ for(i=0; i<N; i++){ j = -1; while(M[i] != 0){ tt = M[i] % 2; M[i] /= 2; j++; if(tt == 0) continue; send(8*i+j); } } for(i=0; i<N; i++) M[i] = tmp[i]; return; } for(i=0; i<N; i++){ for(j=0; j<8; j++){ a[j] = M[i] % 2; M[i] /= 2; } for(j=0; j<4; j++){ if(a[j*2] == 1 && a[(j*2)+1] == 1){ send(i*4+j); send(i*4+j); send(i*4+j); }else if(a[j*2] == 1){ send(i*4+j); }else if(a[(j*2)+1] == 1){ send(i*4+j); send(i*4+j); } } } for(i=0; i<N; i++) M[i] = tmp[i]; }
#include "decoder.h" #include "decoderlib.h" #include <algorithm> #include <stdlib.h> #include <stdio.h> using namespace std; void decode(int N, int L, int X[]){ int i,j; int t1,t2; int ans[100]; int tmp[100][4]; if(N <= 32){ for(i=0; i<N; i++) ans[i] = 0; for(i=0; i<L; i++){ t1 = X[i] / 8; t2 = X[i] % 8; ans[t1] += (1 << t2); } for(i=0; i<N; i++){ output(ans[i]); } return; } for(i=0; i<N; i++){ for(j=0; j<4; j++){ tmp[i][j] = 0; } } for(i=0; i<L; i++){ t1 = X[i] / 4; t2 = X[i] % 4; tmp[t1][t2]++; } for(i=0; i<N; i++) ans[i] = 0; for(i=0; i<N; i++){ for(j=0; j<4; j++){ if(tmp[i][j] == 1){ ans[i] += (1 << (2*j)); }else if(tmp[i][j] == 2){ ans[i] += (1 << ((2*j)+1)); }else if(tmp[i][j] == 3){ ans[i] += (1 << (2*j)); ans[i] += (1 << ((2*j)+1)); } } } for(i=0; i<N; i++) 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...