Submission #1065160

# Submission time Handle Problem Language Result Execution time Memory
1065160 2024-08-19T01:43:02 Z vjudge1 Longest Trip (IOI23_longesttrip) C++17
70 / 100
99 ms 968 KB
#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[256];
vector<int>path,yettovis;
int findit(vector<int>v,int n){
    if(v.size()==1)return v[0];
    vector<int>v1,v2;
    for(auto i:v)
        v1.push_back(i),
        swap(v1,v2);
    if(are_connected(v1,{n}))
        return findit(v1,n);
    return findit(v2,n);
}
void dfs2(int n){
    path.push_back(n);
    yettovis.erase(lower_bound(yettovis.begin(),yettovis.end(),n));
    if(yettovis.empty())return;
    if(are_connected(yettovis,{n}))
        return dfs2(findit(yettovis,n));
}
vector<int> longest_trip(int N, int D){
    vector<int>cc1{0},cc2;
    for(int i=1;i<N;i++)
        if(are_connected(cc1,{i})) {
            cc1.push_back(i);
        } else cc2.push_back(i);
    if(cc2.size()&&!are_connected(cc1,cc2)){
        return cc1.size()<cc2.size()?cc2:cc1;
    }
    path.clear();
    yettovis.clear();
    for(int i=0;i<N;i++)
        yettovis.push_back(i);
    dfs2(0);
    if(path.size()==N)
        return path;
    while(1) {
        if(are_connected(yettovis,{path[0]})) {
            int x=findit(yettovis,path[0]);
            vector<int>v2;
            for(auto i:yettovis)
                if(i-x)v2.push_back(i);
            v2.push_back(x);
            for(auto i:path)
                v2.push_back(i);
            return v2;
        }
        int x=path[0];
        path.erase(path.begin());
        path.push_back(x);
    }
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:37:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     if(path.size()==N)
      |        ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 20 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 344 KB Output is correct
2 Correct 17 ms 344 KB Output is correct
3 Correct 36 ms 600 KB Output is correct
4 Correct 59 ms 600 KB Output is correct
5 Correct 67 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Correct 29 ms 344 KB Output is correct
4 Correct 67 ms 452 KB Output is correct
5 Correct 82 ms 564 KB Output is correct
6 Correct 11 ms 344 KB Output is correct
7 Correct 17 ms 344 KB Output is correct
8 Correct 43 ms 344 KB Output is correct
9 Correct 47 ms 344 KB Output is correct
10 Correct 82 ms 508 KB Output is correct
11 Correct 82 ms 344 KB Output is correct
12 Correct 76 ms 452 KB Output is correct
13 Correct 71 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 32 ms 344 KB Output is correct
4 Correct 53 ms 344 KB Output is correct
5 Correct 70 ms 344 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 14 ms 344 KB Output is correct
8 Correct 31 ms 344 KB Output is correct
9 Correct 52 ms 344 KB Output is correct
10 Correct 76 ms 600 KB Output is correct
11 Correct 99 ms 768 KB Output is correct
12 Correct 69 ms 600 KB Output is correct
13 Correct 73 ms 560 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 7 ms 344 KB Output is correct
16 Correct 21 ms 344 KB Output is correct
17 Correct 25 ms 344 KB Output is correct
18 Correct 31 ms 344 KB Output is correct
19 Correct 45 ms 344 KB Output is correct
20 Correct 52 ms 876 KB Output is correct
21 Correct 66 ms 344 KB Output is correct
22 Correct 71 ms 600 KB Output is correct
23 Correct 75 ms 344 KB Output is correct
24 Correct 67 ms 568 KB Output is correct
25 Correct 6 ms 344 KB Output is correct
26 Correct 6 ms 344 KB Output is correct
27 Correct 6 ms 344 KB Output is correct
28 Correct 8 ms 344 KB Output is correct
29 Correct 6 ms 344 KB Output is correct
30 Correct 6 ms 344 KB Output is correct
31 Correct 6 ms 344 KB Output is correct
32 Correct 6 ms 344 KB Output is correct
33 Correct 7 ms 344 KB Output is correct
34 Correct 7 ms 344 KB Output is correct
35 Correct 9 ms 344 KB Output is correct
36 Correct 12 ms 344 KB Output is correct
37 Correct 16 ms 712 KB Output is correct
38 Correct 10 ms 344 KB Output is correct
39 Correct 13 ms 344 KB Output is correct
40 Correct 9 ms 344 KB Output is correct
41 Correct 8 ms 344 KB Output is correct
42 Correct 8 ms 344 KB Output is correct
43 Correct 9 ms 600 KB Output is correct
44 Correct 8 ms 344 KB Output is correct
45 Correct 16 ms 344 KB Output is correct
46 Correct 15 ms 344 KB Output is correct
47 Correct 21 ms 340 KB Output is correct
48 Correct 17 ms 344 KB Output is correct
49 Correct 19 ms 344 KB Output is correct
50 Correct 46 ms 344 KB Output is correct
51 Correct 30 ms 344 KB Output is correct
52 Correct 30 ms 456 KB Output is correct
53 Correct 48 ms 344 KB Output is correct
54 Correct 47 ms 344 KB Output is correct
55 Correct 45 ms 600 KB Output is correct
56 Correct 77 ms 568 KB Output is correct
57 Correct 78 ms 344 KB Output is correct
58 Correct 55 ms 812 KB Output is correct
59 Correct 65 ms 968 KB Output is correct
60 Correct 61 ms 540 KB Output is correct
61 Correct 57 ms 600 KB Output is correct
62 Correct 53 ms 680 KB Output is correct
63 Correct 46 ms 640 KB Output is correct
64 Correct 47 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 19 ms 344 KB Output is correct
3 Correct 41 ms 344 KB Output is correct
4 Partially correct 59 ms 344 KB Output is partially correct
5 Partially correct 81 ms 592 KB Output is partially correct
6 Correct 13 ms 344 KB Output is correct
7 Correct 19 ms 344 KB Output is correct
8 Correct 45 ms 344 KB Output is correct
9 Partially correct 57 ms 600 KB Output is partially correct
10 Partially correct 79 ms 716 KB Output is partially correct
11 Partially correct 77 ms 344 KB Output is partially correct
12 Partially correct 81 ms 848 KB Output is partially correct
13 Partially correct 89 ms 592 KB Output is partially correct
14 Correct 7 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 25 ms 344 KB Output is correct
17 Correct 28 ms 344 KB Output is correct
18 Correct 30 ms 344 KB Output is correct
19 Partially correct 43 ms 344 KB Output is partially correct
20 Partially correct 53 ms 344 KB Output is partially correct
21 Correct 7 ms 344 KB Output is correct
22 Correct 7 ms 344 KB Output is correct
23 Correct 7 ms 344 KB Output is correct
24 Correct 9 ms 344 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 7 ms 344 KB Output is correct
27 Correct 6 ms 344 KB Output is correct
28 Correct 6 ms 344 KB Output is correct
29 Correct 9 ms 344 KB Output is correct
30 Correct 9 ms 344 KB Output is correct
31 Correct 7 ms 344 KB Output is correct
32 Correct 12 ms 344 KB Output is correct
33 Correct 14 ms 344 KB Output is correct
34 Correct 18 ms 344 KB Output is correct
35 Correct 19 ms 344 KB Output is correct
36 Correct 16 ms 344 KB Output is correct
37 Partially correct 59 ms 344 KB Output is partially correct
38 Partially correct 29 ms 344 KB Output is partially correct
39 Partially correct 29 ms 344 KB Output is partially correct
40 Partially correct 49 ms 344 KB Output is partially correct
41 Partially correct 42 ms 344 KB Output is partially correct
42 Partially correct 51 ms 344 KB Output is partially correct
43 Partially correct 72 ms 600 KB Output is partially correct
44 Partially correct 94 ms 708 KB Output is partially correct
45 Partially correct 72 ms 532 KB Output is partially correct
46 Partially correct 72 ms 344 KB Output is partially correct
47 Correct 11 ms 344 KB Output is correct
48 Correct 11 ms 344 KB Output is correct
49 Correct 10 ms 344 KB Output is correct
50 Correct 9 ms 344 KB Output is correct
51 Correct 9 ms 344 KB Output is correct
52 Correct 9 ms 344 KB Output is correct
53 Correct 9 ms 344 KB Output is correct
54 Correct 10 ms 344 KB Output is correct
55 Correct 8 ms 344 KB Output is correct
56 Correct 11 ms 344 KB Output is correct
57 Correct 14 ms 464 KB Output is correct
58 Correct 11 ms 344 KB Output is correct
59 Correct 11 ms 344 KB Output is correct
60 Correct 8 ms 344 KB Output is correct
61 Correct 11 ms 344 KB Output is correct
62 Partially correct 74 ms 620 KB Output is partially correct
63 Partially correct 59 ms 784 KB Output is partially correct
64 Partially correct 45 ms 576 KB Output is partially correct
65 Partially correct 55 ms 552 KB Output is partially correct
66 Partially correct 63 ms 344 KB Output is partially correct
67 Partially correct 52 ms 600 KB Output is partially correct
68 Partially correct 52 ms 600 KB Output is partially correct
69 Partially correct 51 ms 492 KB Output is partially correct
70 Partially correct 67 ms 592 KB Output is partially correct
71 Partially correct 74 ms 888 KB Output is partially correct
72 Partially correct 74 ms 600 KB Output is partially correct
73 Partially correct 48 ms 600 KB Output is partially correct
74 Partially correct 50 ms 596 KB Output is partially correct
75 Partially correct 50 ms 768 KB Output is partially correct
76 Partially correct 46 ms 568 KB Output is partially correct
77 Partially correct 82 ms 808 KB Output is partially correct
78 Partially correct 76 ms 800 KB Output is partially correct
79 Partially correct 78 ms 568 KB Output is partially correct
80 Partially correct 53 ms 344 KB Output is partially correct
81 Partially correct 46 ms 600 KB Output is partially correct
82 Partially correct 52 ms 600 KB Output is partially correct