結果
問題 | No.2301 Namorientation |
ユーザー | Pechi |
提出日時 | 2023-05-12 22:14:35 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,625 bytes |
コンパイル時間 | 2,923 ms |
コンパイル使用メモリ | 188,596 KB |
実行使用メモリ | 51,676 KB |
最終ジャッジ日時 | 2024-05-06 12:18:30 |
合計ジャッジ時間 | 16,831 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 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 | WA | - |
testcase_06 | WA | - |
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 | 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 | 211 ms
51,676 KB |
testcase_23 | AC | 208 ms
50,816 KB |
testcase_24 | AC | 174 ms
43,008 KB |
testcase_25 | AC | 123 ms
29,452 KB |
testcase_26 | AC | 161 ms
37,368 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
ソースコード
#define _USE_MATH_DEFINES #pragma GCC target("avx2") #pragma GCC optimize("O3") #define _USE_MATH_DEFINES #include<bits/stdc++.h> #include<unordered_map> #include<random> #include <array> #include <complex> using namespace std; #define LP(I,S,G) for (long long int I = (S); I < (G); ++I) #define IN(X) for (int in = 0; in < X.size(); in++)cin >> X[in] #define OUT(X) for (int in = 0; in < X.size(); in++)cout << X[in]<<" " #define SORT(X) sort((X).begin(), (X).end()) #define CSORT(X,Y) sort(X.begin(), X.end(),Y) #define COPY(X,Y) copy(X.begin(), X.end(), Y.begin()) #define ALL(X,Y) for (auto X = (Y).begin(); X != (Y).end(); X++) #define FULL(a) (a).begin(),(a).end() #define BFS(Q,S) for(Q.push(S);Q.size()!=0;Q.pop()) typedef long long int ll; typedef unsigned long long int ull; long long int M = 998244353; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; ll MAX(ll A, ll B) { return ((A) > (B) ? (A) : (B)); } ll MIN(ll A, ll B) { return ((A) < (B) ? (A) : (B)); } inline long long int xor128() { static long long int x = 123456789, y = 362436069, z = 521288629, w = 88675123; long long int t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } ll dfs(ll now, ll past, vector<vector<ll>>& g, vector<ll>& v, vector<ll>& c) { v[now] = 1; ll ret = -1; ALL(i, g[now]) { if (*i == past)continue; if (v[*i] == 1) { c[now] = 1; if (ret == -1)ret = *i; } else { ll res = MAX(ret, dfs(*i, now, g, v, c)); if (res != -1)ret = res; if (ret != -1)c[now] = 1; } } if (ret == now)ret = -1; return ret; } int main() { ll n; cin >> n; vector<ll> u(n), v(n); vector<ll> ans(n, 0); vector<vector<ll>> g(n),G(n); vector<ll> vis(n, 0), c(n, 0); LP(i, 0, n) { cin >> u[i] >> v[i]; u[i]--, v[i]--; g[u[i]].push_back(i); g[v[i]].push_back(i); G[u[i]].push_back(v[i]); G[v[i]].push_back(u[i]); } dfs(0, -1, G, vis, c); queue<ll> q; LP(i, 0, n) { if (g[i].size() == 1)q.push(i); } while (q.size() != 0) { ll now = q.front(); q.pop(); ALL(i, g[now]) { ll gu = u[*i], gv = v[*i]; ll d = 1; if (gv == now) { swap(gu, gv); d *= -1; } if (ans[*i] == 0) { ans[*i] = d; if (c[gv]!=1)q.push(gv); } } } LP(i, 0, n) { if (ans[i] == 0) { ans[i] = 1; q.push(v[i]); break; } } while (q.size() != 0) { ll now = q.front(); q.pop(); ALL(i, g[now]) { ll gu = u[*i], gv = v[*i]; ll d = 1; if (gv == now) { swap(gu, gv); d *= -1; } if (ans[*i] == 0) { ans[*i] = d; q.push(gv); } } } LP(i, 0, n)cout << ((ans[i] == 1) ? "->" : "<-")<<"\n"; return 0; }