답안 #1059899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059899 2024-08-15T08:58:26 Z dozer 가장 긴 여행 (IOI23_longesttrip) C++17
30 / 100
235 ms 604 KB
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
#define sp " " 
#define endl "\n"
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define LL node * 2
#define RR node * 2 + 1
#define ll long long

const int modulo = 1e9 + 7;
const ll INF = 2e18 + 7;


vector<int> longest_trip(int N, int D)
{
    vector<int> ans;
    set<int> undone;
    for (int i = 1; i < N; i++) undone.insert(i);
    ans.pb(0);
    while(!undone.empty()){
        vector<int> tmp(undone.begin(), undone.end());
        vector<int> a = {ans.back()};
        int go = -1;
        for (auto j : tmp){
            vector<int> b = {j};
            if (are_connected(a, b)){
                go = j;
                break;
            }
        }

        if (go == -1){
            int sz = ans.size();
            if (sz * 2 >= N){
                return ans;
            }
            return tmp;
        }
        else{
            ans.pb(go);
            undone.erase(go);
        }
    }
    return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 8 ms 344 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 7 ms 344 KB Output is correct
5 Correct 7 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 7 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 8 ms 344 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
9 Correct 8 ms 344 KB Output is correct
10 Correct 8 ms 600 KB Output is correct
11 Correct 6 ms 344 KB Output is correct
12 Correct 9 ms 480 KB Output is correct
13 Correct 6 ms 344 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 6 ms 344 KB Output is correct
16 Correct 8 ms 344 KB Output is correct
17 Correct 7 ms 344 KB Output is correct
18 Correct 6 ms 344 KB Output is correct
19 Correct 6 ms 344 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 7 ms 344 KB Output is correct
22 Correct 7 ms 472 KB Output is correct
23 Correct 7 ms 344 KB Output is correct
24 Correct 7 ms 344 KB Output is correct
25 Correct 6 ms 344 KB Output is correct
26 Correct 6 ms 344 KB Output is correct
27 Correct 9 ms 344 KB Output is correct
28 Correct 7 ms 344 KB Output is correct
29 Correct 7 ms 344 KB Output is correct
30 Correct 8 ms 344 KB Output is correct
31 Correct 33 ms 344 KB Output is correct
32 Correct 52 ms 344 KB Output is correct
33 Correct 8 ms 344 KB Output is correct
34 Correct 10 ms 344 KB Output is correct
35 Correct 26 ms 600 KB Output is correct
36 Correct 8 ms 344 KB Output is correct
37 Correct 31 ms 344 KB Output is correct
38 Correct 130 ms 600 KB Output is correct
39 Correct 177 ms 344 KB Output is correct
40 Correct 212 ms 344 KB Output is correct
41 Correct 184 ms 444 KB Output is correct
42 Correct 212 ms 460 KB Output is correct
43 Correct 235 ms 592 KB Output is correct
44 Correct 217 ms 456 KB Output is correct
45 Correct 4 ms 344 KB Output is correct
46 Correct 6 ms 344 KB Output is correct
47 Correct 7 ms 344 KB Output is correct
48 Correct 6 ms 344 KB Output is correct
49 Correct 10 ms 344 KB Output is correct
50 Correct 6 ms 344 KB Output is correct
51 Correct 28 ms 344 KB Output is correct
52 Correct 36 ms 344 KB Output is correct
53 Correct 8 ms 344 KB Output is correct
54 Correct 9 ms 344 KB Output is correct
55 Correct 18 ms 600 KB Output is correct
56 Correct 7 ms 344 KB Output is correct
57 Correct 23 ms 344 KB Output is correct
58 Correct 93 ms 432 KB Output is correct
59 Correct 134 ms 452 KB Output is correct
60 Correct 140 ms 344 KB Output is correct
61 Correct 205 ms 604 KB Output is correct
62 Correct 172 ms 448 KB Output is correct
63 Correct 158 ms 460 KB Output is correct
64 Correct 221 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 8 ms 344 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -