結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー tkmst201tkmst201
提出日時 2020-09-11 21:35:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,244 bytes
コンパイル時間 1,822 ms
コンパイル使用メモリ 172,968 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-27 05:39:05
合計ジャッジ時間 2,994 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	vector<int> S(N), T(N);
	REP(i, N) scanf("%d", &S[i]);
	REP(i, N) scanf("%d", &T[i]);
	
	vector<vector<int>> ans(N, vector<int>(N));
	bool yoko = false, tate = false;
	REP(i, N) {
		if (S[i] == 2) { REP(j, N) ans[i][j] = 1; yoko = true; }
		if (T[i] == 2) { REP(j, N) ans[j][i] = 1; tate = true; }
	}
	
	int ansc = 0;
	if (yoko) { REP(i, N) if (S[i] == 1) ++ansc; }
	else if (tate) { REP(i, N) if (T[i] == 1) ++ansc; }
	else {
		int a[2] {};
		REP(i, N) a[0] += S[i] == 1;
		REP(i, N) a[1] += T[i] == 1;
		ansc = max(a[0], a[1]);
	}
	
	REP(i, N) REP(j, N) ansc += ans[i][j];
	cout << ansc << endl;
	return 0;
}
0