結果
問題 |
No.1605 Matrix Shape
|
ユーザー |
|
提出日時 | 2021-07-16 22:03:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,024 bytes |
コンパイル時間 | 3,877 ms |
コンパイル使用メモリ | 229,664 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 09:14:35 |
合計ジャッジ時間 | 7,609 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 6 |
ソースコード
#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] = {}; rep(i,N){ ll a,b; cin>>a>>b; H[a]++; W[b]++; } ll d = 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; rep(i,200200){ if(H[i]>0){ ans++; } } cout << ans << endl; } else if(tigau == 2){ if(N == 2){ cout << 2 << endl; } else{ cout << 1 << endl; } } return 0; }