# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
840429 | 2023-08-31T11:23:40 Z | ogkostya | Longest Trip (IOI23_longesttrip) | C++17 | 12 ms | 336 KB |
#include "longesttrip.h" std::vector<int> longest_trip(int N, int D) { std::vector<int> an1 = {}; std::vector<int> an2 = {}; an1.push_back(0); std::vector<int> temp1 = {}; std::vector<int> temp2 = {}; for (int i = 1; i < N; i++) { temp1.clear(); temp1.push_back(i); temp2.clear(); temp2.push_back(an1.back()); if (are_connected(temp1, temp2)) { an1.push_back(i); } else { if (an2.size() == 0) { an2.push_back(i); } else { temp2.clear(); temp2.push_back(an2.back()); if (are_connected(temp1, temp2)) { an2.push_back(i); } else { while (an2.size() > 0) { an1.push_back(an2.back()); an2.pop_back(); } an2.push_back(i); } } } } if (an2.size() > 0) { temp1.clear(); temp1.push_back(an1.back()); temp2.clear(); temp2.push_back(an2.back()); if (are_connected(temp1, temp2)) { while (an2.size() > 0) { an1.push_back(an2.back()); an2.pop_back(); } } else { temp2.clear(); temp2.push_back(an2.front()); if (are_connected(temp1, temp2)) { for (int i = 0; i < an2.size(); i++) { an1.push_back(an2[i]); } } } } return an1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 3 ms | 288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 208 KB | Output is correct |
2 | Correct | 7 ms | 208 KB | Output is correct |
3 | Correct | 8 ms | 208 KB | Output is correct |
4 | Correct | 8 ms | 208 KB | Output is correct |
5 | Correct | 10 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 208 KB | Output is correct |
2 | Correct | 7 ms | 208 KB | Output is correct |
3 | Correct | 10 ms | 208 KB | Output is correct |
4 | Correct | 8 ms | 208 KB | Output is correct |
5 | Correct | 4 ms | 284 KB | Output is correct |
6 | Incorrect | 0 ms | 208 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 208 KB | Output is correct |
2 | Correct | 10 ms | 208 KB | Output is correct |
3 | Correct | 8 ms | 208 KB | Output is correct |
4 | Correct | 8 ms | 208 KB | Output is correct |
5 | Correct | 9 ms | 208 KB | Output is correct |
6 | Correct | 11 ms | 208 KB | Output is correct |
7 | Correct | 10 ms | 208 KB | Output is correct |
8 | Correct | 9 ms | 208 KB | Output is correct |
9 | Correct | 8 ms | 208 KB | Output is correct |
10 | Correct | 8 ms | 208 KB | Output is correct |
11 | Correct | 9 ms | 208 KB | Output is correct |
12 | Correct | 9 ms | 336 KB | Output is correct |
13 | Correct | 8 ms | 208 KB | Output is correct |
14 | Correct | 12 ms | 208 KB | Output is correct |
15 | Incorrect | 1 ms | 208 KB | Incorrect |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 208 KB | Output is correct |
2 | Correct | 7 ms | 208 KB | Output is correct |
3 | Correct | 8 ms | 208 KB | Output is correct |
4 | Correct | 9 ms | 208 KB | Output is correct |
5 | Correct | 7 ms | 284 KB | Output is correct |
6 | Incorrect | 0 ms | 208 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |