結果

問題 No.1225 I hate I hate Matrix Construction
コンテスト
ユーザー Haa
提出日時 2020-09-11 21:40:06
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 799 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,235 ms
コンパイル使用メモリ 185,540 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-01 23:34:52
合計ジャッジ時間 2,746 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	int n; cin >> n;
	VI s(n), t(n);
	REP(i,n) cin >> s[i];
	REP(i,n) cin >> t[i];
	VVI a(n,VI(n,0));
	REP(i,n){
		if(s[i]==2){
			REP(j,n)
				a[i][j]=1;
		}
	}
	REP(i,n){
		if(t[i]==2){
			REP(j,n)
				a[j][i]=1;
		}
	}
	int x=0, y=0;
	REP(i,n){
		if(s[i]==1){
			bool no=1;
			REP(j,n){
				if(a[i][j])
					no=0;
			}
			x+=no;
		}
	}
	REP(i,n){
		if(t[i]==1){
			bool no=1;
			REP(j,n){
				if(a[j][i])
					no=0;
			}
			y+=no;
		}
	}
	int ans=max(x,y);
	REP(i,n)REP(j,n)
		ans+=a[i][j];
	cout << ans << endl;
	return 0;
}
0