Submission #349979

# Submission time Handle Problem Language Result Execution time Memory
349979 2021-01-18T19:16:34 Z evn Stations (IOI20_stations) C++14
69.868 / 100
1023 ms 1260 KB
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
typedef long long ll;
typedef pair<int, int> pii;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int timer = 0;
int depth[1005];
int in[1005];
int out[1005];
vector<int> adj[1005];
vector<int> labels;

void dfs(int u, int p){
	if(depth[u] % 2 == 0)labels[u] = timer++;
	for(int v : adj[u]){
		if(v != p){
			depth[v] = depth[u]+1;
			dfs(v, u);
		}
	}
	if(depth[u] % 2 == 1)labels[u] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	labels.resize(n);
	for(int i = 0; i < n;i ++){
		adj[i].clear();
		depth[i] = 0;
		labels[i] = 0;
	}
	for(int i = 0; i < u.size(); i++){
		int a, b;
		a = u[i];
		b = v[i];
		adj[a].pb(b);
		adj[b].pb(a);
	}
	dfs(0, -1);
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	if(c.size() == 1)return c[0];
	if(c[0] > s){
		//this is the in value
		if(t < s || t >= c[c.size()-1])return c[c.size()-1];
		for(int i = 0;i < c.size()-1; i++){
			if(t <= c[i])return c[i];
		}
	}
	else{
		//this is the out value
		if(t <= c[0] || t > s)return c[0];
		for(int i = c.size()-1; i >= 1; i--){
			if(t >= c[i])return c[i];
		}
	}
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i = 0; i < u.size(); i++){
      |                 ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:55:19: 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 = 0;i < c.size()-1; i++){
      |                 ~~^~~~~~~~~~~~
stations.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
   66 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1008
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 572 KB Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=1507
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 503 ms 1072 KB Output is correct
2 Correct 534 ms 992 KB Output is correct
3 Correct 1004 ms 944 KB Output is correct
4 Correct 781 ms 944 KB Output is correct
5 Correct 651 ms 1116 KB Output is correct
6 Correct 502 ms 992 KB Output is correct
7 Correct 532 ms 1248 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 4 ms 864 KB Output is correct
10 Correct 2 ms 864 KB Output is correct
11 Correct 544 ms 864 KB Output is correct
12 Correct 605 ms 1260 KB Output is correct
13 Correct 507 ms 992 KB Output is correct
14 Correct 458 ms 892 KB Output is correct
15 Correct 65 ms 936 KB Output is correct
16 Correct 77 ms 736 KB Output is correct
17 Correct 107 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1014 ms 736 KB Output is correct
2 Correct 693 ms 736 KB Output is correct
3 Correct 686 ms 944 KB Output is correct
4 Correct 3 ms 952 KB Output is correct
5 Correct 4 ms 736 KB Output is correct
6 Correct 1 ms 864 KB Output is correct
7 Correct 607 ms 864 KB Output is correct
8 Correct 901 ms 864 KB Output is correct
9 Correct 765 ms 1108 KB Output is correct
10 Correct 632 ms 864 KB Output is correct
11 Correct 7 ms 944 KB Output is correct
12 Correct 7 ms 736 KB Output is correct
13 Correct 6 ms 944 KB Output is correct
14 Correct 3 ms 952 KB Output is correct
15 Correct 2 ms 944 KB Output is correct
16 Correct 581 ms 864 KB Output is correct
17 Correct 610 ms 944 KB Output is correct
18 Correct 562 ms 944 KB Output is correct
19 Correct 513 ms 1080 KB Output is correct
20 Correct 569 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 584 ms 1076 KB Partially correct
2 Partially correct 480 ms 1080 KB Partially correct
3 Correct 903 ms 864 KB Output is correct
4 Correct 647 ms 952 KB Output is correct
5 Correct 714 ms 944 KB Output is correct
6 Partially correct 503 ms 864 KB Partially correct
7 Correct 411 ms 864 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 5 ms 944 KB Output is correct
10 Correct 1 ms 952 KB Output is correct
11 Partially correct 492 ms 872 KB Partially correct
12 Partially correct 542 ms 1120 KB Partially correct
13 Correct 1023 ms 836 KB Output is correct
14 Correct 793 ms 944 KB Output is correct
15 Correct 687 ms 944 KB Output is correct
16 Correct 445 ms 864 KB Output is correct
17 Correct 752 ms 992 KB Output is correct
18 Partially correct 421 ms 1008 KB Partially correct
19 Partially correct 569 ms 1120 KB Partially correct
20 Correct 531 ms 892 KB Output is correct
21 Correct 55 ms 864 KB Output is correct
22 Partially correct 64 ms 900 KB Partially correct
23 Partially correct 140 ms 876 KB Partially correct
24 Correct 5 ms 736 KB Output is correct
25 Correct 8 ms 952 KB Output is correct
26 Correct 5 ms 944 KB Output is correct
27 Correct 4 ms 736 KB Output is correct
28 Correct 2 ms 864 KB Output is correct
29 Correct 628 ms 864 KB Output is correct
30 Correct 547 ms 864 KB Output is correct
31 Correct 460 ms 944 KB Output is correct
32 Correct 464 ms 944 KB Output is correct
33 Correct 501 ms 952 KB Output is correct
34 Partially correct 316 ms 1084 KB Partially correct
35 Partially correct 486 ms 1120 KB Partially correct
36 Partially correct 485 ms 1032 KB Partially correct
37 Partially correct 479 ms 1224 KB Partially correct
38 Partially correct 587 ms 1120 KB Partially correct
39 Partially correct 491 ms 1220 KB Partially correct
40 Partially correct 530 ms 992 KB Partially correct
41 Partially correct 463 ms 1108 KB Partially correct
42 Partially correct 80 ms 892 KB Partially correct
43 Partially correct 98 ms 736 KB Partially correct
44 Partially correct 144 ms 984 KB Partially correct
45 Partially correct 174 ms 1236 KB Partially correct
46 Partially correct 322 ms 888 KB Partially correct
47 Partially correct 339 ms 1116 KB Partially correct
48 Partially correct 76 ms 1148 KB Partially correct
49 Partially correct 57 ms 1080 KB Partially correct