Submission #341683

# Submission time Handle Problem Language Result Execution time Memory
341683 2020-12-30T12:16:29 Z ogibogi2004 Stations (IOI20_stations) C++14
0 / 100
880 ms 1152 KB
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
#define time afds
const int MAXN=1024;
vector<int>g[MAXN];
int in_time[MAXN],out_time[MAXN],time=-1;
void dfs(int u,int par)
{
	in_time[u]=++time;
	for(auto v:g[u])
	{
		if(v==par)continue;
		dfs(v,u);
	}
	out_time[u]=time;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);
	time=-1;
	for(int i=0;i<=n;i++)g[i].clear();
	for(int i=0;i<u.size();i++)
	{
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	dfs(0,-1);
	for (int i = 0; i < n; i++) {
		if(in_time[i]*1000+out_time[i]<=k)labels[i] = in_time[i]*1000+out_time[i];
		else labels[i]=in_time[i];
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	int in_s=s/1000,out_s=s%1000;
	int in_t=t/1000,out_t=t%1000;
	if(!(in_t>=in_s&&out_t<=out_s))
	{
		for(auto xd:c)
		{
			int in1=xd/1000,out1=xd%1000;
			if(in1<=in_s&&out1>=out_s)
			{
				return xd;
			}
		}
	}
	else
	{
		for(auto xd:c)
		{
			int in1=xd/1000,out1=xd%1000;
			if(in1<=in_t&&out1>=out_t)
			{
				return xd;
			}
		}
	}
	return 0;
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=0;i<u.size();i++)
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (duplicates values). scenario=0, label=9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 492 KB Invalid labels (duplicates values). scenario=0, label=995
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 540 ms 900 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 880 ms 736 KB Output is correct
2 Incorrect 653 ms 864 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 553 ms 1152 KB Wrong query response.
2 Halted 0 ms 0 KB -