답안 #401173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
401173 2021-05-09T14:11:18 Z dxz05 기지국 (IOI20_stations) C++14
5 / 100
1025 ms 764 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1011;

vector<int> g[MAXN];

int tin[MAXN], last[MAXN], timer = 0;
void dfs(int v, int p){
    tin[v] = last[v] = timer++;
    for (int u : g[v]){
        if (u != p){
            dfs(u, v);
            last[v] = last[u];
        }
    }
}

bool line = true, binary = true;

vector<int> label(int n, int k, vector<int> U, vector<int> V) {
    for (int i = 0; i < n; i++) g[i].clear();
    timer = 0;

    for (int i = 0; i < n - 1; i++){
        if (U[i] > V[i]) swap(U[i], V[i]);
        g[U[i]].push_back(V[i]);
        g[V[i]].push_back(U[i]);
        if (U[i] != i / 2 || V[i] != i + 1) binary = false;
    }

    int idx = -1;
    for (int i = 0; i < n; i++){
        if (g[i].size() > 2){
            line = false;
        }
        if (g[i].size() == 1) idx = i;
    }

    dfs(idx, -1);

	vector<int> labels(n, 0);
	for (int i = 0; i < n; i++){
        if (line){
            labels[i] = tin[i];
            continue;
        }

        if (binary){
            labels[i] = i;
            continue;
        }

        labels[i] = tin[i] * 1000 + last[i];
	}

	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
    if (line){
        return (s < t ? s + 1 : s - 1);
    }
    if (binary){
        while (t > 0){
            int x = (t - 1) / 2;
            if (x == s) return t;
            t = x;
        }
        return (s - 1) / 2;
    }
    int ans = c[0];
    t /= 1000;
    for (int v : c){
        int x = v / 1000, y = v % 1000;
        if (x <= t && t <= y) ans = v;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 581 ms 544 KB Output is correct
2 Correct 559 ms 648 KB Output is correct
3 Correct 951 ms 528 KB Output is correct
4 Correct 786 ms 512 KB Output is correct
5 Correct 762 ms 644 KB Output is correct
6 Correct 501 ms 508 KB Output is correct
7 Correct 507 ms 532 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 6 ms 728 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 607 ms 588 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 730 ms 528 KB Output is correct
2 Correct 479 ms 644 KB Output is correct
3 Correct 978 ms 400 KB Output is correct
4 Correct 815 ms 588 KB Output is correct
5 Correct 724 ms 656 KB Output is correct
6 Correct 601 ms 520 KB Output is correct
7 Correct 514 ms 516 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 6 ms 716 KB Output is correct
10 Correct 2 ms 728 KB Output is correct
11 Incorrect 676 ms 680 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1025 ms 500 KB Output is correct
2 Correct 679 ms 532 KB Output is correct
3 Correct 604 ms 528 KB Output is correct
4 Correct 3 ms 608 KB Output is correct
5 Correct 5 ms 600 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Incorrect 658 ms 516 KB Wrong query response.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 602 ms 512 KB Output is correct
2 Correct 604 ms 544 KB Output is correct
3 Correct 910 ms 528 KB Output is correct
4 Correct 721 ms 516 KB Output is correct
5 Correct 576 ms 400 KB Output is correct
6 Correct 511 ms 764 KB Output is correct
7 Correct 530 ms 656 KB Output is correct
8 Correct 3 ms 728 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
11 Incorrect 514 ms 584 KB Wrong query response.
12 Halted 0 ms 0 KB -