제출 #246135

#제출 시각아이디문제언어결과실행 시간메모리
246135luisoncpp앵무새 (IOI11_parrots)C++17
81 / 100
15 ms1792 KiB
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>
#include <cstdlib>
#include <cassert>
#include <queue>
#include <unordered_map>
#define PARROTS
#ifndef PARROTS_MAIN
#include "encoder.h"
#include "encoderlib.h"
#endif

template<typename T>
using Vec = std::vector<T>;

Vec<int> SplitInto4Bit(int N, int* message) {
	Vec<int> ret;
	for (int i = 0; i < N; ++i) {
		ret.push_back(message[i]&15);
		ret.push_back(message[i]>>4);
	}
	return ret;
}

void encode(int N, int* message_8) {
	auto message = SplitInto4Bit(N, message_8);
	for (int i = 0; i < message.size(); ++i) {
		int index = (i&15);
		int times = (1 << (i / 16));
		while (times--) {
			send(message[i] | (index<<4));
		}
	}
}
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>
#include <cstdlib>
#include <cassert>
#include <queue>
#include <unordered_map>
#ifndef PARROTS_MAIN
#include "decoder.h"
#include "decoderlib.h"
#endif
#ifndef PARROTS
template<typename T>
using Vec = std::vector<T>;
#endif

void decode(int N, int L, int* X) {
	Vec<int> decoded_4_bit(2*N);
	std::unordered_map<int, int> Count;
	for (int i = 0; i < L; ++i) {
		++Count[X[i]];
	}
	for (int i = 0; i < L; ++i) {
		int index = (X[i] >> 4);
		int value = (X[i] & 15);
		if (Count[X[i]] & 1) {
			decoded_4_bit.at(index) = value;
		}
		if (Count[X[i]] & 2) {
			decoded_4_bit.at(index + 16) = value;
		}
		if (Count[X[i]] & 4) {
			decoded_4_bit.at(index + 32) = value;
		}
		if (Count[X[i]] & 8) {
			decoded_4_bit.at(index + 48) = value;
		}
	}
	for (int i = 0; i < 2*N; i += 2) {
		int num = (decoded_4_bit[i] | (decoded_4_bit[i + 1]<<4));
		output(num);
	}
}

컴파일 시 표준 에러 (stderr) 메시지

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < message.size(); ++i) {
                  ~~^~~~~~~~~~~~~~~~
#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...