Submission #38325

# Submission time Handle Problem Language Result Execution time Memory
38325 2018-01-03T17:02:08 Z pce913 Parrots (IOI11_parrots) C++14
81 / 100
18 ms 2304 KB
#include "encoder.h"
#include "encoderlib.h"
#include<vector>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

int org[256][4];

void encode(int N, int M[])
{
	memset(org, 0, sizeof(org));
	for (int x = 0; x < N ; x++){
		int num = M[x];
		bool find = false;
		for (int i = 0; i < 256; i++){    // 1
			for (int j = 0; j < 64; j++){  //4
				for (int k = 0; k < 16; k++){  //16
					for (int l = 0; l < 4; l++){   //64
						if (i + 4 * j + 16 * k + 64 * l == num){
							org[num][0] = i, org[num][1] = j;
							org[num][2] = k, org[num][3] = l;
							find = true;
							break;
						}
					}
					if (find)break;
				}
				if (find)break;
			}
			if (find)break;
		}
	}

	vector<int> a;
	for (int x = 0; x < N; x++){
		int num = M[x];
		int in = x << 3;
		int n1 = org[num][0], n4 = org[num][1];
		int n16 = org[num][2], n64 = org[num][3];
		int min1_4 = min(n1, n4), max1_4 = max(n1, n4);
		int min16_64 = min(n16, n64), max16_64 = max(n16, n64);
		for (int i = 0; i < min1_4; i++)
			a.push_back(in + (1 << 1) + 1);
		for (int i = 0; i < max1_4 - min1_4; i++){
			if (max1_4 == n1)
				a.push_back(in + (1 << 1));
			else
				a.push_back(in + 1);
		}
		for (int i = 0; i < min16_64; i++)
			a.push_back(in + (1 << 2) + (1 << 1) + 1);
		for (int i = 0; i < max16_64 - min16_64; i++){
			if (max16_64 == n16)
				a.push_back(in + (1 << 2) + (1 << 1));
			else
				a.push_back(in + (1 << 2) + 1);
		}
			
	}
	
	for (int i = 0; i < a.size(); i++)  //인코딩 시킨 숫자
		send(a[i]);
}
#include "decoder.h"
#include "decoderlib.h"
#include<cstring>
#include<iostream>
using namespace std;
int ans[260];
void decode(int N, int L, int X[]){  //N:원래 메시지의 길이, L:전송된 메시지의 길이
	memset(ans, 0, sizeof(ans));
	for (int i = 0; i < L; i++){
		int ord = X[i] >> 3;
		int num = X[i] & 7;
		if (num&(1 << 2)){
			if (num&(1 << 1))
				ans[ord] += 16;
			if (num&(1 << 0)){
				ans[ord] += 64;
			}
		}
		else{
			if (num&(1 << 1))
				ans[ord] += 1;
			if (num&(1 << 0))
				ans[ord] += 4;
		}
	}
	for (int i = 0; i < N; i++)
		output(ans[i]);
}

Compilation message

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:63:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.size(); i++)  //인코딩 시킨 숫자
                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1752 KB Output is correct
2 Correct 6 ms 1784 KB Output is correct
3 Correct 7 ms 1904 KB Output is correct
4 Correct 9 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2168 KB Output is correct
2 Correct 7 ms 2304 KB Output is correct
3 Correct 7 ms 2304 KB Output is correct
4 Correct 10 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2304 KB Output is correct
2 Correct 7 ms 2304 KB Output is correct
3 Correct 8 ms 2304 KB Output is correct
4 Correct 13 ms 2304 KB Output is correct
5 Correct 15 ms 2304 KB Output is correct
6 Correct 18 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 7 ms 2304 KB Output is partially correct - P = 6.000000
2 Partially correct 16 ms 2304 KB Output is partially correct - P = 6.000000
3 Incorrect 4 ms 2304 KB Error : Bad encoded integer
4 Incorrect 4 ms 2304 KB Error : Bad encoded integer
5 Incorrect 5 ms 2304 KB Error : Bad encoded integer
6 Incorrect 5 ms 2304 KB Error : Bad encoded integer
7 Incorrect 5 ms 2304 KB Error : Bad encoded integer