답안 #1014266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014266 2024-07-04T15:42:10 Z JakobZorz 가장 긴 여행 (IOI23_longesttrip) C++17
30 / 100
839 ms 1368 KB
#include"longesttrip.h"
#include<iostream>
using namespace std;

int n;
vector<int>nodes[500];

vector<int>longest_trip(int N,int D){
    n=N;
    for(int i=0;i<n;i++)
        nodes[i].clear();
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(are_connected({i},{j})){
                nodes[i].push_back(j);
                nodes[j].push_back(i);
                //cout<<"CONN "<<i<<" "<<j<<"\n";
            }
        }
    }
    vector<int>res={0};
    vector<bool>vis(n);
    vis[0]=true;
    while(true){
        int node=res.back();
        //cout<<"VIS "<<node<<"\n";
        for(int ne:nodes[node])
            if(!vis[ne]){
                res.push_back(ne);
                break;
            }
        vis[res.back()]=true;
        if(node==res.back())
            break;
    }
    // all unvisited are strongly connected
    /*for(int i=0;i<(int)res.size();i++){
        for(int ne:nodes[res[i]]){
            if(!vis[ne]){
                vector<int>res2;
                for(int j=0;j<n;j++)
                    if(!vis[j])
                        res2.push_back(j);
                for(int j=i;j<(int)res.size();j++)
                    res2.push_back(res[j]);
                for(int j=0;j<i;j++)
                    res2.push_back(res[j]);
                return res2;
            }
        }
    }*/
    vector<int>res2;
    for(int j=0;j<n;j++)
        if(!vis[j])
            res2.push_back(j);
    if(res.size()>res2.size())
        return res;
    else
        return res2;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 187 ms 1076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 27 ms 344 KB Output is correct
3 Correct 142 ms 344 KB Output is correct
4 Correct 379 ms 736 KB Output is correct
5 Correct 790 ms 1040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 15 ms 344 KB Output is correct
3 Correct 145 ms 344 KB Output is correct
4 Correct 372 ms 344 KB Output is correct
5 Correct 796 ms 968 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 596 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 162 ms 448 KB Output is correct
4 Correct 419 ms 468 KB Output is correct
5 Correct 839 ms 1172 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 19 ms 344 KB Output is correct
8 Correct 137 ms 448 KB Output is correct
9 Correct 307 ms 716 KB Output is correct
10 Correct 773 ms 752 KB Output is correct
11 Correct 677 ms 852 KB Output is correct
12 Correct 764 ms 900 KB Output is correct
13 Correct 767 ms 896 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 7 ms 344 KB Output is correct
16 Correct 46 ms 340 KB Output is correct
17 Correct 86 ms 344 KB Output is correct
18 Correct 128 ms 344 KB Output is correct
19 Correct 229 ms 632 KB Output is correct
20 Correct 283 ms 724 KB Output is correct
21 Correct 813 ms 1068 KB Output is correct
22 Correct 734 ms 848 KB Output is correct
23 Correct 831 ms 916 KB Output is correct
24 Correct 792 ms 1308 KB Output is correct
25 Correct 8 ms 344 KB Output is correct
26 Correct 7 ms 344 KB Output is correct
27 Correct 25 ms 344 KB Output is correct
28 Correct 28 ms 344 KB Output is correct
29 Correct 31 ms 340 KB Output is correct
30 Correct 181 ms 1112 KB Output is correct
31 Correct 204 ms 344 KB Output is correct
32 Correct 211 ms 344 KB Output is correct
33 Correct 292 ms 344 KB Output is correct
34 Correct 299 ms 712 KB Output is correct
35 Correct 288 ms 848 KB Output is correct
36 Correct 756 ms 1128 KB Output is correct
37 Correct 810 ms 1256 KB Output is correct
38 Correct 788 ms 1196 KB Output is correct
39 Correct 761 ms 1308 KB Output is correct
40 Correct 779 ms 1196 KB Output is correct
41 Correct 788 ms 960 KB Output is correct
42 Correct 805 ms 760 KB Output is correct
43 Correct 785 ms 812 KB Output is correct
44 Correct 707 ms 1176 KB Output is correct
45 Correct 9 ms 344 KB Output is correct
46 Correct 9 ms 344 KB Output is correct
47 Correct 23 ms 344 KB Output is correct
48 Correct 24 ms 344 KB Output is correct
49 Correct 21 ms 344 KB Output is correct
50 Correct 177 ms 344 KB Output is correct
51 Correct 175 ms 344 KB Output is correct
52 Correct 172 ms 344 KB Output is correct
53 Correct 280 ms 600 KB Output is correct
54 Correct 327 ms 600 KB Output is correct
55 Correct 306 ms 716 KB Output is correct
56 Correct 803 ms 848 KB Output is correct
57 Correct 798 ms 812 KB Output is correct
58 Correct 821 ms 924 KB Output is correct
59 Correct 758 ms 960 KB Output is correct
60 Correct 725 ms 1200 KB Output is correct
61 Correct 818 ms 1016 KB Output is correct
62 Correct 795 ms 784 KB Output is correct
63 Correct 822 ms 1368 KB Output is correct
64 Correct 784 ms 1208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 27 ms 344 KB Output is correct
3 Partially correct 116 ms 600 KB Output is partially correct
4 Partially correct 416 ms 344 KB Output is partially correct
5 Partially correct 808 ms 700 KB Output is partially correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -