# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1038175 | 2024-07-29T14:00:28 Z | aymanrs | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 873 ms | 1116 KB |
#include "longesttrip.h" #include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") using namespace std; bool g[300][300] = {{false}}; bool ej[256] = {false}; pair<vector<int>,vector<int>> fl(const vector<int>& V){ memset(ej, 0, sizeof(ej)); queue<int> q;q.push(V[0]); ej[V[0]]=true; vector<int> a;a.push_back(V[0]); while(!q.empty()){ int t = q.front(); q.pop(); for(int j : V){ if(g[t][j] && !ej[j]){ ej[j]=true; q.push(j); a.push_back(j); } } } vector<int> b, c; if(a.size()<V.size()){ for(int i : V) if(!ej[i]) b.push_back(i); return {a,b}; } int i, j; for(i = 0;i < V.size();i++){ for(j = i+1;j < V.size();j++){ if(!g[V[i]][V[j]]) goto hoho; } } hoho: if(i >= V.size() || j >= V.size()) return {a, {}}; a.clear(); i=V[i];j=V[j]; for(int k : V){ if(k==i||k==j) continue; if(!g[k][j]) a.push_back(k); else if(!g[k][i]) c.push_back(k); else { b.push_back(k); } } if(b.empty()){ a.push_back(i); for(int& k : a){ for(int& l : c){ if(g[k][l]){ swap(k, a.back()); swap(l, c[0]); c.push_back(j); for(int x : c) a.push_back(x); return {a, {}}; } } } } auto L = fl(b); if(L.second.empty()){ a.push_back(i); for(int k : L.first) a.push_back(k); a.push_back(j); for(int k : c) a.push_back(k); return {a, {}}; } else { if(a.empty()){ L.first.push_back(i); for(int k : L.second) L.first.push_back(k); L.first.push_back(j); for(int k : c) L.first.push_back(k); return {L.first, {}}; } if(g[a[0]][L.first[0]]){ a.push_back(i); swap(a.back(), a[0]); for(int k : L.first) a.push_back(k); for(int k : a) L.second.push_back(k); L.second.push_back(j); for(int k : c) L.second.push_back(k); return {L.second, {}}; } else { a.push_back(i); swap(a.back(), a[0]); for(int k : L.second) a.push_back(k); for(int k : a) L.first.push_back(k); L.first.push_back(j); for(int k : c) L.first.push_back(k); return {L.first, {}}; } } } std::vector<int> longest_trip(int N, int D) { vector<int> V; for(int i = 0;i < N;i++) for(int j = 0;j < N;j++) g[i][j] = false; for(int i = 0;i < N;i++){ V.push_back(i); for(int j = i+1;j < N;j++){ if(are_connected({i}, {j})){ g[i][j]=g[j][i]=true; } } } auto L = fl(V); if(L.first.size()>=L.second.size()) return L.first; return L.second; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 221 ms | 492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 340 KB | Output is correct |
3 | Correct | 139 ms | 436 KB | Output is correct |
4 | Correct | 366 ms | 452 KB | Output is correct |
5 | Correct | 781 ms | 488 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 344 KB | Output is correct |
3 | Correct | 134 ms | 432 KB | Output is correct |
4 | Correct | 417 ms | 468 KB | Output is correct |
5 | Correct | 743 ms | 492 KB | Output is correct |
6 | Correct | 9 ms | 344 KB | Output is correct |
7 | Correct | 21 ms | 344 KB | Output is correct |
8 | Correct | 124 ms | 704 KB | Output is correct |
9 | Correct | 272 ms | 540 KB | Output is correct |
10 | Correct | 759 ms | 1004 KB | Output is correct |
11 | Correct | 747 ms | 868 KB | Output is correct |
12 | Correct | 775 ms | 1076 KB | Output is correct |
13 | Correct | 771 ms | 872 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 16 ms | 344 KB | Output is correct |
3 | Correct | 105 ms | 428 KB | Output is correct |
4 | Correct | 359 ms | 592 KB | Output is correct |
5 | Correct | 782 ms | 344 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 26 ms | 344 KB | Output is correct |
8 | Correct | 173 ms | 600 KB | Output is correct |
9 | Correct | 327 ms | 704 KB | Output is correct |
10 | Correct | 873 ms | 1004 KB | Output is correct |
11 | Correct | 831 ms | 868 KB | Output is correct |
12 | Correct | 858 ms | 1004 KB | Output is correct |
13 | Correct | 796 ms | 872 KB | Output is correct |
14 | Correct | 5 ms | 344 KB | Output is correct |
15 | Correct | 11 ms | 344 KB | Output is correct |
16 | Correct | 39 ms | 344 KB | Output is correct |
17 | Correct | 86 ms | 344 KB | Output is correct |
18 | Correct | 166 ms | 432 KB | Output is correct |
19 | Correct | 311 ms | 592 KB | Output is correct |
20 | Correct | 329 ms | 448 KB | Output is correct |
21 | Correct | 786 ms | 752 KB | Output is correct |
22 | Correct | 789 ms | 752 KB | Output is correct |
23 | Correct | 796 ms | 520 KB | Output is correct |
24 | Correct | 808 ms | 520 KB | Output is correct |
25 | Correct | 7 ms | 344 KB | Output is correct |
26 | Correct | 7 ms | 344 KB | Output is correct |
27 | Correct | 17 ms | 344 KB | Output is correct |
28 | Correct | 22 ms | 344 KB | Output is correct |
29 | Correct | 15 ms | 344 KB | Output is correct |
30 | Correct | 159 ms | 344 KB | Output is correct |
31 | Correct | 181 ms | 344 KB | Output is correct |
32 | Correct | 165 ms | 344 KB | Output is correct |
33 | Correct | 294 ms | 592 KB | Output is correct |
34 | Correct | 292 ms | 344 KB | Output is correct |
35 | Correct | 311 ms | 592 KB | Output is correct |
36 | Correct | 733 ms | 496 KB | Output is correct |
37 | Correct | 769 ms | 496 KB | Output is correct |
38 | Correct | 851 ms | 496 KB | Output is correct |
39 | Correct | 721 ms | 496 KB | Output is correct |
40 | Correct | 806 ms | 488 KB | Output is correct |
41 | Correct | 820 ms | 592 KB | Output is correct |
42 | Correct | 800 ms | 488 KB | Output is correct |
43 | Correct | 725 ms | 492 KB | Output is correct |
44 | Correct | 788 ms | 492 KB | Output is correct |
45 | Correct | 10 ms | 344 KB | Output is correct |
46 | Correct | 13 ms | 344 KB | Output is correct |
47 | Correct | 23 ms | 344 KB | Output is correct |
48 | Correct | 17 ms | 344 KB | Output is correct |
49 | Correct | 23 ms | 344 KB | Output is correct |
50 | Correct | 181 ms | 344 KB | Output is correct |
51 | Correct | 196 ms | 344 KB | Output is correct |
52 | Correct | 211 ms | 344 KB | Output is correct |
53 | Correct | 261 ms | 344 KB | Output is correct |
54 | Correct | 289 ms | 592 KB | Output is correct |
55 | Correct | 305 ms | 344 KB | Output is correct |
56 | Correct | 781 ms | 492 KB | Output is correct |
57 | Correct | 834 ms | 492 KB | Output is correct |
58 | Correct | 838 ms | 500 KB | Output is correct |
59 | Correct | 780 ms | 592 KB | Output is correct |
60 | Correct | 790 ms | 496 KB | Output is correct |
61 | Correct | 820 ms | 492 KB | Output is correct |
62 | Correct | 816 ms | 488 KB | Output is correct |
63 | Correct | 799 ms | 492 KB | Output is correct |
64 | Correct | 808 ms | 496 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 27 ms | 344 KB | Output is correct |
3 | Partially correct | 136 ms | 432 KB | Output is partially correct |
4 | Partially correct | 361 ms | 452 KB | Output is partially correct |
5 | Partially correct | 764 ms | 500 KB | Output is partially correct |
6 | Correct | 9 ms | 344 KB | Output is correct |
7 | Correct | 26 ms | 344 KB | Output is correct |
8 | Partially correct | 144 ms | 344 KB | Output is partially correct |
9 | Partially correct | 329 ms | 784 KB | Output is partially correct |
10 | Partially correct | 764 ms | 828 KB | Output is partially correct |
11 | Partially correct | 753 ms | 1048 KB | Output is partially correct |
12 | Partially correct | 855 ms | 868 KB | Output is partially correct |
13 | Partially correct | 790 ms | 1116 KB | Output is partially correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 13 ms | 344 KB | Output is correct |
16 | Correct | 41 ms | 344 KB | Output is correct |
17 | Partially correct | 99 ms | 344 KB | Output is partially correct |
18 | Partially correct | 137 ms | 452 KB | Output is partially correct |
19 | Partially correct | 306 ms | 452 KB | Output is partially correct |
20 | Partially correct | 280 ms | 344 KB | Output is partially correct |
21 | Correct | 8 ms | 344 KB | Output is correct |
22 | Correct | 9 ms | 344 KB | Output is correct |
23 | Correct | 30 ms | 596 KB | Output is correct |
24 | Correct | 23 ms | 344 KB | Output is correct |
25 | Correct | 16 ms | 344 KB | Output is correct |
26 | Partially correct | 189 ms | 344 KB | Output is partially correct |
27 | Partially correct | 201 ms | 344 KB | Output is partially correct |
28 | Partially correct | 197 ms | 344 KB | Output is partially correct |
29 | Partially correct | 298 ms | 344 KB | Output is partially correct |
30 | Partially correct | 328 ms | 448 KB | Output is partially correct |
31 | Partially correct | 294 ms | 444 KB | Output is partially correct |
32 | Correct | 9 ms | 344 KB | Output is correct |
33 | Correct | 14 ms | 344 KB | Output is correct |
34 | Correct | 15 ms | 344 KB | Output is correct |
35 | Correct | 30 ms | 344 KB | Output is correct |
36 | Correct | 38 ms | 344 KB | Output is correct |
37 | Partially correct | 186 ms | 460 KB | Output is partially correct |
38 | Partially correct | 165 ms | 600 KB | Output is partially correct |
39 | Partially correct | 210 ms | 344 KB | Output is partially correct |
40 | Partially correct | 312 ms | 592 KB | Output is partially correct |
41 | Partially correct | 350 ms | 344 KB | Output is partially correct |
42 | Partially correct | 332 ms | 344 KB | Output is partially correct |
43 | Partially correct | 820 ms | 516 KB | Output is partially correct |
44 | Partially correct | 867 ms | 516 KB | Output is partially correct |
45 | Partially correct | 820 ms | 524 KB | Output is partially correct |
46 | Partially correct | 766 ms | 752 KB | Output is partially correct |
47 | Partially correct | 785 ms | 488 KB | Output is partially correct |
48 | Partially correct | 789 ms | 592 KB | Output is partially correct |
49 | Partially correct | 773 ms | 500 KB | Output is partially correct |
50 | Partially correct | 769 ms | 748 KB | Output is partially correct |
51 | Partially correct | 784 ms | 488 KB | Output is partially correct |
52 | Partially correct | 780 ms | 592 KB | Output is partially correct |
53 | Partially correct | 810 ms | 504 KB | Output is partially correct |
54 | Partially correct | 762 ms | 492 KB | Output is partially correct |
55 | Partially correct | 795 ms | 488 KB | Output is partially correct |
56 | Partially correct | 792 ms | 492 KB | Output is partially correct |
57 | Partially correct | 719 ms | 748 KB | Output is partially correct |
58 | Partially correct | 801 ms | 492 KB | Output is partially correct |
59 | Partially correct | 705 ms | 488 KB | Output is partially correct |
60 | Partially correct | 712 ms | 492 KB | Output is partially correct |
61 | Partially correct | 777 ms | 488 KB | Output is partially correct |
62 | Partially correct | 745 ms | 492 KB | Output is partially correct |
63 | Partially correct | 753 ms | 492 KB | Output is partially correct |
64 | Partially correct | 733 ms | 496 KB | Output is partially correct |
65 | Partially correct | 720 ms | 492 KB | Output is partially correct |
66 | Partially correct | 700 ms | 752 KB | Output is partially correct |
67 | Partially correct | 739 ms | 492 KB | Output is partially correct |
68 | Partially correct | 678 ms | 492 KB | Output is partially correct |
69 | Partially correct | 782 ms | 488 KB | Output is partially correct |
70 | Partially correct | 781 ms | 492 KB | Output is partially correct |
71 | Partially correct | 794 ms | 488 KB | Output is partially correct |
72 | Partially correct | 765 ms | 492 KB | Output is partially correct |
73 | Partially correct | 787 ms | 496 KB | Output is partially correct |
74 | Partially correct | 817 ms | 500 KB | Output is partially correct |
75 | Partially correct | 795 ms | 492 KB | Output is partially correct |
76 | Partially correct | 686 ms | 496 KB | Output is partially correct |
77 | Partially correct | 749 ms | 488 KB | Output is partially correct |
78 | Partially correct | 764 ms | 492 KB | Output is partially correct |
79 | Partially correct | 830 ms | 492 KB | Output is partially correct |
80 | Partially correct | 790 ms | 500 KB | Output is partially correct |
81 | Partially correct | 752 ms | 488 KB | Output is partially correct |
82 | Partially correct | 757 ms | 344 KB | Output is partially correct |