結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー mmn15277198mmn15277198
提出日時 2020-09-11 22:39:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,665 bytes
コンパイル時間 872 ms
コンパイル使用メモリ 96,072 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 15:37:23
合計ジャッジ時間 2,306 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

long long gcd(long long a,long long b){
	long long x=max(a,b),y=min(a,b);
	if(x%y==0)return y;
	else return gcd(y,x%y);
}

long long lcm(long long a,long long b){
	return (a/gcd(a,b))*b;
}

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//cout << fixed << setprecision(1) << endl;
	
	int n;
	cin >> n;
	vector<int> s(n);
	vector<int> t(n);
	for(int i = 0; i < n; i++)cin >> s[i];
	for(int i = 0; i < n; i++)cin >> t[i];
	
	vector<vector<int>> ans(n,vector<int>(n,0));
	
	int cnt = 0;
	
	//s
	for(int i = 0; i < n; i++){
		if(s[i] == 0){
			continue;
		}else if(s[i] == 2){
			for(int j = 0; j < n; j++){
				ans[i][j] = 1;
			}
		}else if(s[i] == 1){
			continue;
		}
	}		
	
	//t
	for(int i = 0; i < n; i++){
		if(t[i] == 0){
			for(int j = 0; j < n; j++){
				ans[j][i] = 0;
			}
		}else if(s[i] == 2){
			for(int j = 0; j < n;j++){
				ans[i][j] = 1;
			}
		}else if(s[i] == 1){
			continue;
		}
	}		
	
	for(int i = 0; i < n; i++){
		if(s[i] == 1 && t[i] == 1){
			ans[i][i] = 1;
		}else if(s[i] == 1){
			bool ok = false;
			for(int j = 0; j < n; j++){
				if(ans[i][j] == 1){
					ok = true;
				}
			}
			if(!ok){
				ans[i][0] = 1;
			}
		}else if(t[i] == 1){
			bool ok = false;
			for(int j = 0; j < n; j++){
				if(ans[j][i] == 1){
					ok = true;
				}
			}
			if(!ok){
				ans[0][i] = 1;
			}
		}
	}
	
	//cnt	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(ans[i][j] == 1)cnt++;
		}
	}	
	cout << cnt << endl;
	return 0;
}
 
0