답안 #308160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308160 2020-09-30T07:18:06 Z jwvg0425 기지국 (IOI20_stations) C++17
76 / 100
994 ms 1272 KB
#include "stations.h"
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

template<typename T, typename Pr = less<T>>
using pq = priority_queue<T, vector<T>, Pr>;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

struct Solver
{
	vector<int> edge[1005];
	int in[1005] = { 0, }, out[1005] = { 0, };
	int depth[1005] = { 0, };
	int vis = 0;

	void dfs(int root)
	{
		in[root] = vis;
		vis++;

		for (auto& e : edge[root])
		{
			edge[e].erase(find(all(edge[e]), root));
			depth[e] = depth[root] + 1;
			dfs(e);
		}

		out[root] = vis;
		vis++;
	}
};

vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
	Solver s;
	for (int i = 0; i < n - 1; i++)
	{
		s.edge[u[i]].push_back(v[i]);
		s.edge[v[i]].push_back(u[i]);
	}

	s.dfs(0);

	vector<int> res(n);
	for (int i = 0; i < n; i++)
	{
		if (s.depth[i] % 2 == 0)
			res[i] = s.in[i];
		else
			res[i] = s.out[i];
	}

	return res;
}

int find_next_station(int s, int t, vector<int> c)
{
	// s = in time, cs = out time
	if (s < c[0])
	{
		int pc = s;
		for (int i = 0; i < c.size(); i++)
		{
			if (t > pc && t <= c[i])
				return c[i];

			pc = c[i];
		}

		return c.back();
	}
	else
	{
		// s = out time, cs = in time
		for (int i = 0; i < c.size(); i++)
		{
			int nc = (i == c.size() - 1) ? (s + 1) : c[i + 1];
			if (t >= c[i] && t < nc)
				return c[i];
		}

		return c[0];
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:83:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |   for (int i = 0; i < c.size(); i++)
      |                   ~~^~~~~~~~~~
stations.cpp:96:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |   for (int i = 0; i < c.size(); i++)
      |                   ~~^~~~~~~~~~
stations.cpp:98:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |    int nc = (i == c.size() - 1) ? (s + 1) : c[i + 1];
      |              ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 512 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 472 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 561 ms 1024 KB Output is correct
2 Correct 471 ms 1024 KB Output is correct
3 Correct 860 ms 864 KB Output is correct
4 Correct 636 ms 872 KB Output is correct
5 Correct 615 ms 872 KB Output is correct
6 Correct 486 ms 1272 KB Output is correct
7 Correct 545 ms 772 KB Output is correct
8 Correct 2 ms 864 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 659 ms 760 KB Output is correct
12 Correct 555 ms 1092 KB Output is correct
13 Correct 481 ms 1016 KB Output is correct
14 Correct 453 ms 768 KB Output is correct
15 Correct 59 ms 864 KB Output is correct
16 Correct 63 ms 840 KB Output is correct
17 Correct 112 ms 940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 982 ms 872 KB Output is correct
2 Correct 684 ms 768 KB Output is correct
3 Correct 631 ms 872 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 4 ms 1024 KB Output is correct
6 Correct 2 ms 868 KB Output is correct
7 Correct 571 ms 864 KB Output is correct
8 Correct 994 ms 768 KB Output is correct
9 Correct 716 ms 768 KB Output is correct
10 Correct 591 ms 864 KB Output is correct
11 Correct 5 ms 872 KB Output is correct
12 Correct 6 ms 768 KB Output is correct
13 Correct 4 ms 768 KB Output is correct
14 Correct 4 ms 768 KB Output is correct
15 Correct 2 ms 880 KB Output is correct
16 Correct 594 ms 768 KB Output is correct
17 Correct 495 ms 760 KB Output is correct
18 Correct 599 ms 880 KB Output is correct
19 Correct 536 ms 868 KB Output is correct
20 Correct 546 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 554 ms 1024 KB Partially correct
2 Partially correct 465 ms 1016 KB Partially correct
3 Correct 900 ms 864 KB Output is correct
4 Correct 730 ms 1024 KB Output is correct
5 Correct 658 ms 872 KB Output is correct
6 Partially correct 573 ms 1016 KB Partially correct
7 Partially correct 464 ms 768 KB Partially correct
8 Correct 3 ms 880 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 1 ms 872 KB Output is correct
11 Partially correct 483 ms 768 KB Partially correct
12 Partially correct 599 ms 812 KB Partially correct
13 Correct 909 ms 788 KB Output is correct
14 Correct 656 ms 840 KB Output is correct
15 Correct 626 ms 864 KB Output is correct
16 Partially correct 460 ms 760 KB Partially correct
17 Correct 597 ms 768 KB Output is correct
18 Partially correct 476 ms 1008 KB Partially correct
19 Partially correct 470 ms 1088 KB Partially correct
20 Partially correct 447 ms 768 KB Partially correct
21 Correct 56 ms 868 KB Output is correct
22 Partially correct 75 ms 768 KB Partially correct
23 Partially correct 105 ms 784 KB Partially correct
24 Correct 5 ms 872 KB Output is correct
25 Correct 5 ms 872 KB Output is correct
26 Correct 6 ms 768 KB Output is correct
27 Correct 3 ms 880 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 561 ms 860 KB Output is correct
30 Correct 502 ms 868 KB Output is correct
31 Correct 543 ms 868 KB Output is correct
32 Correct 528 ms 868 KB Output is correct
33 Correct 499 ms 768 KB Output is correct
34 Partially correct 411 ms 992 KB Partially correct
35 Partially correct 445 ms 1024 KB Partially correct
36 Partially correct 455 ms 1272 KB Partially correct
37 Partially correct 485 ms 788 KB Partially correct
38 Partially correct 488 ms 888 KB Partially correct
39 Partially correct 458 ms 768 KB Partially correct
40 Partially correct 450 ms 784 KB Partially correct
41 Partially correct 538 ms 904 KB Partially correct
42 Partially correct 74 ms 1024 KB Partially correct
43 Partially correct 119 ms 780 KB Partially correct
44 Partially correct 146 ms 768 KB Partially correct
45 Partially correct 181 ms 768 KB Partially correct
46 Partially correct 307 ms 1024 KB Partially correct
47 Partially correct 318 ms 768 KB Partially correct
48 Partially correct 71 ms 768 KB Partially correct
49 Partially correct 75 ms 768 KB Partially correct