Submission #1080539

# Submission time Handle Problem Language Result Execution time Memory
1080539 2024-08-29T10:50:21 Z Faisal_Saqib Stations (IOI20_stations) C++17
76 / 100
605 ms 1052 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+100;
const int M=1e3;
vector<int> ma[N];
int tin[N],tout[N],last[N],timer=-1;
void dfs(int v, int p,int h=0)
{
    tin[v] = ++timer; // n

    for (auto u:ma[v]) {
        if (u != p)
        {
            dfs(u, v,1-h);
        }
    }
   	last[v]=h;
    tout[v] = ++timer; // n
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	timer=-1;
	for(int i=0;i<(n);i++)last[i]=-1,ma[i].clear();
	vector<int> labels(n,0);
	for(int i=0;i<(n-1);i++)
	{
		ma[u[i]].push_back(v[i]);
		ma[v[i]].push_back(u[i]);
	}
	dfs(0,-1);
	// tout[i] >= tin[i]
	// tout[i]-tin[i] == sz[i]
	// 1<= sz[i] <=n
	for(int i=0;i<n;i++)
	{
		if(last[i]==0)
		{
			labels[i]=tin[i];
		}
		else
		{
			labels[i]=tout[i];
		}
	}
	return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
	sort(begin(c),end(c));
	if(s<c[0])
	{
		// s = in[s]
		int last=s+1;
		for(auto j:c)
		{
			if(last<=t and t<=j)
				return j;
			last=j+1;
		}
		return c.back();
	}
	else
	{
		reverse(begin(c),end(c));
		int last=s-1;
		for(auto j:c)
		{
			if(j<=t and t<=last)
				return j;
			last=j-1;
		}
		return c.back();
	}
	return t;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 532 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 374 ms 684 KB Output is correct
2 Correct 312 ms 688 KB Output is correct
3 Correct 602 ms 684 KB Output is correct
4 Correct 413 ms 684 KB Output is correct
5 Correct 403 ms 684 KB Output is correct
6 Correct 309 ms 932 KB Output is correct
7 Correct 302 ms 712 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 2 ms 780 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 432 ms 684 KB Output is correct
12 Correct 324 ms 1044 KB Output is correct
13 Correct 300 ms 796 KB Output is correct
14 Correct 281 ms 684 KB Output is correct
15 Correct 28 ms 768 KB Output is correct
16 Correct 50 ms 684 KB Output is correct
17 Correct 55 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 605 ms 684 KB Output is correct
2 Correct 471 ms 696 KB Output is correct
3 Correct 408 ms 684 KB Output is correct
4 Correct 2 ms 764 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 407 ms 800 KB Output is correct
8 Correct 603 ms 684 KB Output is correct
9 Correct 419 ms 684 KB Output is correct
10 Correct 385 ms 684 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 2 ms 776 KB Output is correct
14 Correct 1 ms 776 KB Output is correct
15 Correct 1 ms 776 KB Output is correct
16 Correct 328 ms 684 KB Output is correct
17 Correct 381 ms 684 KB Output is correct
18 Correct 350 ms 684 KB Output is correct
19 Correct 336 ms 684 KB Output is correct
20 Correct 373 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 370 ms 684 KB Partially correct
2 Partially correct 286 ms 684 KB Partially correct
3 Correct 583 ms 684 KB Output is correct
4 Correct 491 ms 684 KB Output is correct
5 Correct 422 ms 684 KB Output is correct
6 Partially correct 348 ms 684 KB Partially correct
7 Partially correct 345 ms 684 KB Partially correct
8 Correct 1 ms 776 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
11 Partially correct 300 ms 684 KB Partially correct
12 Partially correct 350 ms 684 KB Partially correct
13 Correct 570 ms 684 KB Output is correct
14 Correct 553 ms 680 KB Output is correct
15 Correct 386 ms 684 KB Output is correct
16 Partially correct 322 ms 684 KB Partially correct
17 Correct 379 ms 684 KB Output is correct
18 Partially correct 291 ms 796 KB Partially correct
19 Partially correct 306 ms 1052 KB Partially correct
20 Partially correct 304 ms 696 KB Partially correct
21 Correct 40 ms 764 KB Output is correct
22 Partially correct 33 ms 764 KB Partially correct
23 Partially correct 64 ms 744 KB Partially correct
24 Correct 3 ms 764 KB Output is correct
25 Correct 2 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 1 ms 768 KB Output is correct
28 Correct 0 ms 768 KB Output is correct
29 Correct 317 ms 684 KB Output is correct
30 Correct 357 ms 688 KB Output is correct
31 Correct 302 ms 684 KB Output is correct
32 Correct 311 ms 684 KB Output is correct
33 Correct 328 ms 684 KB Output is correct
34 Partially correct 208 ms 684 KB Partially correct
35 Partially correct 293 ms 1048 KB Partially correct
36 Partially correct 307 ms 932 KB Partially correct
37 Partially correct 349 ms 944 KB Partially correct
38 Partially correct 301 ms 1028 KB Partially correct
39 Partially correct 326 ms 940 KB Partially correct
40 Partially correct 316 ms 1028 KB Partially correct
41 Partially correct 302 ms 796 KB Partially correct
42 Partially correct 33 ms 768 KB Partially correct
43 Partially correct 48 ms 684 KB Partially correct
44 Partially correct 87 ms 764 KB Partially correct
45 Partially correct 112 ms 804 KB Partially correct
46 Partially correct 185 ms 684 KB Partially correct
47 Partially correct 196 ms 688 KB Partially correct
48 Partially correct 31 ms 972 KB Partially correct
49 Partially correct 35 ms 744 KB Partially correct