Submission #336025

# Submission time Handle Problem Language Result Execution time Memory
336025 2020-12-14T13:46:41 Z richyrich Stations (IOI20_stations) C++17
5 / 100
978 ms 1900 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4+3;
const int inf = 1e9;
int ans[N], timer, vis[N];
vector<vector<int>> adj(N);
void dfs(int x, int par) {
    vis[x] = 1;
    for(int y : adj[x]) {
        if(y==par || vis[y]) continue;
        dfs(y, x);
    }
    ans[x] = timer;
    timer++;
    return;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    timer = 0;
    for(int i = 0; i < n; i++) {
        adj[i].clear();
        vis[i] = 0;
        ans[i] = 0;
    }
    for(int i = 0; i < u.size(); i++) {
        adj[u[i]].push_back(v[i]), adj[v[i]].push_back(u[i]);
    }
    for(int i = 0; i < n; i++) {
        if(adj[i].size()==1) {
            dfs(i, -1);
            break;
        }
    }
    std::vector<int> labels(n);
    for(int i = 0; i < n; i++) labels[i] = ans[i];
    return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    int n = c.size();
    if(s > t) return c[0];
    else return c[n-1];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0; i < u.size(); i++) {
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 524 ms 1584 KB Output is correct
2 Correct 429 ms 1376 KB Output is correct
3 Correct 857 ms 1376 KB Output is correct
4 Correct 715 ms 1368 KB Output is correct
5 Correct 573 ms 1248 KB Output is correct
6 Correct 554 ms 1536 KB Output is correct
7 Correct 535 ms 1260 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 5 ms 1248 KB Output is correct
10 Correct 2 ms 1248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 528 ms 1248 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 558 ms 1496 KB Output is correct
2 Correct 451 ms 1496 KB Output is correct
3 Correct 978 ms 1540 KB Output is correct
4 Correct 865 ms 1368 KB Output is correct
5 Correct 550 ms 1504 KB Output is correct
6 Correct 563 ms 1500 KB Output is correct
7 Correct 521 ms 1252 KB Output is correct
8 Correct 3 ms 1368 KB Output is correct
9 Correct 5 ms 1496 KB Output is correct
10 Correct 2 ms 1248 KB Output is correct
11 Incorrect 609 ms 1248 KB Wrong query response.
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 866 ms 1368 KB Output is correct
2 Correct 740 ms 1368 KB Output is correct
3 Correct 572 ms 1368 KB Output is correct
4 Correct 3 ms 1376 KB Output is correct
5 Correct 5 ms 1248 KB Output is correct
6 Correct 2 ms 1368 KB Output is correct
7 Incorrect 662 ms 1248 KB Wrong query response.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 686 ms 1500 KB Output is correct
2 Correct 524 ms 1624 KB Output is correct
3 Correct 934 ms 1368 KB Output is correct
4 Correct 623 ms 1900 KB Output is correct
5 Correct 612 ms 1248 KB Output is correct
6 Correct 520 ms 1500 KB Output is correct
7 Correct 558 ms 1252 KB Output is correct
8 Correct 3 ms 1376 KB Output is correct
9 Correct 5 ms 1376 KB Output is correct
10 Correct 2 ms 1416 KB Output is correct
11 Incorrect 482 ms 1296 KB Wrong query response.
12 Halted 0 ms 0 KB -