結果

問題 No.2301 Namorientation
ユーザー 沙耶花沙耶花
提出日時 2023-05-12 21:35:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 4,560 ms
コンパイル使用メモリ 265,324 KB
実行使用メモリ 20,068 KB
最終ジャッジ日時 2024-05-06 11:17:31
合計ジャッジ時間 20,037 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 414 ms
19,528 KB
testcase_23 AC 411 ms
19,428 KB
testcase_24 AC 345 ms
17,152 KB
testcase_25 AC 299 ms
16,780 KB
testcase_26 AC 392 ms
20,068 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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]]++;
	}
	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