Submission #345761

#TimeUsernameProblemLanguageResultExecution timeMemory
345761Kevin_Zhang_TWParrots (IOI11_parrots)C++17
88 / 100
10 ms1528 KiB
#include "encoder.h"
#include "encoderlib.h"

#ifndef MINC
#define MINC

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif

#endif

// send(int b)
void encode(int N, int M[]) {
	static const int MAX_N = 256;
	static int cnt[MAX_N];
	const int K = N * 10;

	if (N > 32) {
		int b = 0;
		for (int i = 0;i < N;++i) {
			//DE(M[i]);
			for (int j = 0;j < 8;j += 2) {
				cnt[b++] = (M[i]>>j)&0b11;
				//DE(cnt[b-1]);
			}

		}
		int res = 0;
		for (int i = 0;i < b;++i) {
			for (int j = 0;j < cnt[i];++j)
				send(i);
			cnt[i] = 0;
		}
	}
	else {
		int b = 0;
		for (int i = 0;i < N;++i) {
			//DE(M[i]);
			for (int j = 0;j < 8;++j) {
				cnt[b++] = (M[i]>>j)&1;
				//DE(cnt[b-1]);
			}

		}
		int res = 0;
		for (int i = 0;i < b;++i) {
			for (int j = 0;j < cnt[i];++j)
				send(i);
			cnt[i] = 0;
		}
	}
}
#include "decoder.h"
#include "decoderlib.h"

#ifndef MINC
#define MINC

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif


#endif
// output(int b)
void decode(int N, int L, int X[]) {
	static const int MAX_N = 256;
	static int cnt[MAX_N];

	for (int i = 0;i < L;++i)
		++cnt[X[i]];

	//DE(N, L);
	if (N > 32) {
		int b = 0;
		for (int i = 0;i < N;++i) {
			int res = 0;
			for (int j = 0;j < 8;j += 2)
				res |= cnt[b++] << j;
			//DE(res);
			output(res);
			//output(res ^ ((1<<8)-1));
		}
		for (int i = 0;i < L;++i) cnt[X[i]] = 0;
	}
	else {
		int b = 0;
		for (int i = 0;i < N;++i) {
			int res = 0;
			for (int j = 0;j < 8;++j)
				res |= cnt[b++] << j;
			//DE(res);
			output(res);
			//output(res ^ ((1<<8)-1));
		}
		for (int i = 0;i < L;++i) cnt[X[i]] = 0;
	}
}

Compilation message (stderr)

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:42:7: warning: unused variable 'res' [-Wunused-variable]
   42 |   int res = 0;
      |       ^~~
encoder.cpp:59:7: warning: unused variable 'res' [-Wunused-variable]
   59 |   int res = 0;
      |       ^~~
encoder.cpp:30:12: warning: unused variable 'K' [-Wunused-variable]
   30 |  const int K = N * 10;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...