結果
| 問題 |
No.2301 Namorientation
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2023-05-12 22:08:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,441 bytes |
| コンパイル時間 | 2,174 ms |
| コンパイル使用メモリ | 213,276 KB |
| 最終ジャッジ日時 | 2025-02-12 22:56:36 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
if(a>b){
a=b;
}
}
template<class T> void chmax(T &a,T b){
if(a<b){
a=b;
}
}
vector<vector<ll>> g;
vector<bool> vis;
vector<ll> v,s={};
void dfs(ll x,ll p){
v.push_back(x);
vis[x]=true;
for(auto &i:g[x]){
if(i==p) continue;
if(!vis[i]) dfs(i,x);
else{
if((ll)s.size()==0) s=v;
}
}
v.pop_back();
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
g.resize(n);
vis.resize(n,false);
map<pll,ll> mp;
vector<ll> ans(n,-1);
vector<ll> a(n),b(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]);
mp[{a[i],b[i]}]=i;
mp[{b[i],a[i]}]=i;
}
dfs(0,-1);
rep(i,s.size()){
ll x=s[i];
ll y=s[(i+1)%(ll)s.size()];
if(x<y) ans[mp[{x,y}]]=1;
else ans[mp[{x,y}]]=0;
}
rep(i,n){
if(ans[i]!=-1) continue;
if((ll)g[a[i]].size()<(ll)g[b[i]].size()) ans[i]=1;
else ans[i]=0;
}
rep(i,n){
if(ans[i]==0) cout << "<-\n";
else cout << "->\n";
}
}
FplusFplusF