結果
問題 | No.1605 Matrix Shape |
ユーザー | 沙耶花 |
提出日時 | 2021-07-16 21:39:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 912 bytes |
コンパイル時間 | 3,897 ms |
コンパイル使用メモリ | 268,248 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 08:38:02 |
合計ジャッジ時間 | 7,117 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,944 KB |
testcase_02 | AC | 3 ms
6,944 KB |
testcase_03 | AC | 4 ms
6,944 KB |
testcase_04 | AC | 3 ms
6,940 KB |
testcase_05 | AC | 3 ms
6,944 KB |
testcase_06 | AC | 3 ms
6,944 KB |
testcase_07 | AC | 3 ms
6,944 KB |
testcase_08 | AC | 4 ms
6,940 KB |
testcase_09 | AC | 3 ms
6,940 KB |
testcase_10 | AC | 4 ms
6,940 KB |
testcase_11 | AC | 3 ms
6,940 KB |
testcase_12 | AC | 3 ms
6,944 KB |
testcase_13 | AC | 3 ms
6,940 KB |
testcase_14 | AC | 3 ms
6,940 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 3 ms
6,940 KB |
testcase_18 | AC | 3 ms
6,944 KB |
testcase_19 | AC | 120 ms
6,944 KB |
testcase_20 | AC | 112 ms
6,944 KB |
testcase_21 | AC | 114 ms
6,940 KB |
testcase_22 | AC | 119 ms
6,940 KB |
testcase_23 | AC | 124 ms
6,944 KB |
testcase_24 | AC | 123 ms
6,940 KB |
testcase_25 | AC | 77 ms
6,940 KB |
testcase_26 | AC | 77 ms
6,940 KB |
testcase_27 | AC | 78 ms
6,940 KB |
testcase_28 | AC | 74 ms
6,940 KB |
testcase_29 | AC | 76 ms
6,940 KB |
testcase_30 | AC | 109 ms
6,944 KB |
testcase_31 | AC | 113 ms
6,940 KB |
testcase_32 | AC | 102 ms
6,944 KB |
testcase_33 | AC | 100 ms
6,944 KB |
testcase_34 | AC | 97 ms
6,944 KB |
testcase_35 | WA | - |
testcase_36 | AC | 57 ms
6,940 KB |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main(){ int N; cin>>N; vector<int> da(200005,0),db(200005,0); dsu D(200005); rep(i,N){ int h,w; cin>>h>>w; da[h]++; db[w]++; D.merge(h,w); } set<int> S; rep(i,da.size()){ if(da[i]>0||db[i]>0){ S.insert(D.leader(i)); } } if(S.size()>1){ cout<<0<<endl; return 0; } S.clear(); set<int> S2; int cnt = 0; rep(i,da.size()){ if(da[i]==0&&db[i]==0)continue; if(da[i]==db[i]){ cnt++; } else if(da[i]+1==db[i]){ S.insert(i); } else if(da[i]==db[i]+1){ S2.insert(i); } else{ cout<<0<<endl; return 0; } } if(S.size()==0&&S2.size()==0){ cout<<cnt<<endl; return 0; } if(S.size()==1&&S2.size()==1){ cout<<1<<endl; return 0; } return 0; }