답안 #1065154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065154 2024-08-19T01:29:20 Z vjudge1 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
1000 ms 1416 KB
#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[256];
bitset<256>vis;
void dfs(int n){
    if(vis[n])return;
    vis[n]=1;
    for(auto i:adj[n])
        dfs(i);
}
vector<int>path;
void dfs2(int n){
    path.push_back(n);
    vis[n]=1;
    for(auto i:adj[n])
        if(!vis[i])
            return dfs2(i);
}
mt19937 rng(1272842334);
vector<int> longest_trip(int N, int D){
    for(int i=0;i<N;i++)
        adj[i].clear();
    for(int i=1;i<N;i++) for(int j=i;j--;)
        if(are_connected({i},{j}))
            adj[i].push_back(j),
            adj[j].push_back(i);
    vis.reset();
    path.clear();
    int nod=rng()%N;
    dfs2(nod);
    if(path.size()==N)
        return path;
    while(1) {
        for(auto x:adj[path[0]])
            if(!vis[x]) {
                vector<int>v2;
                vis[x]=1;
                for(int i=0;i<N;i++)
                    if(!vis[i])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:32:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     if(path.size()==N)
      |        ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3085 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 20 ms 344 KB Output is correct
3 Correct 145 ms 452 KB Output is correct
4 Correct 401 ms 724 KB Output is correct
5 Correct 850 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Correct 146 ms 344 KB Output is correct
4 Correct 415 ms 460 KB Output is correct
5 Correct 850 ms 756 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 21 ms 344 KB Output is correct
8 Correct 130 ms 344 KB Output is correct
9 Correct 325 ms 848 KB Output is correct
10 Correct 892 ms 592 KB Output is correct
11 Correct 828 ms 1128 KB Output is correct
12 Correct 845 ms 1000 KB Output is correct
13 Correct 879 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 137 ms 344 KB Output is correct
4 Correct 429 ms 344 KB Output is correct
5 Correct 836 ms 1168 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 23 ms 344 KB Output is correct
8 Correct 136 ms 344 KB Output is correct
9 Correct 317 ms 600 KB Output is correct
10 Correct 880 ms 1196 KB Output is correct
11 Correct 864 ms 1100 KB Output is correct
12 Correct 837 ms 600 KB Output is correct
13 Correct 805 ms 1416 KB Output is correct
14 Execution timed out 3007 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Partially correct 164 ms 344 KB Output is partially correct
4 Partially correct 443 ms 732 KB Output is partially correct
5 Partially correct 814 ms 1204 KB Output is partially correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 28 ms 344 KB Output is correct
8 Partially correct 144 ms 600 KB Output is partially correct
9 Partially correct 328 ms 592 KB Output is partially correct
10 Partially correct 803 ms 1192 KB Output is partially correct
11 Partially correct 868 ms 1148 KB Output is partially correct
12 Partially correct 820 ms 1188 KB Output is partially correct
13 Partially correct 839 ms 1172 KB Output is partially correct
14 Execution timed out 3053 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -