제출 #683584

#제출 시각아이디문제언어결과실행 시간메모리
683584whqkrtk04기지국 (IOI20_stations)C++17
52.32 / 100
995 ms732 KiB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
#define fi first
#define se second
const int INF = 1e9+1;
const int P = 1000000007;
const ll LLINF = (ll)1e18+1;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) { os << p.fi << " " << p.se; return os; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { for(auto i : v) os << i << " "; os << "\n"; return os; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<int>(x, y)(rng)

const int MAX = 1000;

void dfs(int x, int &cnt, vector<vector<int>> &E, vector<int> &I, vector<int> &O, vector<bool> &vis) {
	if(vis[x]) return;
	vis[x] = true; I[x] = cnt++;
	for(auto i : E[x]) dfs(i, cnt, E, I, O, vis);
	O[x] = cnt;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	int cnt = 0;
	vector<bool> vis(n, false);
	vector<int> I(n), O(n);
	vector<vector<int>> E(n);
	for(int i = 0; i+1 < n; i++) {
		E[u[i]].push_back(v[i]);
		E[v[i]].push_back(u[i]);
	}
	dfs(0, cnt, E, I, O, vis);
	//cout << I << O;
	vector<int> ret(n);
	for(int i = 0; i < n; i++) ret[i] = I[i]*MAX+(O[i]-I[i]-1);
	return ret;
}

pii parse(int x) { return {x/MAX, x/MAX+x%MAX+1}; }

int find_next_station(int s, int t, vector<int> c) {
	pii S = parse(s), T = parse(t);
	//cout << S << "  " << T << "\n";
	if(T.fi < S.fi || T.fi >= S.se) return c[0];
	for(int i = 1; i < c.size(); i++) {
		pii tmp = parse(c[i]);
		if(tmp.fi <= T.fi && T.fi < tmp.se) return c[i];
	}
	return c[0];
}

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for(int i = 1; i < c.size(); i++) {
      |                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...