Submission #747952

# Submission time Handle Problem Language Result Execution time Memory
747952 2023-05-25T08:07:48 Z saayan007 City Mapping (NOI18_citymapping) C++17
13 / 100
1 ms 852 KB
#include "bits/stdc++.h"
#include "citymapping.h"
using namespace std;
using ll = long long;
#define eb emplace_back
#define nl endl
#define qry get_distance

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

    /* for(int i = 1; i < N; ++i) { */
        /* cout << i << ": "; */
        /* for(int j : node[i]) cout << j << ' '; */
        /* cout << nl; */
    /* } */

    path.eb(1);
    for(int i = 1; i <= N; ++i) {
        /* for(int x : path) cout << x << ' '; */
        /* cout << nl; */
        if((int)node[i].size() == 2) {
            int a = node[i][0], b = node[i][1];
            if(qry(a, path.back()) == 1) swap(a, b);
            path.emplace_front(a); path.eb(b);
        }
        else if((int) node[i].size() == 1) {
            int a = node[i][0];
            if(qry(a, path.back()) == 1) path.eb(a);
            else path.emplace_front(a);
        }
    }
    /* for(int x : path) cout << x << ' '; */
    /* cout << nl; */

    for(int i = 0; i < N - 1; ++i) {
        /* cout << path[i] << ' ' << path[i + 1] << ' ' << W[i] << nl; */
        A[i] = path[i], B[i] = path[i + 1], W[i] = 1;
    }
	return;
}
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Correct: 1909 out of 12000 queries used.
2 Correct 1 ms 504 KB Correct: 1764 out of 12000 queries used.
3 Correct 1 ms 468 KB Correct: 1682 out of 12000 queries used.
4 Correct 1 ms 460 KB Correct: 1667 out of 12000 queries used.
5 Correct 1 ms 472 KB Correct: 1807 out of 12000 queries used.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Correct: 1909 out of 12000 queries used.
2 Correct 1 ms 504 KB Correct: 1764 out of 12000 queries used.
3 Correct 1 ms 468 KB Correct: 1682 out of 12000 queries used.
4 Correct 1 ms 460 KB Correct: 1667 out of 12000 queries used.
5 Correct 1 ms 472 KB Correct: 1807 out of 12000 queries used.
6 Runtime error 1 ms 852 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -