Submission #393001

# Submission time Handle Problem Language Result Execution time Memory
393001 2021-04-22T13:59:00 Z REALITYNB Stations (IOI20_stations) C++14
0 / 100
2439 ms 2097156 KB
#include <bits/stdc++.h> 
#include "stations.h"
#define pii pair<int,int> 
#define in first 
#define out second
#define mp make_pair 
using namespace std; 
	vector<int> adj[1000] ; 

vector<int> label(int n ,int k , vector<int> u , vector<int> v){
	vector<int> ans(n) ; 
	for(int i=0;i<n-1;i++) {
		adj[u[i]].push_back(v[i]) ; 
		adj[v[i]].push_back(u[i]) ; 
	}
	int tim = 0 ; 
	vector<int> inn(n) , outt(n),  lvl(n) ; 
	function<void(int,int,int)> dfs = [&](int a, int p, int l){
		inn[a]=tim++ ; 
		lvl[a]=l ; 
		for(int x :adj[a]){
			if(x!=p){
				dfs(x,a,l^1) ; 
			}
		}
		outt[a]=tim++ ; 
	}; 
	dfs(0,0,0) ; 
	for(int i=0;i<n;i++)
		ans[i]=(lvl[i]?outt[i]:inn[i]) ; 
	return ans ; 
}
pii get(int x){
	return mp(x%(1<<11),(x>>11)) ; 
}
bool ancestor(pii s, pii b){
	return (s.in<=b.in&&b.out<=s.out); 
}
int find_next_station(int s ,int t, vector<int> ne){
	int isin = (ne[0]>s) ;
	if(s==0){
		for(int i=1;i<ne.size();i++) if(ne[i-1]<t&&t<=ne[i]) return ne[i] ; 
		return ne[0] ; 
	} 
	if(isin^1){

		for(int i=1;i+1<ne.size();i++){
			if(ne[i]<=t&&t<ne[i+1]){
				return ne[i] ; 
			}
		}
		if(ne.back()<=t&&t<s) return ne.back() ; 
		return ne[0] ; 
	}
	for(int i=1;i+1<ne.size();i++){
		if(ne[i-1]<t&&t<=ne[i]) return ne[i] ; 
	}	
	if(s<=t&&t<=ne[0]) return ne[0] ; 
	return ne.back() ; 

}
/*int main(){
	vector<int> u= {0,1,2} , v = {1,2,3} ;
	vector<int> res = label(4,1000000,u,v) ; 
	for(int x : res) cout << x <<" " ; 
	cout << endl ; 
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(i!=j){
				cout << res[i]<< " "<< res[j] << ": " << find_next_station(res[i],res[j],adj[i]) << endl ; 
			}
		}
	}
	return 0 ; 
}*/

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(int i=1;i<ne.size();i++) if(ne[i-1]<t&&t<=ne[i]) return ne[i] ;
      |               ~^~~~~~~~~~
stations.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(int i=1;i+1<ne.size();i++){
      |               ~~~^~~~~~~~~~
stations.cpp:55:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for(int i=1;i+1<ne.size();i++){
      |              ~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1372 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 576 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1323 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1051 ms 400 KB Output is correct
2 Runtime error 1224 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2439 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -