답안 #13487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13487 2015-02-22T01:47:31 Z tncks0121 앵무새 (IOI11_parrots) C++14
98 / 100
12 ms 2432 KB
#include "encoder.h"
#include "encoderlib.h"
 
int count[1000];
 
void encode (int N, int M[]) { // 6N approach
    int c1 = 0, c0 = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 4; j++) {
            count[i*4+j] = !!(M[i] & 1<<(j*2+1))*2 + !!(M[i] & 1<<(j*2));
            c1 += count[i*4+j];
        }
    }
    c0 = N * 4 * 3 - c1;
     
    if(c1 < c0) {
        for(int i = 0; i < N * 4; i++)
            while(count[i]--) send(i);
    }else {
        send(0); send(0); send(0); send(0);
        for(int i = 0; i < N * 4; i++) {
            count[i] = 3 - count[i];
            while(count[i]--) send(i);
        }
    }
}
#include "decoder.h"
#include "decoderlib.h"
 
int count[1000];
 
void decode (int N, int L, int X[]) {
    int i, j;
 
    bool isc0 = false;
    for(i = 0; i < N * 4; i++) count[i] = 0;
    for(i = 0; i < L; i++) {
        ++count[X[i]];
        if(count[0] == 4) isc0 = true;
    }
 
    if(isc0) {
        count[0] -= 4;
        for(i = 0; i < N * 4; i++) count[i] = 3 - count[i];
    }
 
    for(i = 0; i < N; i++) {
        int ret = 0;
        for(j = 0; j < 4; j++) {
            ret |= count[i * 4 + j] << (2 * j);
        }
 
        output(ret);
    }
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1592 KB Output is correct
2 Correct 4 ms 1592 KB Output is correct
3 Correct 5 ms 1624 KB Output is correct
4 Correct 5 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1880 KB Output is correct
2 Correct 5 ms 2192 KB Output is correct
3 Correct 6 ms 2352 KB Output is correct
4 Correct 7 ms 2352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2352 KB Output is correct
2 Correct 6 ms 2352 KB Output is correct
3 Correct 5 ms 2352 KB Output is correct
4 Correct 8 ms 2352 KB Output is correct
5 Correct 7 ms 2432 KB Output is correct
6 Correct 8 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 5 ms 2432 KB Output is partially correct - P = 6.250000
2 Partially correct 8 ms 2432 KB Output is partially correct - P = 6.093750
3 Partially correct 7 ms 2432 KB Output is partially correct - P = 6.121212
4 Partially correct 9 ms 2432 KB Output is partially correct - P = 6.080000
5 Partially correct 11 ms 2432 KB Output is partially correct - P = 6.066667
6 Partially correct 12 ms 2432 KB Output is partially correct - P = 6.047619
7 Partially correct 12 ms 2432 KB Output is partially correct - P = 6.062500