Submission #29246

#TimeUsernameProblemLanguageResultExecution timeMemory
29246NikeforParrots (IOI11_parrots)C++98
81 / 100
17 ms2528 KiB
#include "encoder.h" #include "encoderlib.h" #include<cmath> #include<cstdio> bool a[9]; void encode(int N, int M[]) { int sum=0; // printf("hebele\n"); for(int i=0; i<N; i++) { for(int b=0; b<9; b++) a[b] = false; int n = M[i]; int msg=i; // printf("%d sayi var i=%d\n",N, i); msg = msg<<2; // printf("msg %d\n", msg); //n sayisi ikilik tabana donusturule for(int j=7; j>-1; j--) { if( n>=(1<<j) ) { a[j] = true; // printf("%d true\n", j); n-=1<<j; } } for(int j=0; j<4; j++) { if(a[2*j] and a[2*j+1]) { sum+=3; } else if(a[2*j]) { sum+=2;} else if(a[2*j+1]) {sum++;} } } for(int i=0; i<N; i++) { for(int b=0; b<9; b++) a[b] = false; int n = M[i]; int msg=i; // printf("%d sayi var i=%d\n",N, i); msg = msg<<2; // printf("msg %d\n", msg); //n sayisi ikilik tabana donusturule for(int j=7; j>-1; j--) { if( n>=(1<<j) ) { a[j] = true; // printf("%d true\n", j); n-=1<<j; } } //printf("hebele\n"); if(sum> (8*N)) { // printf("hebele\n"); int sen=4; send(255); send(255); send(255); send(255); for(int j=0; j<4; j++) { if(!(a[2*j] or a[2*j+1]) ) { /*printf("%d 3 kere\n", j); */send(msg+j); send(msg+j); send(msg+j); sen+=3;} else if(a[2*j] and a[2*j+1]) continue; else if(a[2*j]) { send(msg+j); send(msg+j); /*printf("%d 2 kere\n", j);*/ sen+=2;} else if(a[2*j+1]) {/*printf("%d 1 kere\n", j); */send(msg+j); sen++;} } // printf("%d kere yollandi\n",sen); } else for(int j=0; j<4; j++) { if(a[2*j] and a[2*j+1]) { /*printf("%d 3 kere\n", j);*/ send(msg+j); send(msg+j); send(msg+j); } else if(a[2*j]) { send(msg+j); /*printf("%d 1 kere\n", j); */} else if(a[2*j+1]) {/*printf("%d 2 kere\n", j); */send(msg+j); send(msg+j); } } } /*int i; for(i=0; i<N; i++) send(M[i]);*/ }
#include "decoder.h" #include "decoderlib.h" #include<cmath> #include<cstdio> #include<bits/stdc++.h> using namespace std; int as[66][6]; int ctr; void decode(int N, int L, int X[]) { for(int i=0; i<66; i++) for(int j=0; j<6;j++) as[i][j] = 0; ctr = 0; for(int i=0; i<L; i++) if(X[i]==255) ctr++; if(ctr>3) { for(int i=0; i<66; i++) for(int j=0; j<6;j++) as[i][j] = 3; for(int i=0; i<L; i++) { int n = X[i]; n = n>>2; int k = X[i]%4; as[n][k]--; // printf("%d . sayinin %d . bit ikilisi\n", n, k); } as[63][3]+=4; } else for(int i=0; i<L; i++) { // if(X[i]==255) ctr++; //63 3 // printf("kod %d\n", X[i]); int n = X[i]; n = n>>2; int k = X[i]%4; as[n][k]++; // printf("%d . sayinin %d . bit ikilisi\n", n, k); } for(int i=0; i<N; i++) { int msg = 0; for(int j=0; j<4; j++) msg+= as[i][j]*pow(2,2*j); output(msg); // printf("%d\n", msg); } //int i, b; }
#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...