結果

問題 No.2301 Namorientation
ユーザー 沙耶花沙耶花
提出日時 2023-05-12 21:37:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 615 ms / 3,000 ms
コード長 1,204 bytes
コンパイル時間 4,518 ms
コンパイル使用メモリ 265,232 KB
実行使用メモリ 20,180 KB
最終ジャッジ日時 2024-05-06 11:19:26
合計ジャッジ時間 21,900 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 342 ms
13,048 KB
testcase_13 AC 310 ms
12,164 KB
testcase_14 AC 615 ms
19,728 KB
testcase_15 AC 385 ms
15,016 KB
testcase_16 AC 512 ms
17,712 KB
testcase_17 AC 361 ms
13,272 KB
testcase_18 AC 526 ms
17,848 KB
testcase_19 AC 286 ms
11,676 KB
testcase_20 AC 514 ms
17,844 KB
testcase_21 AC 391 ms
13,860 KB
testcase_22 AC 467 ms
19,528 KB
testcase_23 AC 459 ms
19,304 KB
testcase_24 AC 374 ms
17,156 KB
testcase_25 AC 327 ms
16,784 KB
testcase_26 AC 414 ms
20,180 KB
testcase_27 AC 606 ms
19,780 KB
testcase_28 AC 595 ms
19,656 KB
testcase_29 AC 606 ms
19,660 KB
testcase_30 AC 611 ms
19,784 KB
testcase_31 AC 603 ms
19,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001



int main(){
	
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	vector<vector<int>> E(n);
	vector<int> d(n);
	rep(i,n){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		E[a[i]].push_back(i);
		E[b[i]].push_back(i);
		d[a[i]]++;
		d[b[i]]++;
	}
	vector<int> ans(n,-1);
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;
	rep(i,n){
		Q.emplace(d[i],i);
	}
	vector<bool> used(n,false);
	while(Q.size()>0){
		auto r = Q.top();
		Q.pop();
		if(d[r.second]!=r.first)continue;
		int u = r.second;
		rep(i,E[r.second].size()){
			int ii = E[r.second][i];
			int v = u ^ a[ii] ^ b[ii];
			if(ans[ii]!=-1)continue;
			if(used[u]==false){
				if(u<v)ans[ii] = 0;
				else ans[ii] = 1;
				used[u] = true;
			}
			else{
				if(u<v)ans[ii] = 1;
				else ans[ii] = 0;
				used[v] = true;
			}
			d[u]--,d[v]--;
			Q.emplace(d[u],u);
			Q.emplace(d[v],v);
			break;
		}
	}
	rep(i,n){
		if(ans[i]==0)cout<<"->"<<endl;
		else cout<<"<-"<<endl;
	}
	return 0;
}
0