Submission #529545

# Submission time Handle Problem Language Result Execution time Memory
529545 2022-02-23T06:53:14 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 = -1;
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(1, -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;
	}
}

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;
      |                    ^~
stations.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
   36 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 944 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3049 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1227 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 730 ms 488 KB Output is correct
2 Runtime error 918 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2217 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -