답안 #1085025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085025 2024-09-07T10:16:29 Z ZeroCool 기지국 (IOI20_stations) C++14
100 / 100
673 ms 1044 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h> 
using namespace std; const int N = 1000; vector<int> g[N];vector<int> A; int T = 0;void dfs(int x,int p, bool b){	if(b){		for(auto u: g[x]){			if(u == p)continue;			dfs(u, x, !b);		}		A[x] = T++;	}else{		A[x] = T++;		for(auto u: g[x]){			if(u == p)continue;			dfs(u, x, !b);		}	}} std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {	T = 0;	A.clear();	A.resize(n);	for(int i = 0;i < n;i++)g[i].clear();	for(int i = 0;i < n- 1;i ++){		g[u[i]].push_back(v[i]);		g[v[i]].push_back(u[i]);	}	dfs(0, 0,0 );	return A;} int find_next_station(int s, int t, std::vector<int> g) {	if(g.size() == 1)return g.front();	sort(g.begin(), g.end());	if(s > g.front()){		if(t > s || t <= g.front())return g.front();		return *(upper_bound(g.begin(), g.end(), t) - 1);	}else{		if(t < s | t >= g.back())return g.back();		return *lower_bound(g.begin(), g.end(), t);	}}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:4:787: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
    4 | using namespace std; const int N = 1000; vector<int> g[N];vector<int> A; int T = 0;void dfs(int x,int p, bool b){ if(b){  for(auto u: g[x]){   if(u == p)continue;   dfs(u, x, !b);  }  A[x] = T++; }else{  A[x] = T++;  for(auto u: g[x]){   if(u == p)continue;   dfs(u, x, !b);  } }} std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { T = 0; A.clear(); A.resize(n); for(int i = 0;i < n;i++)g[i].clear(); for(int i = 0;i < n- 1;i ++){  g[u[i]].push_back(v[i]);  g[v[i]].push_back(u[i]); } dfs(0, 0,0 ); return A;} int find_next_station(int s, int t, std::vector<int> g) { if(g.size() == 1)return g.front(); sort(g.begin(), g.end()); if(s > g.front()){  if(t > s || t <= g.front())return g.front();  return *(upper_bound(g.begin(), g.end(), t) - 1); }else{  if(t < s | t >= g.back())return g.back();  return *lower_bound(g.begin(), g.end(), t); }}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 362 ms 684 KB Output is correct
2 Correct 302 ms 684 KB Output is correct
3 Correct 657 ms 684 KB Output is correct
4 Correct 472 ms 684 KB Output is correct
5 Correct 403 ms 684 KB Output is correct
6 Correct 257 ms 684 KB Output is correct
7 Correct 305 ms 684 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 290 ms 684 KB Output is correct
2 Correct 379 ms 684 KB Output is correct
3 Correct 596 ms 684 KB Output is correct
4 Correct 488 ms 684 KB Output is correct
5 Correct 390 ms 684 KB Output is correct
6 Correct 304 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 354 ms 684 KB Output is correct
2 Correct 309 ms 684 KB Output is correct
3 Correct 618 ms 684 KB Output is correct
4 Correct 427 ms 684 KB Output is correct
5 Correct 416 ms 684 KB Output is correct
6 Correct 266 ms 804 KB Output is correct
7 Correct 282 ms 684 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 371 ms 684 KB Output is correct
12 Correct 310 ms 788 KB Output is correct
13 Correct 328 ms 932 KB Output is correct
14 Correct 286 ms 684 KB Output is correct
15 Correct 41 ms 768 KB Output is correct
16 Correct 36 ms 768 KB Output is correct
17 Correct 66 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 673 ms 684 KB Output is correct
2 Correct 471 ms 688 KB Output is correct
3 Correct 413 ms 684 KB Output is correct
4 Correct 1 ms 776 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 0 ms 764 KB Output is correct
7 Correct 404 ms 684 KB Output is correct
8 Correct 602 ms 688 KB Output is correct
9 Correct 485 ms 688 KB Output is correct
10 Correct 389 ms 684 KB Output is correct
11 Correct 2 ms 764 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 1 ms 764 KB Output is correct
15 Correct 0 ms 776 KB Output is correct
16 Correct 332 ms 684 KB Output is correct
17 Correct 317 ms 684 KB Output is correct
18 Correct 310 ms 688 KB Output is correct
19 Correct 308 ms 684 KB Output is correct
20 Correct 331 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 364 ms 684 KB Output is correct
2 Correct 309 ms 684 KB Output is correct
3 Correct 604 ms 684 KB Output is correct
4 Correct 466 ms 680 KB Output is correct
5 Correct 392 ms 684 KB Output is correct
6 Correct 322 ms 684 KB Output is correct
7 Correct 280 ms 684 KB Output is correct
8 Correct 1 ms 772 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 321 ms 684 KB Output is correct
12 Correct 330 ms 684 KB Output is correct
13 Correct 626 ms 684 KB Output is correct
14 Correct 459 ms 684 KB Output is correct
15 Correct 392 ms 684 KB Output is correct
16 Correct 318 ms 684 KB Output is correct
17 Correct 417 ms 764 KB Output is correct
18 Correct 326 ms 932 KB Output is correct
19 Correct 317 ms 684 KB Output is correct
20 Correct 283 ms 684 KB Output is correct
21 Correct 30 ms 768 KB Output is correct
22 Correct 34 ms 764 KB Output is correct
23 Correct 61 ms 716 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 2 ms 776 KB Output is correct
26 Correct 3 ms 768 KB Output is correct
27 Correct 1 ms 768 KB Output is correct
28 Correct 0 ms 776 KB Output is correct
29 Correct 358 ms 684 KB Output is correct
30 Correct 295 ms 684 KB Output is correct
31 Correct 330 ms 684 KB Output is correct
32 Correct 337 ms 684 KB Output is correct
33 Correct 370 ms 684 KB Output is correct
34 Correct 210 ms 684 KB Output is correct
35 Correct 262 ms 684 KB Output is correct
36 Correct 293 ms 940 KB Output is correct
37 Correct 307 ms 800 KB Output is correct
38 Correct 284 ms 684 KB Output is correct
39 Correct 292 ms 1044 KB Output is correct
40 Correct 279 ms 932 KB Output is correct
41 Correct 292 ms 788 KB Output is correct
42 Correct 32 ms 732 KB Output is correct
43 Correct 67 ms 716 KB Output is correct
44 Correct 92 ms 764 KB Output is correct
45 Correct 100 ms 712 KB Output is correct
46 Correct 216 ms 684 KB Output is correct
47 Correct 201 ms 684 KB Output is correct
48 Correct 34 ms 684 KB Output is correct
49 Correct 33 ms 864 KB Output is correct