Submission #63826130
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;#ifdef local#include <debug.hpp>#else#define debug(...)#endif#define rep(i, n) for (int i = 0; i < n; i++)template <class T> istream& operator>>(istream& I, vector<T>& V) {for (T& X : V) I >> X; return I;}template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}vector<int> di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1}; int inf = 1e9; long INF = 1e18;int main() {int n, k;cin >> n >> k;if (k == 1) {cout << "Yes\n";return 0;}n = n * k;
#include <bits/stdc++.h> using namespace std; #ifdef local #include <debug.hpp> #else #define debug(...) #endif #define rep(i, n) for (int i = 0; i < n; i++) template <class T> istream& operator>>(istream& I, vector<T>& V) {for (T& X : V) I >> X; return I;} template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} vector<int> di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1}; int inf = 1e9; long INF = 1e18; int main() { int n, k; cin >> n >> k; if (k == 1) { cout << "Yes\n"; return 0; } n = n * k; vector<vector<int>> g(n); rep(i, n - 1) { int u, v; cin >> u >> v; u--; v--; g[u].push_back(v); g[v].push_back(u); } vector<int> dp(n, -inf), used(n); auto f = [&](auto f, int v, int p = -1) -> int { if (used[v]) return dp[v]; used[v] = true; int cnt = 0, x = 0; for (int u : g[v]) if (u != p) { if (f(f, u, v) != 0) { cnt++; x = f(f, u, v); } } if (cnt >= 2) { return dp[v] = inf; } else if (cnt == 0) { return dp[v] = k - 1; } else { return dp[v] = x - 1; } }; f(f, 0); vector<int> cnt(k); rep(i, n) if (dp[i] < k) cnt[dp[i]]++; rep(i, k) { if (cnt[i] != n / k) { cout << "No\n"; return 0; } } assert(false); cout << (dp[0] ? "No\n" : "Yes\n"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Path Decomposition of a Tree |
User | WINGU |
Language | C++ 20 (gcc 12.2) |
Score | 0 |
Code Size | 1695 Byte |
Status | RE |
Exec Time | 184 ms |
Memory | 35060 KB |
Judge Result
Set Name | Sample | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 475 | ||||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | RE | 74 ms | 3552 KB |
00_sample_02.txt | AC | 1 ms | 3548 KB |
01_random_01.txt | AC | 105 ms | 15828 KB |
01_random_02.txt | AC | 106 ms | 15796 KB |
01_random_03.txt | AC | 106 ms | 15764 KB |
01_random_04.txt | AC | 111 ms | 15760 KB |
01_random_05.txt | AC | 105 ms | 15756 KB |
01_random_06.txt | AC | 107 ms | 15828 KB |
01_random_07.txt | AC | 104 ms | 15836 KB |
01_random_08.txt | AC | 110 ms | 15740 KB |
01_random_09.txt | AC | 114 ms | 15840 KB |
01_random_10.txt | AC | 111 ms | 15916 KB |
01_random_11.txt | AC | 105 ms | 16020 KB |
01_random_12.txt | AC | 106 ms | 16092 KB |
01_random_13.txt | AC | 107 ms | 16072 KB |
01_random_14.txt | AC | 105 ms | 15860 KB |
01_random_15.txt | AC | 107 ms | 16620 KB |
01_random_16.txt | WA | 112 ms | 16004 KB |
01_random_17.txt | WA | 107 ms | 15908 KB |
01_random_18.txt | WA | 119 ms | 15812 KB |
01_random_19.txt | WA | 109 ms | 16340 KB |
01_random_20.txt | AC | 119 ms | 15836 KB |
01_random_21.txt | AC | 106 ms | 15824 KB |
01_random_22.txt | AC | 105 ms | 16056 KB |
01_random_23.txt | AC | 105 ms | 15760 KB |
01_random_24.txt | AC | 107 ms | 16020 KB |
01_random_25.txt | AC | 105 ms | 15792 KB |
01_random_26.txt | WA | 119 ms | 15512 KB |
01_random_27.txt | WA | 109 ms | 15560 KB |
01_random_28.txt | WA | 106 ms | 15512 KB |
01_random_29.txt | WA | 104 ms | 15560 KB |
01_random_30.txt | AC | 109 ms | 15568 KB |
01_random_31.txt | AC | 119 ms | 15512 KB |
01_random_32.txt | AC | 105 ms | 15568 KB |
01_random_33.txt | AC | 105 ms | 15584 KB |
01_random_34.txt | WA | 105 ms | 15596 KB |
01_random_35.txt | AC | 107 ms | 15572 KB |
01_random_36.txt | WA | 107 ms | 18472 KB |
01_random_37.txt | WA | 108 ms | 19800 KB |
01_random_38.txt | WA | 119 ms | 18432 KB |
01_random_39.txt | WA | 107 ms | 21108 KB |
01_random_40.txt | AC | 109 ms | 21116 KB |
01_random_41.txt | AC | 108 ms | 21808 KB |
01_random_42.txt | AC | 108 ms | 21376 KB |
01_random_43.txt | AC | 119 ms | 19816 KB |
01_random_44.txt | AC | 110 ms | 25592 KB |
01_random_45.txt | AC | 107 ms | 17604 KB |
02_handmade_01.txt | AC | 1 ms | 3492 KB |
02_handmade_02.txt | RE | 184 ms | 35060 KB |
02_handmade_03.txt | AC | 1 ms | 3632 KB |
02_handmade_04.txt | AC | 1 ms | 3456 KB |