Submission #3426986


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DEBUG(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

struct nd {
	long long v;
	nd(long long v = INF) :v(v) {} // ! e
};
struct SegmentTreeFastAry {
	nd merge(nd& l, nd& r) {
		nd ret;
		ret.v = min(l.v, r.v);
		return ret;
	}
	void updatepoint(nd& node, nd& nx) { // point update 
		node.v = nx.v;
	}
	// -- setting -- // 
	int ARY_SIZE; nd node[1 << 17]; // 131072
	void init(int n) { ARY_SIZE = 1; while (ARY_SIZE < n) ARY_SIZE <<= 1; }
	SegmentTreeFastAry(int n) : ARY_SIZE(1) { init(n); }
	inline void update(int i, nd& val) {
		i += ARY_SIZE; updatepoint(node[i], val);
		while (i > 1) { i >>= 1;	node[i] = merge(node[i << 1], node[(i << 1) + 1]); }
	}
	inline nd query(int l, int r) {
		if (l >= r) return nd(); nd vl = nd(), vr = nd();
		for (l += ARY_SIZE, r += ARY_SIZE; l != r; l >>= 1, r >>= 1) {
			if (l & 1) vl = merge(vl, node[l++]); if (r & 1) vr = merge(node[--r], vr);
		}	return merge(vl, vr);
	}
	nd operator[](int i) { return node[i + ARY_SIZE]; }
	void debugShow() { for (int i = ARY_SIZE; i < ARY_SIZE << 1; ++i) cerr << node[i].v << " "; cerr << "\n"; }
};
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL N; cin >> N;
	VL c(N), a(N);
	FOR(i, 1, N) {
		cin >> c[i] >> a[i];
	}
	nd mione(-1);
	nd zero(0);
	SegmentTreeFastAry seg(N + 10);
	// -- 
	FOR(i, 0, N + 5) {
		seg.update(i, mione);
	}
	seg.update(0, zero);
	// O(Nlog^2N)
	LL ans = 0;
	DEBUG(debug(seg.query(0, 1).v));
	FOR(i, 1, N) {
		int L = 0, R = N;// ここだった
		DEBUG(debug(i - c[i]));
		while (R - L > 1) {
			int mid = (L + R) / 2;
			LL minVal = seg.query(0, mid).v;
			if (minVal >= i - c[i]) {// i-c(i)≧0
				L = mid;
			}
			else {
				R = mid;
			}
		}
		DEBUG(debug(L, R, seg.query(0, 1).v, seg.query(1, 2).v, seg.query(2, 3).v, seg.query(3, 4).v));
		// update
		int G = L;
		if (a[i] & 1)ans ^= G;// add
		nd xx(i);
		seg.update(G, xx);
	}

	cout << (ans ? "First" : "Second") << "\n";

	return 0;
}

Submission Info

Submission Time
Task C - 茶碗と豆
User vjudge2
Language C++14 (GCC 5.4.1)
Score 100
Code Size 3005 Byte
Status RE
Exec Time 303 ms
Memory 2816 KB

Judge Result

Set Name Sample Dataset1 Dataset2 Dataset3
Score / Max Score 0 / 0 80 / 80 20 / 20 0 / 4
Status
AC × 3
AC × 13
AC × 21
AC × 21
RE × 8
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
Dataset1 sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
Dataset2 sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt
Dataset3 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 03-01.txt, 03-02.txt, 03-03.txt, 03-04.txt, 03-05.txt, 03-06.txt, 03-07.txt, 03-08.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt AC 2 ms 1280 KB
01-02.txt AC 2 ms 1280 KB
01-03.txt AC 2 ms 1280 KB
01-04.txt AC 2 ms 1280 KB
01-05.txt AC 2 ms 1280 KB
01-06.txt AC 2 ms 1280 KB
01-07.txt AC 2 ms 1280 KB
01-08.txt AC 2 ms 1280 KB
01-09.txt AC 2 ms 1280 KB
01-10.txt AC 1 ms 1280 KB
02-01.txt AC 1 ms 1280 KB
02-02.txt AC 1 ms 1280 KB
02-03.txt AC 2 ms 1280 KB
02-04.txt AC 2 ms 1280 KB
02-05.txt AC 2 ms 1280 KB
02-06.txt AC 1 ms 1280 KB
02-07.txt AC 2 ms 1280 KB
02-08.txt AC 2 ms 1280 KB
03-01.txt RE 303 ms 2816 KB
03-02.txt RE 114 ms 2816 KB
03-03.txt RE 114 ms 2816 KB
03-04.txt RE 114 ms 2816 KB
03-05.txt RE 115 ms 2816 KB
03-06.txt RE 115 ms 2816 KB
03-07.txt RE 109 ms 2816 KB
03-08.txt RE 109 ms 2816 KB
sample-01.txt AC 2 ms 1280 KB
sample-02.txt AC 1 ms 1280 KB
sample-03.txt AC 1 ms 1280 KB