# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1007059 | 2024-06-24T11:16:25 Z | 3as8 | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 867 ms | 600 KB |
#include "longesttrip.h" #include<bits/stdc++.h> #define ll long long using namespace std; bool con[300][300]; bool vis[300]; bool bkVis[300]; ll n; ll l = 0; void dfs(ll startIndex, vector<int>& curr) { vis[startIndex] = true; curr.push_back(startIndex); bool in = false; for(int i = 0; i < n; i++) { if(con[startIndex][i] && !vis[i]) { dfs(i, curr); in = true; } } if(!in) l = startIndex; } std::vector<int> longest_trip(int N, int D) { n = N; for(int i = 0; i < n; i++) { for(int j = i + 1; j < n; j++) { con[i][j] = con[j][i] = are_connected({i}, {j}); } } ll mx = LLONG_MIN; vector<int> ans; for(int i = 0; i < n; i++) vis[i] = false; for(int i = 0; i < n; i++) { if(vis[i]) continue; for(int j = 0; j < n; j++) bkVis[j] = vis[j]; vector<int> curr; l = i; dfs(i, curr); for(int j = 0; j < n; j++) vis[j] = bkVis[j]; vector<int> curr2; dfs(l, curr2); if(curr2.size() > ans.size()) { ans = curr; } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 186 ms | 492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 20 ms | 344 KB | Output is correct |
3 | Correct | 144 ms | 344 KB | Output is correct |
4 | Correct | 403 ms | 592 KB | Output is correct |
5 | Correct | 808 ms | 488 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 20 ms | 344 KB | Output is correct |
3 | Correct | 124 ms | 344 KB | Output is correct |
4 | Correct | 364 ms | 344 KB | Output is correct |
5 | Correct | 867 ms | 492 KB | Output is correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 18 ms | 344 KB | Output is correct |
3 | Correct | 166 ms | 344 KB | Output is correct |
4 | Correct | 369 ms | 344 KB | Output is correct |
5 | Correct | 808 ms | 492 KB | Output is correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 344 KB | Output is correct |
2 | Correct | 26 ms | 344 KB | Output is correct |
3 | Partially correct | 141 ms | 344 KB | Output is partially correct |
4 | Partially correct | 393 ms | 344 KB | Output is partially correct |
5 | Partially correct | 765 ms | 600 KB | Output is partially correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |