Submission #43733

# Submission time Handle Problem Language Result Execution time Memory
43733 2018-03-21T18:57:31 Z baactree Parrots (IOI11_parrots) C++14
88 / 100
14 ms 2528 KB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int N, int M[]){
	if (N <= 32) {
		for (int i = 0; i < N; i++) {
			int a = M[i] >> 4;
			int b = M[i] & (0xf);
			send(((i * 2) << 2) + (a >> 2));
			send(((i * 2) << 2) + (a >> 2));
			send(((i * 2) << 2) + (a & 3));
			send(((i * 2 + 1) << 2) + (b >> 2));
			send(((i * 2 + 1) << 2) + (b >> 2));
			send(((i * 2 + 1) << 2) + (b & 3));
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 4; j++) {
				int now = M[i] & 3;
				for (int k = 0; k < now; k++)
					send((i << 2) + j);
				M[i] /= 4;
			}
		}
	}
}
#include "decoder.h"
#include "decoderlib.h"
void decode(int N, int L, int X[]){
	if (N <= 32) {
		int ans[32] = { 0, }, cnt[64][4] = { 0, };
		for (int i = 0; i < L; i++) 
			cnt[X[i] >> 2][X[i] & 3]++;
		for (int i = 0; i < 64; i++) {
			for (int j = 0; j < 4; j++) {
				if (cnt[i][j] == 1) {
					ans[i / 2] |= i & 1 ? j : j << 4;
				}
				else if (cnt[i][j] == 2) {
					ans[i / 2] |= i & 1 ? j << 2 : j << 6;
				}
				else if (cnt[i][j] == 3) {
					ans[i / 2] |= i & 1 ? (j * 4 + j) : (j * 4 + j) << 4;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			output(ans[i]);
		}
	}
	else {
		int ans[64] = { 0, }, cnt[64][4] = { 0, };
		for (int i = 0; i < L; i++)
			cnt[X[i] >> 2][X[i] & 3]++;
		for (int i = 0; i < 64; i++) {
			for (int j = 0; j < 4; j++) {
				ans[i] |= (cnt[i][j] << (j * 2));
			}
		}
		for (int i = 0; i < N; i++) {
			output(ans[i]);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2000 KB Output is correct
2 Correct 5 ms 2024 KB Output is correct
3 Correct 7 ms 2064 KB Output is correct
4 Correct 6 ms 2064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2088 KB Output is correct
2 Correct 5 ms 2440 KB Output is correct
3 Correct 5 ms 2440 KB Output is correct
4 Correct 6 ms 2440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2440 KB Output is correct
2 Correct 7 ms 2440 KB Output is correct
3 Correct 6 ms 2440 KB Output is correct
4 Correct 7 ms 2440 KB Output is correct
5 Correct 8 ms 2440 KB Output is correct
6 Correct 8 ms 2440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 7 ms 2440 KB Output is partially correct - P = 6.000000
2 Partially correct 8 ms 2440 KB Output is partially correct - P = 6.000000
3 Partially correct 8 ms 2440 KB Output is partially correct - P = 12.000000
4 Partially correct 10 ms 2520 KB Output is partially correct - P = 12.000000
5 Partially correct 14 ms 2528 KB Output is partially correct - P = 12.000000
6 Partially correct 13 ms 2528 KB Output is partially correct - P = 12.000000
7 Partially correct 13 ms 2528 KB Output is partially correct - P = 12.000000