답안 #429474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
429474 2021-06-16T01:11:04 Z abdzag 기지국 (IOI20_stations) C++17
0 / 100
1142 ms 708 KB
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include "stations.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define trav(a,v) for(auto& a: v)
#define sz(v) v.size()
#define all(v) v.begin(),v.end()
#define vi vector<int>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const long long inf = 2e9;

using namespace std;
vector<vector<ll>> children;
vector<bool> visited2;
vector<ll> in;
vector<ll> out;
ll counterr = 0;
void dfs(ll cur) {
	in[cur] = counterr++;
	trav(a, children[cur]) {
		dfs(a);
	}
	out[cur] = counterr++;
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	ll counter = 0;
	counterr = 0;
	vector<vector<ll>> g(n);
	rep(i, 0, n - 1) {
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	vector<int> ans(n);
	children.clear();
	visited2.clear();
	in.clear();
	out.clear();
	in.resize(n);
	out.resize(n);
	children.resize(n);
	visited2.resize(n);
	vector<int> visited(n);
	queue<ll> q;
	q.push(0);
	visited[0] = 1;
	while (!q.empty()) {
		ll cur = q.front();
		q.pop();
		trav(a, g[cur]) {
			if (!visited[a]) {
				visited[a] = 1;
				q.push(a);
				children[cur].push_back(a);
			}
		}
	}
	dfs(0);
	rep(i, 0, n)ans[i] = 2000 * in[i] + out[i];
	return ans;
}

int find_next_station(int s, int t, vector<int> c) {
	int ans = -1;
	trav(a, c) {
		if ((a / 2000) < (t / 2000) && (t / 2000) < a % 2000) {
			ans = max(ans, a);
		}
	}
	if (ans == -1)return c[0];
	return ans;
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:31:5: warning: unused variable 'counter' [-Wunused-variable]
   31 |  ll counter = 0;
      |     ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 484 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=14014
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 448 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1991
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 412 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=3, label=1157149
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1142 ms 472 KB Output is correct
2 Incorrect 826 ms 400 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 813 ms 708 KB Wrong query response.
2 Halted 0 ms 0 KB -