結果
問題 |
No.483 マッチ並べ
|
ユーザー |
![]() |
提出日時 | 2024-09-29 23:56:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 839 bytes |
コンパイル時間 | 1,411 ms |
コンパイル使用メモリ | 121,780 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-29 23:56:27 |
合計ジャッジ時間 | 3,107 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 53 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll = long long; #include<atcoder/dsu> #include<map> int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin>>n; atcoder::dsu uf(100*100); map<pair<int,int>,int> memo; for(int i = 0;i<n;i++){ int a,b,c,d; cin>>a>>b>>c>>d; a--;b--;c--;d--; int ni = a * 100 + b; int nj = c * 100 + d; uf.merge(ni,nj); memo[{a,b}]++; } bool fn = false; for(auto now:uf.groups()){ int cnt = 0; for(auto e:now){ int a = e / 100; int b = e % 100; cnt += memo[{a,b}]; } int sz = now.size(); if(cnt<=sz) continue; fn = true; } if(fn) cout<<"NO\n"; else cout<<"YES\n"; }