結果

問題 No.2301 Namorientation
ユーザー umezoumezo
提出日時 2023-05-12 23:10:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 438 ms / 3,000 ms
コード長 932 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 208,024 KB
実行使用メモリ 19,420 KB
最終ジャッジ日時 2023-08-19 06:04:01
合計ジャッジ時間 16,019 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,192 KB
testcase_01 AC 3 ms
8,016 KB
testcase_02 AC 4 ms
8,192 KB
testcase_03 AC 4 ms
8,048 KB
testcase_04 AC 4 ms
8,024 KB
testcase_05 AC 4 ms
8,188 KB
testcase_06 AC 4 ms
8,016 KB
testcase_07 AC 3 ms
8,076 KB
testcase_08 AC 4 ms
8,192 KB
testcase_09 AC 4 ms
8,020 KB
testcase_10 AC 4 ms
8,028 KB
testcase_11 AC 4 ms
8,020 KB
testcase_12 AC 217 ms
14,284 KB
testcase_13 AC 193 ms
13,704 KB
testcase_14 AC 394 ms
18,804 KB
testcase_15 AC 245 ms
15,676 KB
testcase_16 AC 331 ms
17,312 KB
testcase_17 AC 226 ms
14,768 KB
testcase_18 AC 334 ms
17,376 KB
testcase_19 AC 195 ms
13,636 KB
testcase_20 AC 322 ms
17,340 KB
testcase_21 AC 243 ms
15,044 KB
testcase_22 AC 314 ms
18,628 KB
testcase_23 AC 312 ms
18,588 KB
testcase_24 AC 254 ms
16,876 KB
testcase_25 AC 231 ms
16,972 KB
testcase_26 AC 299 ms
19,420 KB
testcase_27 AC 385 ms
18,832 KB
testcase_28 AC 438 ms
18,876 KB
testcase_29 AC 383 ms
18,820 KB
testcase_30 AC 432 ms
18,820 KB
testcase_31 AC 385 ms
18,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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]--;
      que.push({deg[nv],nv});
      break;
    }
  }
  rep(i,n){
    if(to[A[i]]==B[i]) cout<<"->"<<endl;
    else cout<<"<-"<<endl;
  }
  
  return 0;
}
0