답안 #747935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747935 2023-05-25T07:56:38 Z saayan007 City Mapping (NOI18_citymapping) C++17
0 / 100
54 ms 8276 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[]) {
    ll dist[N + 1][N + 1];
    for(int i = 1; i <= N; ++i) {
        dist[i][i] = 0;
        for(int j = i + 1; j <= N; ++j) {
            dist[i][j] = dist[j][i] = abs(get_distance(i, j));
        }
    }
    /* for(int i = 1; i <= N; ++i) { */
    /*     for(int j = 1; j <= N; ++j) { */
    /*         cout << dist[i][j] << ' '; */
    /*     } */
    /*     cout << nl; */
    /* } */
    /* cout << nl; */

    vector<pair<int, ll>> adj[N + 1];
    for(int i = 1; i <= N; ++i) {
        int x = (i == 1 ? 2 : 1);
        for(int j = 1; j <= N; ++j) {
            if(j == i) continue;
            if(dist[i][j] < dist[i][x]) x = j;
        }
        adj[i].eb(x, dist[i][x]);

        int y = 0;
        for(int j = 1; j <= N; ++j) {
            if(j == i || j == x) continue;
            if(dist[i][j] == dist[i][x] + dist[x][j]) continue;
            if(y == 0 || dist[i][j] < dist[i][y]) y = j;
        }
        if(y == 0) continue;
        adj[i].eb(y, dist[i][y]);
        continue;

        int z = 0;
        for(int j = 1; j <= N; ++j) {
            if(j == i || j == x || j == y) continue;
            if(dist[i][j] == dist[i][x] + dist[x][j]) continue;
            if(dist[i][j] == dist[i][y] + dist[y][j]) continue;
            if(z == 0 || dist[i][j] < dist[i][z]) z = j;
        }
        if(z == 0) continue;
        adj[i].eb(z, dist[i][z]);
    }

    int ptr = 0;
    for(int i = 1; i <= N; ++i) {
        for(auto [j, w] : adj[i]) {
            if(j <= i) continue;
            A[ptr] = i; B[ptr] = j; W[ptr] = w;
            ++ptr;
            /* cout << i << ' ' << j << ' ' << w << nl; */
        }
    }
    return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 8268 KB Correct: 498501 out of 500000 queries used.
2 Incorrect 45 ms 8276 KB Reported list of edges differ from actual.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 8268 KB Correct: 498501 out of 500000 queries used.
2 Incorrect 45 ms 8276 KB Reported list of edges differ from actual.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 8020 KB Too many calls to get_distance().
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 8020 KB Too many calls to get_distance().
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 8268 KB Correct: 498501 out of 500000 queries used.
2 Incorrect 45 ms 8276 KB Reported list of edges differ from actual.
3 Halted 0 ms 0 KB -