Submission #639119

#TimeUsernameProblemLanguageResultExecution timeMemory
639119ghostwriterStations (IOI20_stations)C++14
0 / 100
3061 ms2097152 KiB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#include "stub.cpp"
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
    Tran The Bao
    CTL - Da Lat
    Cay ngay cay dem nhung deo duoc cong nhan
*/
const int MAXN = 1e3 + 5;
int N;
vi adj[MAXN];
namespace subtask1 {
	int cnt = 0;
	vi ans;
	void dfs(int u, int p) {
		ans[u] = cnt++;
		EACH(v, adj[u]) {
			if (v == p) continue;
			dfs(v, u);
		}
	}
	vi label() {
		int root = 0;
		FOR(i, 0, N - 1)
			if (sz(adj[i]) == 1)
				root = i;
		ans.resize(N, 0);
		dfs(root, 0);
		return ans;
	}	
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	N = n;
	FOR(i, 0, n - 2) {
		int ui = u[i], vi = v[i];
		adj[ui].pb(vi);
		adj[vi].pb(ui);
	}
	int maxdeg = 0;
	FOR(i, 0, n - 1) maxdeg = max(maxdeg, sz(adj[i]));
	if (k == 1000 && maxdeg <= 2) return subtask1::label();
}

int find_next_station(int s, int t, std::vector<int> c) {
	int Min = MAXN, Max = 0;
	EACH(u, c) {
		Min = min(Min, u);
		Max = max(Max, u);
	}
	if (s < t) return Max;
	return Min;
}

Compilation message (stderr)

stations.cpp: In function 'void subtask1::dfs(int, int)':
stations.cpp:29:31: warning: unnecessary parentheses in declaration of 'v' [-Wparentheses]
   29 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
stations.cpp:47:3: note: in expansion of macro 'EACH'
   47 |   EACH(v, adj[u]) {
      |   ^~~~
stations.cpp: In function 'vi subtask1::label()':
stations.cpp:27:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   27 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
stations.cpp:54:3: note: in expansion of macro 'FOR'
   54 |   FOR(i, 0, N - 1)
      |   ^~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:27:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   27 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
stations.cpp:64:2: note: in expansion of macro 'FOR'
   64 |  FOR(i, 0, n - 2) {
      |  ^~~
stations.cpp:27:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   27 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
stations.cpp:70:2: note: in expansion of macro 'FOR'
   70 |  FOR(i, 0, n - 1) maxdeg = max(maxdeg, sz(adj[i]));
      |  ^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:29:31: warning: unnecessary parentheses in declaration of 'u' [-Wparentheses]
   29 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
stations.cpp:76:2: note: in expansion of macro 'EACH'
   76 |  EACH(u, c) {
      |  ^~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:72:1: warning: control reaches end of non-void function [-Wreturn-type]
   72 | }
      | ^
#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...