답안 #512711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
512711 2022-01-16T16:59:17 Z AdamGS 기지국 (IOI20_stations) C++17
0 / 100
821 ms 528 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], odw[LIM], lpre;
void DFS(int x, int v) {
	odw[x]=1;
	if(v%2==0) T[x]=++lpre;
	for(auto i : V[x]) if(odw[i]==0) DFS(i, v+1);
	if(v%2==1) T[x]=++lpre;
}
vector<int>label(int n, int k, vector<int>u, vector<int>v) {
	rep(i, n-1) {
		V[u[i]].pb(v[i]);
		V[v[i]].pb(u[i]);
	}
	lpre=-1;
	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:35:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   35 |   if(t>s || c.size()>1 && t<c[1]) return c[0];
stations.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for(int i=2; i<c.size(); ++i) if(c[i]>t) return c[i-1];
      |                ~^~~~~~~~~
stations.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i=0; i<c.size()-1; ++i) if(c[i]>=t) return c[i];
      |                ~^~~~~~~~~~~
stations.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 436 KB Invalid labels (duplicates values). scenario=2, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 412 KB Invalid labels (duplicates values). scenario=3, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 432 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 821 ms 400 KB Output is correct
2 Incorrect 649 ms 528 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 448 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -