Submission #512705

# Submission time Handle Problem Language Result Execution time Memory
512705 2022-01-16T16:53:44 Z AdamGS Stations (IOI20_stations) C++17
0 / 100
953 ms 684 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e3+7;
vector<int>V[LIM];
int T[LIM], lpre=-1;
void DFS(int x, int v) {
	if(!v) T[x]=++lpre;
	for(auto i : V[x]) if(T[i]==-1) DFS(i, v^1);
	if(v) T[x]=++lpre;
}
vector<int>label(int n, int k, vector<int>u, vector<int>v) {
	rep(i, n) T[i]=-1;
	rep(i, n-1) {
		V[u[i]].pb(v[i]);
		V[v[i]].pb(u[i]);
	}
	DFS(0, 0);
	vector<int>p(n);
	rep(i, n) p[i]=T[i];
	return p;
}
int find_next_station(int s, int t, vector<int>c) {
	if(s==0) {
		for(auto i : c) if(i>=t) return i;
	} else if(s>=c[0]) {
		if(t>s || c.size()>1 && t<c[1]) return c[0];
		for(int i=2; i<c.size(); ++i) if(c[i]>t) return c[i-1];
		return c.back();
	} else {
		if(t<s) return c.back();
		for(int i=0; i<c.size()-1; ++i) if(c[i]>=t) return c[i];
		return c.back();
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:34:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   34 |   if(t>s || c.size()>1 && t<c[1]) return c[0];
stations.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int i=2; i<c.size(); ++i) if(c[i]>t) return c[i-1];
      |                ~^~~~~~~~~
stations.cpp:39:17: 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<c.size()-1; ++i) if(c[i]>=t) return c[i];
      |                ~^~~~~~~~~~~
stations.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 444 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=4, label=1412
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 428 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=2, label=1335
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 551 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 953 ms 400 KB Output is correct
2 Incorrect 722 ms 400 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 600 ms 632 KB Wrong query response.
2 Halted 0 ms 0 KB -