답안 #18402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18402 2016-01-31T07:53:03 Z suhgyuho_william 앵무새 (IOI11_parrots) C++
88 / 100
15 ms 2432 KB
#include "encoder.h"
#include "encoderlib.h"

void encode(int N, int M[]){
	int i,j,tt;
	int tmp[100];
	int a[100];

	if(N <= 32){
	for(i=0; i<N; i++) tmp[i] = M[i];
	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);
			}
		}
	}
}
#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]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1592 KB Output is correct
2 Correct 6 ms 1592 KB Output is correct
3 Correct 5 ms 1624 KB Output is correct
4 Correct 7 ms 1816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1928 KB Output is correct
2 Correct 4 ms 2144 KB Output is correct
3 Correct 5 ms 2144 KB Output is correct
4 Correct 5 ms 2144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2184 KB Output is correct
2 Correct 6 ms 2184 KB Output is correct
3 Correct 5 ms 2184 KB Output is correct
4 Correct 5 ms 2184 KB Output is correct
5 Correct 7 ms 2184 KB Output is correct
6 Correct 9 ms 2184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 6 ms 2184 KB Output is partially correct - P = 8.000000
2 Partially correct 7 ms 2184 KB Output is partially correct - P = 8.000000
3 Partially correct 8 ms 2184 KB Output is partially correct - P = 12.000000
4 Partially correct 15 ms 2184 KB Output is partially correct - P = 12.000000
5 Partially correct 13 ms 2432 KB Output is partially correct - P = 12.000000
6 Partially correct 14 ms 2432 KB Output is partially correct - P = 12.000000
7 Partially correct 14 ms 2432 KB Output is partially correct - P = 12.000000