結果

問題 No.2702 Nand Nor Matrix
ユーザー binapbinap
提出日時 2024-03-29 23:09:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,197 bytes
コンパイル時間 4,559 ms
コンパイル使用メモリ 263,084 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-29 23:10:24
合計ジャッジ時間 30,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 388 ms
6,676 KB
testcase_02 AC 379 ms
6,676 KB
testcase_03 AC 388 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 397 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 391 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 388 ms
6,676 KB
testcase_14 WA -
testcase_15 AC 387 ms
6,676 KB
testcase_16 AC 379 ms
6,676 KB
testcase_17 AC 134 ms
6,676 KB
testcase_18 WA -
testcase_19 AC 517 ms
6,676 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 163 ms
6,676 KB
testcase_23 WA -
testcase_24 AC 342 ms
6,676 KB
testcase_25 AC 184 ms
6,676 KB
testcase_26 AC 242 ms
6,676 KB
testcase_27 AC 552 ms
6,676 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 500 ms
6,676 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 421 ms
6,676 KB
testcase_35 AC 462 ms
6,676 KB
testcase_36 AC 594 ms
6,676 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 597 ms
6,676 KB
testcase_40 WA -
testcase_41 AC 570 ms
6,676 KB
testcase_42 AC 575 ms
6,676 KB
testcase_43 AC 591 ms
6,676 KB
testcase_44 WA -
testcase_45 AC 602 ms
6,676 KB
testcase_46 WA -
testcase_47 AC 602 ms
6,676 KB
testcase_48 AC 568 ms
6,676 KB
testcase_49 AC 599 ms
6,676 KB
testcase_50 AC 564 ms
6,676 KB
testcase_51 AC 479 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef long double ld;
typedef pair<int, int> P;

ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;}
template <int m> ostream& operator<<(ostream& os, const static_modint<m>& a) {os << a.val(); return os;}
template <int m> ostream& operator<<(ostream& os, const dynamic_modint<m>& a) {os << a.val(); return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;}
template<typename U, typename T> ostream& operator<<(ostream& os, const pair<U, T>& p){os << p.first << ' ' << p.second; return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;}

template<typename T> void chmin(T& a, T b){a = min(a, b);}
template<typename T> void chmax(T& a, T b){a = max(a, b);}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> b(n);
	rep(i, n - 1) cin >> b[i + 1];
	rep(i, n) if(i % 2) a[i] ^= 1;
	rep(i, n) if(i % 2) b[i] ^= 1;
	int h = 0, w = 0;
	for(int x = 1; x < n; x++){
		if(a[x] == 0) w++;
		else break;
	}
	for(int y = 1; y < n; y++){
		if(b[y] == 0) h++;
		else break;
	}
	int q;
	cin >> q;
	auto f = [&](int y, int x, long long flag){
		if((y + x) % 2) return flag ^ 1;
		else return flag;
	};
	rep(_, q){
		long long t;
		int y, x;
		cin >> t >> y >> x;
		y--; x--;
		if(y == 0){
			cout << f(y, x, a[x]) << "\n";
			continue;
		}
		if(x == 0){
			cout << f(y, x, b[y]) << "\n";
			continue;
		}
		long long flag = 0;
		if((y + x - 2) <= t and y <= h and x <= w){
//			cout << y << ' ' << x << ' ' << t << "\n";
			flag = f(y, x, 0);
		}else{
			flag = t % 2;
		}
		cout << flag <<"\n";
	}
	return 0;
}
0