# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056402 | 2024-08-13T09:15:07 Z | Ignut | Longest Trip (IOI23_longesttrip) | C++17 | 765 ms | 1320 KB |
/* Ignut started: 13.08.2024 now: 13.08.2024 ████████████████████████████████████████████████████████████████████ ████████████████████████████████ ████████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████ ██████████████████ ██████████████████ ██████ ██████ ██████████████ ██████████████ ██████ ██████ ██ ████████████ ████████████ ██ ██████ ██████ ████ ██████████ ██████████ ████ ██████ ██████ ████ ██████████ ██████████ ████ ██████ ██████ ████ ██████████ ██████████ ██████ ██████ ██████ ██████ ██████████ ██████████ ██████ ██████ ██████ ██████ ████████ ████████ ██████ ██████ ██████ ██████ ██████ ██████ ██████ ██████ ██████ ████ ████ ████ ████ ██████ ██████ ██████████ ████ ██████████ ██████ ██████ ██ ██████ ████████ ██████ ██ ██████ ██████ ██████ ████████ ██████ ██████ ██████ ██ ██ ██████ ██████████████████████ ████ ████ ██████████████████████ ████████████████████████ ██ ██ ████████████████████████ ██████████████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ████████████████████████████████████████████████████████████████████ */ #include <bits/stdc++.h> using namespace std; using ll = long long; bool are_connected(vector<int> A, vector<int> B); const int MAXN = 333; vector<int> g[MAXN]; bool used[MAXN]; vector<int> order; void dfs(int v) { order.push_back(v); used[v] = true; for (int to : g[v]) { if (used[to]) continue; dfs(to); return; } } vector<int> longest_trip(int N, int D) { if (D == 3) { vector<int> vec; for (int i = 0; i < N; i ++) vec.push_back(i); return vec; } if (D == 2) { vector<pair<int, int>> lst; int cnt[N] = {}; for (int i = 0; i < N; i ++) { for (int j = i + 1; j < N; j ++) { if (!are_connected({i}, {j})) { lst.push_back({i, j}); cnt[i] ++, cnt[j] ++; } } } vector<int> free; for (int i = 0; i < N; i ++) if (cnt[i] == 0) free.push_back(i); vector<int> res; for (int i = 0; i < lst.size(); i ++) res.push_back(lst[i].first); for (int val : free) res.push_back(val); for (int i = 0; i < lst.size(); i ++) res.push_back(lst[i].second); return res; } order.clear(); for (int i = 0; i < N; i ++) { g[i].clear(); used[i] = false; } for (int i = 0; i < N; i ++) { for (int j = i + 1; j < N; j ++) { if (are_connected({i}, {j})) { g[i].push_back(j); g[j].push_back(i); } } } int vertex = 0; for (int i = 1; i < N; i ++) if (g[i].size() < g[vertex].size()) vertex = i; dfs(vertex); return order; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 174 ms | 900 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 344 KB | Output is correct |
2 | Correct | 28 ms | 344 KB | Output is correct |
3 | Correct | 107 ms | 344 KB | Output is correct |
4 | Correct | 353 ms | 344 KB | Output is correct |
5 | Correct | 765 ms | 420 KB | Output is correct |
6 | Correct | 9 ms | 344 KB | Output is correct |
7 | Correct | 18 ms | 344 KB | Output is correct |
8 | Correct | 118 ms | 344 KB | Output is correct |
9 | Correct | 248 ms | 340 KB | Output is correct |
10 | Correct | 672 ms | 424 KB | Output is correct |
11 | Correct | 692 ms | 424 KB | Output is correct |
12 | Correct | 660 ms | 344 KB | Output is correct |
13 | Correct | 691 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 18 ms | 344 KB | Output is correct |
3 | Correct | 145 ms | 344 KB | Output is correct |
4 | Correct | 335 ms | 600 KB | Output is correct |
5 | Correct | 643 ms | 1104 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 18 ms | 344 KB | Output is correct |
8 | Correct | 94 ms | 344 KB | Output is correct |
9 | Correct | 236 ms | 616 KB | Output is correct |
10 | Correct | 714 ms | 860 KB | Output is correct |
11 | Correct | 692 ms | 1320 KB | Output is correct |
12 | Correct | 749 ms | 848 KB | Output is correct |
13 | Correct | 730 ms | 712 KB | Output is correct |
14 | Correct | 5 ms | 344 KB | Output is correct |
15 | Incorrect | 1 ms | 344 KB | Incorrect |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 23 ms | 344 KB | Output is correct |
3 | Partially correct | 115 ms | 344 KB | Output is partially correct |
4 | Partially correct | 303 ms | 592 KB | Output is partially correct |
5 | Partially correct | 689 ms | 848 KB | Output is partially correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Incorrect | 4 ms | 344 KB | Incorrect |
8 | Halted | 0 ms | 0 KB | - |