Submission #772505

#TimeUsernameProblemLanguageResultExecution timeMemory
772505ono_de206Stations (IOI20_stations)C++14
0 / 100
3 ms592 KiB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<vector<int>> g(n);
	for(int i = 0; i < n; i++) {
		g[u[i]].pb(v[i]);
		g[v[i]].pb(u[i]);
	}

	vector<int> in(n), out(n);
	int t = 0;
	auto dfs = [&](auto &self, int to, int fr) -> void {
		in[to] = t++;
		for(int x : g[to]) {
			if(x == fr) continue;
			self(self, x, to);
		}
		out[to] = t - 1;
	};
	vector<int> ret;
	for(int i = 0; i < n; i++) {
		ret.pb(in[i] * 1000 + out[i]);
	}
	return ret;
}

int find_next_station(int s, int t, vector<int> c) {
	auto isPar = [&](int x, int y) -> bool {
		return (x / 1000 <= y / 1000 && x % 1000 >= y % 1000);
	};

	int par = -1;
	for(int i = 0; i < c.size(); i++) {
		if(isPar(c[i], s)) par = i;
	}
	for(int i = 0; i < c.size(); i++) {
		if(i == par) continue;
		if(isPar(c[i], t)) return c[i];
	}
	return c[par];
}

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:30:7: warning: variable 'dfs' set but not used [-Wunused-but-set-variable]
   30 |  auto dfs = [&](auto &self, int to, int fr) -> void {
      |       ^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:51:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  for(int i = 0; i < c.size(); i++) {
      |                 ~~^~~~~~~~~~
stations.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for(int i = 0; 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...