結果
| 問題 | No.1225 I hate I hate Matrix Construction | 
| コンテスト | |
| ユーザー |  hamap000 | 
| 提出日時 | 2020-09-11 21:38:58 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 859 bytes | 
| コンパイル時間 | 2,184 ms | 
| コンパイル使用メモリ | 171,448 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-27 07:29:29 | 
| 合計ジャッジ時間 | 2,805 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  ll N;
  cin >> N;
  vector<int> S(N), T(N);
  REP(i, N) cin >> S[i];
  REP(i, N) cin >> T[i];
  vector<vector<int>> Vec(N, vector<int>(N, 0));
  REP(i, N) {
    if (S[i] == 2) {
      REP(j, N) Vec[i][j] = 1;
    }
    if (T[i] == 2) {
      REP(j, N) Vec[j][i] = 1;
    }
  }
  int _s = 0, _t = 0;
  REP(i, N) {
    if (S[i] == 1) {
      bool b = false;
      REP(j, N) if (Vec[i][j] == 1) b = true;
      if (!b) _s++;
    }
    if (T[i] == 1) {
      bool b = false;
      REP(j, N) if (Vec[j][i] == 1) b = true;
      if (!b) _t++;
    }
  }
  int sum = 0;
  REP(i, N) REP(j, N) if (Vec[i][j] == 1) sum++;
  cout << sum + max(_s, _t) << endl;
}
            
            
            
        