結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー kabipoyokabipoyo
提出日時 2023-05-19 22:34:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 2,254 bytes
コンパイル時間 4,680 ms
コンパイル使用メモリ 264,724 KB
実行使用メモリ 18,784 KB
最終ジャッジ日時 2023-08-23 00:28:18
合計ジャッジ時間 18,618 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 280 ms
7,760 KB
testcase_02 AC 322 ms
10,988 KB
testcase_03 AC 300 ms
11,340 KB
testcase_04 AC 295 ms
11,524 KB
testcase_05 AC 305 ms
12,408 KB
testcase_06 AC 313 ms
15,404 KB
testcase_07 AC 316 ms
14,212 KB
testcase_08 AC 323 ms
16,212 KB
testcase_09 AC 322 ms
16,152 KB
testcase_10 AC 302 ms
11,240 KB
testcase_11 AC 319 ms
10,904 KB
testcase_12 AC 323 ms
10,948 KB
testcase_13 AC 320 ms
10,980 KB
testcase_14 AC 323 ms
10,904 KB
testcase_15 AC 321 ms
10,980 KB
testcase_16 AC 323 ms
10,976 KB
testcase_17 AC 319 ms
11,012 KB
testcase_18 AC 317 ms
11,008 KB
testcase_19 AC 324 ms
11,012 KB
testcase_20 AC 325 ms
10,936 KB
testcase_21 AC 351 ms
18,624 KB
testcase_22 AC 351 ms
18,696 KB
testcase_23 AC 348 ms
18,536 KB
testcase_24 AC 354 ms
18,616 KB
testcase_25 AC 357 ms
18,604 KB
testcase_26 AC 352 ms
18,664 KB
testcase_27 AC 352 ms
18,612 KB
testcase_28 AC 351 ms
18,624 KB
testcase_29 AC 350 ms
18,628 KB
testcase_30 AC 354 ms
18,756 KB
testcase_31 AC 242 ms
18,628 KB
testcase_32 AC 244 ms
18,624 KB
testcase_33 AC 243 ms
18,784 KB
testcase_34 AC 259 ms
18,708 KB
testcase_35 AC 257 ms
18,672 KB
testcase_36 AC 258 ms
18,612 KB
testcase_37 AC 25 ms
4,376 KB
testcase_38 AC 314 ms
10,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int main() {
	lint T;
	cin >> T;

	rep(_, T) {
		lint N;
		cin >> N;
		vector<string> v(N), w(N-1);
		vi Q(N-1);
		vin(v);
		vin(w);
		vin(Q);

		lint a=0, b=0, c=0, x, y, z;
		fenwick_tree<lint> fw(N);
		rep(i, N) fw.add(i, 1);
		rep(i, N-1) {
			lint ng = -1, mid, ok = N-2;
			while (abs(ok - ng) > 1) {
				mid = (ok + ng) / 2;
				x = fw.sum(0, mid+1);
				if (x >= Q[i]) ok = mid;
				else ng = mid;
			}
			z = ok;
			ng = -1, mid, ok = N-1;
			while (abs(ok - ng) > 1) {
				mid = (ok + ng) / 2;
				x = fw.sum(0, mid+1);
				if (x >= Q[i]+1) ok = mid;
				else ng = mid;
			}
			Q[i] = z;
			if (w[Q[i]] == "and") {
				if (v[Q[i]] == "False" || v[ok] == "False") {
					v[Q[i]] = "False";
					v[ok] = "False";
				} else {
					v[Q[i]] = "True";
					v[ok] = "True";
				}
			} else if (w[Q[i]] == "or") {
				if (v[Q[i]] == "True" || v[ok] == "True") {
					v[Q[i]] = "True";
					v[ok] = "True";
				} else {
					v[Q[i]] = "False";
					v[ok] = "False";
				}
			} else if (w[Q[i]] == "xor") {
				if (v[Q[i]] != v[ok]) {
					v[Q[i]] = "True";
					v[ok] = "True";
				} else {
					v[Q[i]] = "False";
					v[ok] = "False";
				}
			} else if (w[Q[i]] == "imp") {
				if (v[Q[i]] == "True") {
					v[Q[i]] = v[ok];
				} else {
					v[Q[i]] = "True";
					v[ok] = "True";
				}
			}
			fw.add(Q[i], -1);
		}
		cout << v[Q[N-2]] << endl;
	}
}
0