| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 29255 | Nikefor | 앵무새 (IOI11_parrots) | C++98 | 0 ms | 0 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
        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> (6*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]*1<<(2*j);
        output(msg);
//    printf("%d\n", msg);
    }
    //int i, b;
}
