답안 #1074121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074121 2024-08-25T08:09:38 Z TheQuantiX 기지국 (IOI20_stations) C++17
0 / 100
630 ms 940 KB
#include <bits/stdc++.h>
#include "stations.h"

using namespace std;
using ll = long long;

ll n, m, q, k, x, y, a, b, c;
vector<ll> G[1000];

void dfs(ll x, ll p, ll depth, ll &timer, vector<int> &ans) {
    // cout << x << ' ' << p << ' ' << depth << ' ' << timer << endl;
    if (depth % 2 == 0) {
        ans[x] = timer;
    }
    timer++;
    for (int i : G[x]) {
        if (i != p) {
            dfs(i, x, depth + 1, timer, ans);
        }
    }
    if (depth % 2 == 1) {
        ans[x] = timer;
    }
    timer++;
}

vector<int> label(int N, int K, vector<int> u, vector<int> v) {
    n = N;
    k = K;
    for (int i = 0; i < 1000; i++) {
        G[i].clear();
    }
    for (int i = 0; i < u.size(); i++) {
        G[u[i]].push_back(v[i]);
        G[v[i]].push_back(u[i]);
    }
    vector<int> ans(n);
    ll timer = 0;
    dfs(0, -1, 0, timer, ans);
    // for (int i = 0; i < n; i++) {
    //     cout << ans[i] << ' ';
    // }
    // cout << endl;
    return ans;
}

int find_next_station(int s, int t, vector<int> c) {
    // cout << s << ' ' << t << '\n';
    // for (int i = 0; i < c.size(); i++) {
    //     cout << c[i] << ' ';
    // }
    // cout << '\n';
    if (s > c[c.size() - 1]) {
        for (int i = 1; i < c.size(); i++) {
            if (c[i] > t) {
                return c[i - 1];
            }
        }
        if (s > t) {
            return c[c.size() - 1];
        }
        return c[0];
    }
    if (s > t) {
        return c[c.size() - 1];
    }
    for (int i = 0; i < c.size() - 1; i++) {
        if (c[i] > t) {
            return c[i];
        }
    }
    return c[c.size() - 1];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i = 0; i < u.size(); i++) {
      |                     ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:54:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for (int i = 1; i < c.size(); i++) {
      |                         ~~^~~~~~~~~~
stations.cpp:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for (int i = 0; i < c.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 592 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 378 ms 940 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 630 ms 684 KB Output is correct
2 Incorrect 442 ms 684 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 360 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -