Submission #305707

# Submission time Handle Problem Language Result Execution time Memory
305707 2020-09-23T20:34:46 Z peti1234 Stations (IOI20_stations) C++17
0 / 100
850 ms 896 KB
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
const int c=1002;
vector<int> sz[c], sol;
bool v[c];
int cnt;
void dfs(int a, bool b) {
    v[a]=1;
    if (!b) sol[a]=cnt++;
    for (int i=0; i<sz[a].size(); i++) {
        int x=sz[a][i];
        if (!v[x]) dfs(x, !b);
    }
    if (b) sol[a]=cnt++;
}
vector<int> label(int n, int k, vector<int> x, vector<int> y) {
    for (int i=0; i<n; i++) sz[i].clear(), v[i]=0, cnt=0, sol.clear();
    sol.resize(n);
    for (int i=0; i<n-1; i++) sz[x[i]].push_back(y[i]), sz[y[i]].push_back(x[i]);
    dfs(0, 0);
    //for(int i=0; i<n; i++) cout << sol[i] << " ";
    return sol;
}
int find_next_station(int s, int t, vector<int> sz) {
    int x=sz[0], y=sz.back(), si=sz.size();
    if (s<x) {
        if (t<s && t>y) return x;
        for (int i=0; i<si; i++) if (sz[i]>=t) return sz[i];
    }
    if (t>s && t<x) return y;
    for (int i=si-1; i>0; i--) if (sz[i]<=t) return sz[i];
}

Compilation message

stations.cpp: In function 'void dfs(int, bool)':
stations.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i=0; i<sz[a].size(); i++) {
      |                   ~^~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 617 ms 896 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 565 ms 816 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 554 ms 780 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 850 ms 768 KB Output is correct
2 Correct 704 ms 896 KB Output is correct
3 Incorrect 744 ms 892 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 538 ms 768 KB Wrong query response.
2 Halted 0 ms 0 KB -