結果

問題 No.2702 Nand Nor Matrix
ユーザー 👑 kmjpkmjp
提出日時 2024-03-30 00:00:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 378 ms / 2,000 ms
コード長 1,484 bytes
コンパイル時間 2,218 ms
コンパイル使用メモリ 204,332 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-30 00:00:49
合計ジャッジ時間 20,839 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 297 ms
6,548 KB
testcase_02 AC 301 ms
6,548 KB
testcase_03 AC 296 ms
6,548 KB
testcase_04 AC 301 ms
6,548 KB
testcase_05 AC 301 ms
6,548 KB
testcase_06 AC 325 ms
6,548 KB
testcase_07 AC 296 ms
6,548 KB
testcase_08 AC 297 ms
6,548 KB
testcase_09 AC 299 ms
6,548 KB
testcase_10 AC 325 ms
6,548 KB
testcase_11 AC 299 ms
6,548 KB
testcase_12 AC 296 ms
6,548 KB
testcase_13 AC 322 ms
6,548 KB
testcase_14 AC 296 ms
6,548 KB
testcase_15 AC 295 ms
6,548 KB
testcase_16 AC 233 ms
6,548 KB
testcase_17 AC 71 ms
6,548 KB
testcase_18 AC 207 ms
6,548 KB
testcase_19 AC 324 ms
6,548 KB
testcase_20 AC 74 ms
6,548 KB
testcase_21 AC 140 ms
6,548 KB
testcase_22 AC 102 ms
6,548 KB
testcase_23 AC 303 ms
6,548 KB
testcase_24 AC 220 ms
6,548 KB
testcase_25 AC 113 ms
6,548 KB
testcase_26 AC 148 ms
6,548 KB
testcase_27 AC 329 ms
6,548 KB
testcase_28 AC 269 ms
6,548 KB
testcase_29 AC 26 ms
6,548 KB
testcase_30 AC 301 ms
6,548 KB
testcase_31 AC 306 ms
6,548 KB
testcase_32 AC 13 ms
6,548 KB
testcase_33 AC 53 ms
6,548 KB
testcase_34 AC 264 ms
6,548 KB
testcase_35 AC 295 ms
6,548 KB
testcase_36 AC 351 ms
6,548 KB
testcase_37 AC 351 ms
6,548 KB
testcase_38 AC 378 ms
6,548 KB
testcase_39 AC 350 ms
6,548 KB
testcase_40 AC 345 ms
6,548 KB
testcase_41 AC 372 ms
6,548 KB
testcase_42 AC 347 ms
6,548 KB
testcase_43 AC 346 ms
6,548 KB
testcase_44 AC 375 ms
6,548 KB
testcase_45 AC 351 ms
6,548 KB
testcase_46 AC 350 ms
6,548 KB
testcase_47 AC 351 ms
6,548 KB
testcase_48 AC 346 ms
6,548 KB
testcase_49 AC 346 ms
6,548 KB
testcase_50 AC 347 ms
6,548 KB
testcase_51 AC 319 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,Q;
int A[202020],B[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N-1) cin>>B[i+1];
	int miC=N;
	int miR=N;
	for(i=N-1;i>=2;i--) {
		if(A[i-1]==A[i]) miC=i;
		if(B[i-1]==B[i]) miR=i;
	}
	int d=0;
	if(A[1]==0&&B[1]==0) {
		d++;
		FOR(i,N) A[i]^=1, B[i]^=1;
		
	}
	
	
	cin>>Q;
	while(Q--) {
		ll T,R,C;
		cin>>T>>R>>C;
		R--,C--;
		if(R==0) {
			cout<<(d^A[C])<<endl;
		}
		else if(C==0) {
			cout<<(d^B[R])<<endl;
		}
		else {
			if(A[1]!=B[1]||T==0) {
				cout<<T%2<<endl;
			}
			else {
				T-=d;
				if(R<miR&&C<miC&&R+C-1<=T) {
					cout<<(((R+C)%2)^d)<<endl;
				}
				else {
					cout<<((T%2)^d)<<endl;
				}
			}
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0