답안 #401215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
401215 2021-05-09T15:51:41 Z dxz05 기지국 (IOI20_stations) C++14
5 / 100
1196 ms 696 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 = 0;
    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 696 ms 648 KB Output is correct
2 Correct 543 ms 520 KB Output is correct
3 Correct 929 ms 584 KB Output is correct
4 Correct 816 ms 528 KB Output is correct
5 Correct 714 ms 540 KB Output is correct
6 Correct 608 ms 520 KB Output is correct
7 Correct 602 ms 528 KB Output is correct
8 Correct 3 ms 608 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 580 ms 656 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 561 ms 528 KB Output is correct
2 Correct 618 ms 644 KB Output is correct
3 Correct 1196 ms 528 KB Output is correct
4 Correct 733 ms 520 KB Output is correct
5 Correct 699 ms 648 KB Output is correct
6 Correct 503 ms 640 KB Output is correct
7 Correct 473 ms 504 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 6 ms 600 KB Output is correct
10 Correct 2 ms 616 KB Output is correct
11 Incorrect 663 ms 532 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1073 ms 400 KB Output is correct
2 Correct 725 ms 532 KB Output is correct
3 Correct 650 ms 588 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 6 ms 600 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Incorrect 623 ms 528 KB Wrong query response.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 553 ms 624 KB Output is correct
2 Correct 577 ms 532 KB Output is correct
3 Correct 1041 ms 520 KB Output is correct
4 Correct 703 ms 696 KB Output is correct
5 Correct 536 ms 400 KB Output is correct
6 Correct 486 ms 648 KB Output is correct
7 Correct 506 ms 528 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Incorrect 579 ms 516 KB Wrong query response.
12 Halted 0 ms 0 KB -