Submission #835227

# Submission time Handle Problem Language Result Execution time Memory
835227 2023-08-23T10:41:46 Z DJeniUp Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097152 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back
#define N 1007

ll n,tin[N],tout[N],h;

vector<int>v[N],res;

ll S(ll x,ll y){
	tin[x]=h;
	tout[x]=h;
	h++;
	for(int i=0;i<v[x].size();i++){
		if(v[x][i]!=y){
			tout[x]=S(v[x][i],x);
		}
	}
	return tout[x];
}

std::vector<int> label(int N1, int k, std::vector<int> u, std::vector<int> w) {
	n=N1;
	res.resize(n);
	for(int i=0;i<u.size();i++){
		v[u[i]].pb(w[i]);
		v[w[i]].pb(u[i]);
	}
	S(0,0);
	for(int i=0;i<n;i++){
		res[i]=tin[i]*1000+tout[i];
	}
	return res;
}

int find_next_station(int s, int t, std::vector<int> c) {
	n=c.size();
	ll tin1=s/1000;
	ll tout1=s%1000;
	ll tin2=t/1000;
	ll tout2=t%1000;
	for(int i=0;i<n;i++){
		tin[i]=c[i]/1000;
		tout[i]=c[i]%1000;
	}
	if(tin1<=tin2 && tout2<=tout1){
		for(int i=0;i<n;i++){
			if(tin[i]<=tin2 && tout2<=tout[i])return c[i];
		}
	}else{
		for(int i=0;i<n;i++){
			if(tin[i]<tin1)return c[i];
		}
	}

	return 0;
}

Compilation message

stations.cpp: In function 'll S(ll, ll)':
stations.cpp:17:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i=0;i<v[x].size();i++){
      |              ~^~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:28:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for(int i=0;i<u.size();i++){
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1269 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3038 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 941 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 627 ms 416 KB Output is correct
2 Runtime error 765 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1570 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -