結果
問題 |
No.1605 Matrix Shape
|
ユーザー |
|
提出日時 | 2021-07-16 22:17:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,335 bytes |
コンパイル時間 | 4,353 ms |
コンパイル使用メモリ | 251,128 KB |
最終ジャッジ日時 | 2025-01-23 02:11:10 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 19 WA * 15 |
ソースコード
#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; }