結果
問題 | No.1023 Cyclic Tour |
ユーザー | ir5 |
提出日時 | 2024-06-18 00:11:23 |
言語 | C++23(gcc13) (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,535 bytes |
コンパイル時間 | 1,939 ms |
コンパイル使用メモリ | 146,448 KB |
実行使用メモリ | 17,008 KB |
最終ジャッジ日時 | 2024-06-18 00:11:36 |
合計ジャッジ時間 | 13,203 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 107 ms
9,856 KB |
testcase_05 | AC | 137 ms
9,728 KB |
testcase_06 | AC | 126 ms
10,624 KB |
testcase_07 | AC | 111 ms
10,240 KB |
testcase_08 | AC | 98 ms
8,576 KB |
testcase_09 | AC | 97 ms
8,320 KB |
testcase_10 | AC | 98 ms
8,320 KB |
testcase_11 | WA | - |
testcase_12 | AC | 101 ms
8,184 KB |
testcase_13 | AC | 96 ms
7,936 KB |
testcase_14 | AC | 92 ms
8,064 KB |
testcase_15 | AC | 132 ms
8,192 KB |
testcase_16 | AC | 176 ms
9,856 KB |
testcase_17 | AC | 184 ms
9,984 KB |
testcase_18 | AC | 186 ms
9,856 KB |
testcase_19 | AC | 181 ms
9,728 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 194 ms
11,748 KB |
testcase_26 | AC | 202 ms
11,392 KB |
testcase_27 | AC | 202 ms
11,136 KB |
testcase_28 | AC | 192 ms
10,496 KB |
testcase_29 | AC | 182 ms
9,984 KB |
testcase_30 | AC | 197 ms
10,880 KB |
testcase_31 | AC | 189 ms
11,136 KB |
testcase_32 | AC | 182 ms
10,240 KB |
testcase_33 | AC | 205 ms
11,008 KB |
testcase_34 | AC | 191 ms
11,008 KB |
testcase_35 | AC | 203 ms
11,776 KB |
testcase_36 | WA | - |
testcase_37 | AC | 187 ms
10,752 KB |
testcase_38 | AC | 178 ms
11,008 KB |
testcase_39 | WA | - |
testcase_40 | AC | 188 ms
10,880 KB |
testcase_41 | AC | 190 ms
10,752 KB |
testcase_42 | AC | 206 ms
11,880 KB |
testcase_43 | AC | 176 ms
9,856 KB |
testcase_44 | AC | 112 ms
10,204 KB |
testcase_45 | AC | 110 ms
16,896 KB |
testcase_46 | AC | 109 ms
16,964 KB |
testcase_47 | AC | 118 ms
17,008 KB |
testcase_48 | WA | - |
testcase_49 | AC | 193 ms
10,972 KB |
testcase_50 | WA | - |
testcase_51 | AC | 192 ms
10,184 KB |
testcase_52 | AC | 197 ms
10,292 KB |
ソースコード
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <numeric> #include <vector> #include <map> #include <set> #include <queue> #include <functional> #include <iomanip> using namespace std; using ll = long long; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n; public:range(int n_):i({0}),n({n_}){}range(int i_,int n_):i({i_}),n({n_}){}I& begin(){return i;}I& end(){return n;}}; template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; } template<typename T> ostream& operator<<(ostream& os, const vector<T>& obj) { os << "{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } template<typename T> ostream& operator<<(ostream& os, const set<T>& obj) { os << "set{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } template<typename T, typename U> ostream& operator<<(ostream& os, const map<T, U>& obj) { os << "map{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } #ifdef ONLINE_JUDGE #define dump(expr) ; #else #define dump(expr) { cerr << "\033[33m#L" << __LINE__ << ": " << expr << "\033[39m" << endl; } #endif struct E { int fr, to, c; E(int fr_, int to_, int c_) : fr(fr_), to(to_), c(c_) {} friend ostream &operator<<(ostream &os, const E &e) { os << "(" << e.fr << " -> " << e.to << ")"; return os; } }; typedef vector<E> V; // typedef vector<V> G; // note that each vertex will have both enterning edges & entered edges void add_edge(vector<V> &vg, int fr, int to, int c) { vg[fr].push_back(E(fr, to, c)); } ll solve() { int n, m; cin >> n >> m; vector<V> vg(n + 1); for (int i : range(m)) { int a, b, c; cin >> a >> b >> c; add_edge(vg, a, b, c); if (c == 1) { add_edge(vg, b, a, c); } } vector<int> visited(n + 1); function<int(int, int)> dfs; int phase = 1; dfs = [&](int idx, int prev) -> int { dump(idx << " " << prev); if (visited[idx] > 0) { return visited[idx] == phase; } visited[idx] = phase; for (auto e : vg[idx]) if (e.to != prev || e.c == 2) { if (dfs(e.to, e.c == 1 ? idx : -1)) return 1; } return 0; }; for (int i : range(1, n + 1)) { phase = i; dump(phase); if (dfs(i, -1)) return 1; } return 0; } int main() { cout << fixed << setprecision(12); cout << (solve() ? "Yes" : "No") << endl; }