結果
| 問題 | No.1225 I hate I hate Matrix Construction | 
| コンテスト | |
| ユーザー |  tkmst201 | 
| 提出日時 | 2020-09-11 21:37:22 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 1,278 bytes | 
| コンパイル時間 | 1,894 ms | 
| コンパイル使用メモリ | 198,536 KB | 
| 最終ジャッジ日時 | 2025-01-14 10:11:33 | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         REP(i, N) scanf("%d", &S[i]);
      |                   ~~~~~^~~~~~~~~~~~~
main.cpp:24:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         REP(i, N) scanf("%d", &T[i]);
      |                   ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#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 || !tate) {
		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;
}
            
            
            
        