結果

問題 No.1605 Matrix Shape
ユーザー aut_jul_duraut_jul_dur
提出日時 2021-07-16 22:17:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,335 bytes
コンパイル時間 4,362 ms
コンパイル使用メモリ 259,844 KB
実行使用メモリ 8,324 KB
最終ジャッジ日時 2023-09-20 14:27:53
合計ジャッジ時間 8,208 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,364 KB
testcase_01 WA -
testcase_02 AC 3 ms
6,608 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
6,496 KB
testcase_08 AC 3 ms
6,596 KB
testcase_09 AC 4 ms
6,344 KB
testcase_10 AC 4 ms
6,428 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 3 ms
6,364 KB
testcase_14 AC 3 ms
6,324 KB
testcase_15 AC 3 ms
6,440 KB
testcase_16 AC 4 ms
6,496 KB
testcase_17 AC 3 ms
6,608 KB
testcase_18 AC 3 ms
6,328 KB
testcase_19 WA -
testcase_20 AC 112 ms
6,360 KB
testcase_21 AC 113 ms
6,604 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 124 ms
6,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 77 ms
6,700 KB
testcase_28 AC 77 ms
6,480 KB
testcase_29 AC 77 ms
6,432 KB
testcase_30 WA -
testcase_31 AC 111 ms
6,360 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 96 ms
6,572 KB
testcase_36 AC 57 ms
6,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
using mint = modint1000000007;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(){
  ll N;
  cin>>N;
  ll H[200200] = {};
  ll W[200200] = {};
  vector<ll> aru;
  bool ddd = 0;
  rep(i,N){
    ll a,b;
    cin>>a>>b;
    if(a == b){
      aru.push_back(a);
      continue;
    }
    ddd = 1;
    H[a]++;
    W[b]++;
  }
  rep(i,aru.size()){
    if(H[aru[i]] == 0 && W[aru[i]] == 0){
      ddd = 0;
    }
  }
  if(!ddd){
    cout << 0 << endl;
    return 0;
  }
  ll tigau = 0;
  rep(i,200200){
    if(H[i] != W[i]){
      tigau++;
    }
  }
  if(tigau > 2){
    cout << 0 << endl;
  }
  else if(tigau == 0){
    ll ans = 0;
    ll kisuu = 0;
    rep(i,200200){
      if(H[i]>0){
        ans++;
        if(H[i]%2 == 1){
          kisuu++;
        }
      }
    }
    if(kisuu>0){
      cout << 1 << endl;
    }
    else{
      cout << ans << endl;
    }
  }
  else if(tigau == 2){
    cout << 1 << endl;
  }
  return 0;
}
0