結果

問題 No.387 ハンコ
ユーザー antaanta
提出日時 2016-06-23 01:57:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,039 ms / 5,000 ms
コード長 2,180 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 173,812 KB
実行使用メモリ 4,660 KB
最終ジャッジ日時 2023-08-02 00:07:24
合計ジャッジ時間 11,230 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,038 ms
4,660 KB
testcase_01 AC 1,039 ms
4,568 KB
testcase_02 AC 767 ms
4,508 KB
testcase_03 AC 775 ms
4,560 KB
testcase_04 AC 339 ms
4,376 KB
testcase_05 AC 660 ms
4,380 KB
testcase_06 AC 881 ms
4,416 KB
testcase_07 AC 799 ms
4,620 KB
testcase_08 AC 817 ms
4,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

#ifdef NDEBUG
#error assert is disabled!
#endif

template<typename T>
T readNatural(T lo, T up) {
	assert(0 <= lo && lo <= up);
	T x = 0;
	while(1) {
		int d = getchar();
		if(!('0' <= d && d <= '9')) {
			ungetc(d, stdin);
			break;
		}
		d -= '0';
		assert(d <= up && x <= (up - d) / 10);
		x = x * 10 + d;
	}
	assert(lo <= x && x <= up);
	return x;
}

void readSpace() { int c = getchar(); assert(c == ' '); }
static bool read_eof = false;
void readEOL() {
	int c = getchar();
	if(c == EOF) {
		assert(!read_eof);
		read_eof = true;
	} else {
		assert(c == '\n');
	}
}
void readEOF() {
	assert(!read_eof);
	int c = getchar();
	assert(c == EOF);
	read_eof = true;
}
unsigned xor128() {
	static unsigned x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned t = x ^ (x << 11);
	x = y; y = z; z = w;
	return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
}
int main() {
	int N = readNatural(1, 100000); readEOL();
	vector<int> a(N);
	rep(i, N) {
		a[i] = readNatural(1, 100000);
		if(i != N - 1) readSpace();
		else readEOL();
	}
	vector<int> b(N);
	rep(i, N) {
		b[i] = readNatural(0, 1);
		if(i != N - 1) readSpace();
		else readEOL();
	}
	readEOF();
	typedef bitset<200000> Bitset;
	Bitset B;
	rep(i, N) if(b[i] == 1)
		B.set(i);
	vector<pair<int,int>> ais(N);
	rep(i, N)
		ais[i] = make_pair(a[i], i);
	sort(ais.begin(), ais.end());
	Bitset C;
	for(int i = 0; i < N; ) {
		int j = i;
		Bitset A;
		for(; j < N && ais[j].first == ais[i].first; ++ j) {
			int shift = ais[j].second;
			A |= B << shift;
		}
		C ^= A;
		i = j;
	}
	rep(i, N * 2 - 1)
		puts(C[i] ? "ODD" : "EVEN");
	return 0;
}
0