Submission #66013

# Submission time Handle Problem Language Result Execution time Memory
66013 2018-08-09T11:12:55 Z llllilll Parrots (IOI11_parrots) C++14
81 / 100
15 ms 2536 KB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;

void encode(int N, int M[])
{
	int forward_cnt = 0, backward_cnt = 0;
	vector<int> forward, backward;
	for (int i = 0; i < N; i++) {
		int msg = 0;
		msg += (i << 2);

		int tmp = M[i];
		for (int j = 3; j >= 0; j--) {
			int cnt = tmp % 4;

			for (int k = 1; k <= cnt; k++) {
				forward.push_back(msg + j);
				forward_cnt++;
			}

			cnt ^= 3;
			for (int k = 1; k <= cnt; k++) {
				backward.push_back(msg + j);
				backward_cnt++;
			}
			tmp >>= 2;
		}
	}

	if (backward_cnt < forward_cnt) {
		for (int i = 0; i < backward_cnt; i++) send(backward[i]);
		for (int i = 0; i < 4; i++) send(255);
	}
	else {
		for (int i = 0; i < forward_cnt; i++) send(forward[i]);
	}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;

void decode(int N, int L, int X[])
{
	int origin[64];
	int back_cnt = 0;

	for (int i = 0; i < L; i++) {
		if (X[i] == 255) back_cnt++;
	}

	if (back_cnt >= 4) {
		for (int i = 0; i < N; i++) origin[i] = 255;
		for (int i = 0; i < L; i++) {
			if (back_cnt > 0 && X[i] == 255) {
				back_cnt--;
				continue;
			}
			int idx = X[i] >> 2;
			int idx_inner = X[i] % 4;

			origin[idx] -= 1 << (3 - idx_inner) * 2;
		}
	}
	else {
		for (int i = 0; i < N; i++) origin[i] = 0;
		for (int i = 0; i < L; i++) {
			int idx = X[i] >> 2;
			int idx_inner = X[i] % 4;

			origin[idx] += 1 << (3 - idx_inner) * 2;
		}
	}

	for (int i = 0; i < N; i++) {
		output(origin[i]);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1600 KB Output is correct
2 Correct 7 ms 2016 KB Output is correct
3 Correct 7 ms 2168 KB Output is correct
4 Correct 6 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2168 KB Output is correct
2 Correct 5 ms 2208 KB Output is correct
3 Correct 6 ms 2208 KB Output is correct
4 Correct 7 ms 2216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2224 KB Output is correct
2 Correct 7 ms 2232 KB Output is correct
3 Correct 7 ms 2232 KB Output is correct
4 Correct 8 ms 2240 KB Output is correct
5 Correct 8 ms 2240 KB Output is correct
6 Correct 10 ms 2240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 8 ms 2240 KB Output is partially correct - P = 6.187500
2 Partially correct 11 ms 2248 KB Output is partially correct - P = 6.093750
3 Partially correct 10 ms 2248 KB Output is partially correct - P = 6.090909
4 Partially correct 13 ms 2512 KB Output is partially correct - P = 6.020000
5 Partially correct 13 ms 2520 KB Output is partially correct - P = 6.033333
6 Partially correct 15 ms 2536 KB Output is partially correct - P = 6.047619
7 Incorrect 10 ms 2536 KB Error : Output is wrong