結果

問題 No.2702 Nand Nor Matrix
ユーザー shobonvipshobonvip
提出日時 2024-03-29 23:06:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 2,266 bytes
コンパイル時間 4,133 ms
コンパイル使用メモリ 263,040 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-29 23:06:52
合計ジャッジ時間 11,969 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 51 ms
6,676 KB
testcase_02 AC 49 ms
6,676 KB
testcase_03 AC 50 ms
6,676 KB
testcase_04 AC 55 ms
6,676 KB
testcase_05 AC 55 ms
6,676 KB
testcase_06 AC 52 ms
6,676 KB
testcase_07 AC 53 ms
6,676 KB
testcase_08 AC 52 ms
6,676 KB
testcase_09 AC 53 ms
6,676 KB
testcase_10 AC 55 ms
6,676 KB
testcase_11 AC 53 ms
6,676 KB
testcase_12 AC 52 ms
6,676 KB
testcase_13 AC 54 ms
6,676 KB
testcase_14 AC 51 ms
6,676 KB
testcase_15 AC 50 ms
6,676 KB
testcase_16 AC 66 ms
6,676 KB
testcase_17 AC 34 ms
6,676 KB
testcase_18 AC 51 ms
6,676 KB
testcase_19 AC 84 ms
6,676 KB
testcase_20 AC 33 ms
6,676 KB
testcase_21 AC 40 ms
6,676 KB
testcase_22 AC 30 ms
6,676 KB
testcase_23 AC 73 ms
6,676 KB
testcase_24 AC 66 ms
6,676 KB
testcase_25 AC 34 ms
6,676 KB
testcase_26 AC 44 ms
6,676 KB
testcase_27 AC 95 ms
6,676 KB
testcase_28 AC 70 ms
6,676 KB
testcase_29 AC 15 ms
6,676 KB
testcase_30 AC 91 ms
6,676 KB
testcase_31 AC 72 ms
6,676 KB
testcase_32 AC 9 ms
6,676 KB
testcase_33 AC 27 ms
6,676 KB
testcase_34 AC 69 ms
6,676 KB
testcase_35 AC 79 ms
6,676 KB
testcase_36 AC 105 ms
6,676 KB
testcase_37 AC 103 ms
6,676 KB
testcase_38 AC 102 ms
6,676 KB
testcase_39 AC 109 ms
6,676 KB
testcase_40 AC 103 ms
6,676 KB
testcase_41 AC 104 ms
6,676 KB
testcase_42 AC 101 ms
6,676 KB
testcase_43 AC 103 ms
6,676 KB
testcase_44 AC 104 ms
6,676 KB
testcase_45 AC 103 ms
6,676 KB
testcase_46 AC 103 ms
6,676 KB
testcase_47 AC 103 ms
6,676 KB
testcase_48 AC 102 ms
6,676 KB
testcase_49 AC 103 ms
6,676 KB
testcase_50 AC 101 ms
6,676 KB
testcase_51 AC 66 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;

	vector<int> a(n);
	rep(i,0,n) cin >> a[i];

	vector<int> b(n);
	rep(i,0,n-1) cin >> b[i+1];

	if (n == 1){
		int q; cin >> q;
		while(q--){
			ll t, r, c; cin >> t >> r >> c;
			cout << a[0] << '\n';
		}
		return 0;
	}

	int rgt = 0;
	int dwn = 0;

	if (a[1] == b[1]){
		rgt = 1;
		dwn = 1;
		rep(i,2,n){
			if (i % 2 == 1){
				if (a[i] != a[1]){
					break;
				}
				rgt = i;
			}else{
				if (a[i] == a[1]){
					break;
				}
				rgt = i;
			}
		}
		rep(i,2,n){
			if (i % 2 == 1){
				if (b[i] != b[1]){
					break;
				}
				dwn = i;
			}else{
				if (b[i] == b[1]){
					break;
				}
				dwn = i;
			}
		}
	}

	//cout << rgt << ' ' << dwn << endl;


	int q; cin >> q;
	while(q--){
		ll t, r, c; cin >> t >> r >> c;
		r--;
		c--;
		if (r == 0){
			cout << a[c] << '\n';
		}else if (c == 0){
			cout << b[r] << '\n';
		}else if (c <= rgt && r <= dwn){
			if (a[1] == 1){
				if (r + c - 1 <= t){
					cout << (r + c) % 2 << '\n';
				}else{
					cout << t % 2 << '\n';
				}
			}else{
				if (r + c <= t){
					cout << (r + c + 1) % 2 << '\n';
				}else{
					cout << t % 2 << '\n';
				}
			}
		}else{
			cout << t % 2 << '\n';
		}
	}

}

0