結果
問題 | No.387 ハンコ |
ユーザー |
![]() |
提出日時 | 2016-06-23 01:57:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 819 ms / 5,000 ms |
コード長 | 2,180 bytes |
コンパイル時間 | 1,739 ms |
コンパイル使用メモリ | 175,884 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 19:49:00 |
合計ジャッジ時間 | 9,342 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 |
ソースコード
#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!#endiftemplate<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;}