답안 #747941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747941 2023-05-25T08:00:06 Z saayan007 City Mapping (NOI18_citymapping) C++17
0 / 100
1 ms 724 KB
#include "bits/stdc++.h"
#include "citymapping.h"
using namespace std;
using ll = long long;
#define eb emplace_back
#define nl endl

void find_roads(int N, int Q, int A[], int B[], int W[]) {
    deque<int> path;
    vector<int> dist[N + 1];
    for(int i = 2; i <= N; ++i) {
        int d = get_distance(1, i);
        dist[d].eb(i);
    }

    int p = 1;
    for(int i = 1; i <= N; ++i) {
        if((int) dist[i].size() < 2) {
            p = i;
            break;
        }
    }

    path.eb(1);
    for(int i = 1; i < p; ++i) {
        int a = dist[i][0], b = dist[i][1];
        if(get_distance(a, path.back()) == 1) swap(a, b);
        path.emplace_front(a); path.eb(b);
    }
    for(int i = p; i <= N; ++i) {
        if((int) dist[i].size() == 0) continue;
        int a = dist[i][0];
        if(get_distance(a, path.back()) == 1) path.eb(a);
        else path.emplace_front(a);
    }

    /* int a = dist[p][0]; */

    /* if(get_distance(a, path.back()) == 1) */
    /*     for(int i = p; i < N && (int)dist[i].size() != 0; ++i) */
    /*         path.eb(dist[i][0]); */
    /* else */
    /*     for(int i = p; i < N && (int)dist[i].size() != 0; ++i) */
    /*         path.emplace_front(dist[i][0]); */

    for(int i = 0; i < N; ++i) {
        A[i] = path[i], B[i] = path[i + 1], W[i] = 1;
    }
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Correct: 1535 out of 500000 queries used.
2 Runtime error 1 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Correct: 1535 out of 500000 queries used.
2 Runtime error 1 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Correct: 1909 out of 12000 queries used.
2 Incorrect 1 ms 468 KB Reported list of edges differ from actual.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Correct: 1909 out of 12000 queries used.
2 Incorrect 1 ms 468 KB Reported list of edges differ from actual.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Correct: 1535 out of 500000 queries used.
2 Runtime error 1 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -