Submission #333459

# Submission time Handle Problem Language Result Execution time Memory
333459 2020-12-06T05:58:37 Z sabamaku Stations (IOI20_stations) C++14
10 / 100
890 ms 1120 KB
#include "stations.h"
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;

int cnt;

pair <int,int> d[20005];

vector <int> vi[2005];

void dfs(int x,int p){
    d[x].f = cnt++;
    for (int j = 0; j < vi[x].size(); j++){
        int to = vi[x][j];
        if (to == p) continue;
        dfs(to,x);
    }
    d[x].s = cnt++;
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<int> labels;
    for (int i = 0; i < 1001; i++){
        vi[i].clear();
        d[i].f = 0;
        d[i].f = d[i].s;
    }
    for (int i = 0; i < u.size(); i++){
        vi[u[i]].push_back(v[i]);
        vi[v[i]].push_back(u[i]);
    }
    cnt = 0;
    dfs(0,0);
    for (int i = 0; i < n; i++)
        labels.push_back((d[i].f) * 1000 + d[i].s);
    
    return labels;
}
int find_next_station(int s, int t, vector<int> v1) {
    if (s / 1000 < t / 1000){
        for (int i = 1; i < v1.size();i++)
            if (t / 1000 >= v1[i] / 1000 && v1[i] % 1000 >= t % 1000) return v1[i];
    }
    return v1[0];
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int j = 0; j < vi[x].size(); j++){
      |                     ~~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < u.size(); i++){
      |                     ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int i = 1; i < v1.size();i++)
      |                         ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=7014
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 492 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1991
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 636 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=12, label=1750970
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 863 ms 792 KB Output is correct
2 Correct 679 ms 912 KB Output is correct
3 Correct 567 ms 912 KB Output is correct
4 Correct 3 ms 864 KB Output is correct
5 Correct 5 ms 864 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 576 ms 1120 KB Output is correct
8 Correct 890 ms 864 KB Output is correct
9 Correct 663 ms 736 KB Output is correct
10 Correct 581 ms 912 KB Output is correct
11 Correct 5 ms 920 KB Output is correct
12 Correct 7 ms 912 KB Output is correct
13 Correct 5 ms 736 KB Output is correct
14 Correct 4 ms 864 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 509 ms 864 KB Output is correct
17 Correct 506 ms 736 KB Output is correct
18 Correct 502 ms 1052 KB Output is correct
19 Correct 492 ms 920 KB Output is correct
20 Correct 515 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 536 ms 1052 KB Wrong query response.
2 Halted 0 ms 0 KB -