結果
問題 | No.2301 Namorientation |
ユーザー |
![]() |
提出日時 | 2023-05-12 23:07:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 902 bytes |
コンパイル時間 | 2,133 ms |
コンパイル使用メモリ | 201,728 KB |
最終ジャッジ日時 | 2025-02-12 23:34:13 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 22 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; vector<int> G[200200]; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; vector<int> A(n),B(n),deg(n); rep(i,n){ cin>>A[i]>>B[i]; A[i]--,B[i]--; G[A[i]].push_back(B[i]); G[B[i]].push_back(A[i]); deg[A[i]]++; deg[B[i]]++; } priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> que; rep(i,n) que.push({G[i].size(),i}); vector<int> to(n,-1); while(que.size()){ auto [a,b]=que.top(); que.pop(); if(to[b]!=-1) continue; for(auto nv:G[b]){ if(to[nv]==b) continue; to[b]=nv; deg[b]--; deg[nv]--; break; } } rep(i,n){ if(to[A[i]]==B[i]) cout<<"->"<<endl; else cout<<"<-"<<endl; } return 0; }