結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー shobonvipshobonvip
提出日時 2023-05-19 21:52:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 1,735 bytes
コンパイル時間 4,457 ms
コンパイル使用メモリ 264,696 KB
実行使用メモリ 21,404 KB
最終ジャッジ日時 2023-09-17 03:10:28
合計ジャッジ時間 13,026 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 138 ms
8,364 KB
testcase_02 AC 153 ms
12,400 KB
testcase_03 AC 149 ms
12,412 KB
testcase_04 AC 143 ms
12,804 KB
testcase_05 AC 147 ms
13,400 KB
testcase_06 AC 163 ms
17,792 KB
testcase_07 AC 157 ms
17,304 KB
testcase_08 AC 159 ms
19,068 KB
testcase_09 AC 160 ms
19,048 KB
testcase_10 AC 153 ms
12,652 KB
testcase_11 AC 159 ms
12,288 KB
testcase_12 AC 154 ms
12,396 KB
testcase_13 AC 157 ms
12,316 KB
testcase_14 AC 156 ms
12,416 KB
testcase_15 AC 156 ms
12,260 KB
testcase_16 AC 153 ms
12,368 KB
testcase_17 AC 154 ms
12,352 KB
testcase_18 AC 155 ms
12,316 KB
testcase_19 AC 157 ms
12,280 KB
testcase_20 AC 157 ms
12,292 KB
testcase_21 AC 167 ms
21,268 KB
testcase_22 AC 167 ms
21,316 KB
testcase_23 AC 170 ms
21,248 KB
testcase_24 AC 170 ms
21,204 KB
testcase_25 AC 164 ms
21,240 KB
testcase_26 AC 172 ms
21,212 KB
testcase_27 AC 167 ms
21,276 KB
testcase_28 AC 169 ms
21,204 KB
testcase_29 AC 169 ms
21,404 KB
testcase_30 AC 171 ms
21,216 KB
testcase_31 AC 107 ms
21,280 KB
testcase_32 AC 110 ms
21,208 KB
testcase_33 AC 107 ms
21,228 KB
testcase_34 AC 118 ms
21,248 KB
testcase_35 AC 118 ms
21,288 KB
testcase_36 AC 119 ms
21,224 KB
testcase_37 AC 9 ms
4,376 KB
testcase_38 AC 153 ms
12,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef modint998244353 mint;
typedef long long ll;

// importbisect
template <typename T>
int bisect_left(vector<T> &X, T v){
	return lower_bound(X.begin(), X.end(), v) - X.begin();
}

template <typename T>
int bisect_right(vector<T> &X, T v){
	return upper_bound(X.begin(), X.end(), v) - X.begin();
}
// -----

int dat;
bool hantei(int x){
	return x < dat;
}

int op(int a, int b){
	return a + b;
}

int e(){
	return 0;
}

void solve(){
	int n; cin >> n;
	vector<string> x(n), y(n-1);
	vector<int> s(n);
	for (int i=0; i<n; i++){
		cin >> x[i];
	}
	for (int i=0; i<n-1; i++){
		cin >> y[i];
	}
	vector<bool> f(n);
	for (int i=0; i<n; i++){
		if (x[i] == "True") f[i] = true;
	}

	segtree<int,op,e> seg1(n);
	segtree<int,op,e> seg2(n-1);
	for (int i=0; i<n; i++){
		seg1.set(i, 1);
	}
	for (int i=0; i<n-1; i++){
		seg2.set(i, 1);
	}

	for (int i=0; i<n-1; i++){
		cin >> s[i];
		s[i]--;
		dat = s[i] + 1;
		int x1 = seg1.max_right<hantei>(0);
		int z = seg2.max_right<hantei>(0);
		dat++;
		int x2 = seg1.max_right<hantei>(0);
		if (y[z] == "and"){
			if (f[x1] && f[x2]) f[x1] = true;
			else f[x1] = false;
		}else if (y[z] == "or"){
			if (f[x1] || f[x2]) f[x1] = true;
			else f[x1] = false;
		}else if (y[z] == "xor"){
			if ((f[x1] && !f[x2]) || (!f[x1] && f[x2])) f[x1] = true;
			else f[x1] = false;
		}else{
			if (f[x1]){
				f[x1] = f[x2];
			}else{
				f[x1] = true;
			}
		}
		seg1.set(x2, 0);
		seg2.set(z, 0);
	}

	dat = 1;
	int x3 = seg1.max_right<hantei>(0);
	if (f[x3]) cout << "True\n";
	else cout << "False\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int t; cin >> t;
	while(t--) solve();
}
0