Submission #529561

# Submission time Handle Problem Language Result Execution time Memory
529561 2022-02-23T07:25:10 Z pokmui9909 Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll in[1005], out[1005];
vector<ll> T[1005];
ll num = 0;
void dfs(ll u, ll p){
    in[u] = ++num;
    for(auto v : T[u]){
        if(v == p) continue;
        dfs(v, u);
    }
    out[u] = num;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	for(int i = 0; i < n - 1; i++){
		T[u[i]].push_back(v[i]);
		T[v[i]].push_back(u[i]);
	}
	dfs(0, -1);
	vector<int> L(n);
	for(int i = 0; i < n; i++){
		L[i] = in[i] * 1000 + out[i];
	}
	return L;
}
int find_next_station(int s, int t, std::vector<int> c) {
	ll ls = s / 1000, rs = s % 1000, lt = t / 1000, rt = t % 1000;
	for(int i = 0; i < c.size(); i++){
		ll k = c[i];
		ll lk = k / 1000, rk = k % 1000;
		if(lk <= lt && rt <= rk) return k;
	}
	return -1;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i < c.size(); i++){
      |                 ~~^~~~~~~~~~
stations.cpp:30:5: warning: unused variable 'ls' [-Wunused-variable]
   30 |  ll ls = s / 1000, rs = s % 1000, lt = t / 1000, rt = t % 1000;
      |     ^~
stations.cpp:30:20: warning: unused variable 'rs' [-Wunused-variable]
   30 |  ll ls = s / 1000, rs = s % 1000, lt = t / 1000, rt = t % 1000;
      |                    ^~
# Verdict Execution time Memory Grader output
1 Runtime error 1127 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3068 ms 476 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1230 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 920 ms 508 KB Output is correct
2 Runtime error 927 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2270 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -