답안 #878562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878562 2023-11-24T17:40:49 Z thinknoexit 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
778 ms 596 KB
#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
using ll = long long;
int n, d;
bool adj[256][256];
vector<int> longest_trip(int N, int D) {
    n = N;
    d = D;
    memset(adj, 0, sizeof adj);
    for (int i = 0;i < n;i++) {
        for (int j = i + 1;j < n;j++) {
            adj[i][j] = adj[j][i] = are_connected({ i }, { j });
        }
    }
    queue<int> q;
    deque<int> ans;
    ans.push_back(0);
    for (int i = 1;i < n;i++) {
        if (adj[0][i]) {
            ans.push_back(i);
            break;
        }
    }
    for (int i = 1;i < n;i++) {
        if (ans.back() != i) q.push(i);
    }
    while (!q.empty()) {
        if (adj[ans.back()][q.front()]) {
            ans.push_back(q.front());
            q.pop();
        }
        else {
            int v = ans.back();
            ans.pop_back();
            int v2 = ans.back();
            ans.pop_back();
            ans.push_back(q.front());
            q.pop();
            ans.push_back(v2);
            ans.push_back(v);
        }
    }
    vector<int> Ans;
    while (!ans.empty()) Ans.push_back(ans.front()), ans.pop_front();
    return Ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 26 ms 344 KB Output is correct
3 Correct 117 ms 344 KB Output is correct
4 Correct 366 ms 476 KB Output is correct
5 Correct 707 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 24 ms 344 KB Output is correct
3 Correct 114 ms 344 KB Output is correct
4 Correct 353 ms 476 KB Output is correct
5 Correct 749 ms 476 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 117 ms 344 KB Output is correct
9 Correct 308 ms 476 KB Output is correct
10 Correct 746 ms 476 KB Output is correct
11 Correct 739 ms 472 KB Output is correct
12 Correct 745 ms 592 KB Output is correct
13 Correct 724 ms 472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 117 ms 344 KB Output is correct
4 Correct 381 ms 476 KB Output is correct
5 Correct 752 ms 472 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 24 ms 596 KB Output is correct
8 Correct 128 ms 344 KB Output is correct
9 Correct 290 ms 592 KB Output is correct
10 Correct 709 ms 476 KB Output is correct
11 Correct 713 ms 476 KB Output is correct
12 Correct 723 ms 476 KB Output is correct
13 Correct 719 ms 472 KB Output is correct
14 Incorrect 0 ms 344 KB Incorrect
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Partially correct 120 ms 344 KB Output is partially correct
4 Partially correct 326 ms 592 KB Output is partially correct
5 Partially correct 720 ms 472 KB Output is partially correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 28 ms 344 KB Output is correct
8 Partially correct 118 ms 344 KB Output is partially correct
9 Partially correct 269 ms 592 KB Output is partially correct
10 Partially correct 743 ms 480 KB Output is partially correct
11 Partially correct 763 ms 480 KB Output is partially correct
12 Partially correct 778 ms 476 KB Output is partially correct
13 Partially correct 705 ms 476 KB Output is partially correct
14 Incorrect 0 ms 340 KB Incorrect
15 Halted 0 ms 0 KB -