Submission #1081513

# Submission time Handle Problem Language Result Execution time Memory
1081513 2024-08-30T06:43:04 Z GrindMachine Stations (IOI20_stations) C++17
52.3205 / 100
644 ms 1272 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define endl '\n'
#define conts continue
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) (int)a.size()

#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rev(i,s,e) for(int i = s; i >= e; --i)
#define trav(i,a) for(auto &i : a)

template<typename T>
void amin(T &x, T y){
	x = min(x,y);
}

template<typename T>
void amax(T &x, T y){
	x = max(x,y);
}

template<typename A,typename B>
string to_string(pair<A,B> p);

string to_string(const string &s){
	return "'"+s+"'";
}

string to_string(const char* s){
	return to_string((string)s);
}

string to_string(bool b){
	return b?"true":"false";
}

template<typename A>
string to_string(A v){
	string res = "{";
	trav(x,v){
		res += to_string(x)+",";
	}
	if(res.back() == ',') res.pop_back();
	res += "}";
	return res;
}

template<typename A,typename B>
string to_string(pair<A,B> p){
	return "("+to_string(p.ff)+","+to_string(p.ss)+")";
}

#define debug(x) cout << "[" << #x << "]: "; cout << to_string(x) << endl

const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int inf1 = 1e9 + 5;
const ll inf2 = (ll)1e18 + 5;

#include "stations.h"

std::vector<int> label(int n, int k, std::vector<int> U, std::vector<int> V) {
	vector<vector<int>> adj(n);
	rep(i,n-1){
		int u = U[i], v = V[i];
		adj[u].pb(v), adj[v].pb(u);
	}

	vector<int> tin(n), tout(n);
	int timer = 0;

	auto dfs1 = [&](int u, int p, auto &&dfs1) -> void{
		tin[u] = timer++;
		trav(v,adj[u]){
			if(v == p) conts;
			dfs1(v,u,dfs1);
		}
		tout[u] = timer-1;
	};

	dfs1(0,-1,dfs1);

	vector<int> ans(n);
	rep(i,n) ans[i] = tin[i]*1000+tout[i];

	// debug(ans);

	return ans;

	// std::vector<int> labels(n);
	// for (int i = 0; i < n; i++) {
	// 	labels[i] = i;
	// }
	// return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	auto in_sub = [&](int u){
		// is t in sub of u?
		int tin1 = u/1000, tout1 = u%1000;
		int tin2 = t/1000, tout2 = t%1000;
		return tin1 <= tin2 and tout1 >= tout2;
	};

	if(in_sub(s)){
		rep(i,sz(c)){
			if(c[i] < s) conts;
			if(in_sub(c[i])){
				return c[i];
			}
		}
	}
	else{
		return c[0];
	}

	assert(0);
	return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 334 ms 684 KB Output is correct
2 Correct 306 ms 684 KB Output is correct
3 Correct 641 ms 684 KB Output is correct
4 Correct 446 ms 684 KB Output is correct
5 Correct 405 ms 684 KB Output is correct
6 Correct 338 ms 684 KB Output is correct
7 Correct 317 ms 688 KB Output is correct
8 Correct 1 ms 772 KB Output is correct
9 Correct 2 ms 776 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 412 ms 768 KB Output is correct
12 Correct 288 ms 764 KB Output is correct
13 Correct 339 ms 932 KB Output is correct
14 Correct 330 ms 684 KB Output is correct
15 Correct 29 ms 776 KB Output is correct
16 Correct 33 ms 768 KB Output is correct
17 Correct 62 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 644 ms 684 KB Output is correct
2 Correct 499 ms 684 KB Output is correct
3 Correct 433 ms 684 KB Output is correct
4 Correct 2 ms 764 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 0 ms 776 KB Output is correct
7 Correct 444 ms 684 KB Output is correct
8 Correct 626 ms 684 KB Output is correct
9 Correct 487 ms 684 KB Output is correct
10 Correct 406 ms 688 KB Output is correct
11 Correct 3 ms 772 KB Output is correct
12 Correct 2 ms 788 KB Output is correct
13 Correct 2 ms 764 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 0 ms 768 KB Output is correct
16 Correct 325 ms 684 KB Output is correct
17 Correct 350 ms 684 KB Output is correct
18 Correct 370 ms 684 KB Output is correct
19 Correct 371 ms 684 KB Output is correct
20 Correct 362 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 331 ms 684 KB Partially correct
2 Partially correct 302 ms 936 KB Partially correct
3 Partially correct 644 ms 684 KB Partially correct
4 Partially correct 476 ms 684 KB Partially correct
5 Partially correct 415 ms 684 KB Partially correct
6 Partially correct 314 ms 684 KB Partially correct
7 Partially correct 321 ms 684 KB Partially correct
8 Partially correct 1 ms 768 KB Partially correct
9 Partially correct 2 ms 776 KB Partially correct
10 Partially correct 1 ms 776 KB Partially correct
11 Partially correct 316 ms 684 KB Partially correct
12 Partially correct 381 ms 684 KB Partially correct
13 Partially correct 638 ms 684 KB Partially correct
14 Partially correct 474 ms 684 KB Partially correct
15 Partially correct 416 ms 684 KB Partially correct
16 Partially correct 301 ms 688 KB Partially correct
17 Partially correct 420 ms 684 KB Partially correct
18 Partially correct 320 ms 760 KB Partially correct
19 Partially correct 339 ms 1024 KB Partially correct
20 Partially correct 331 ms 684 KB Partially correct
21 Partially correct 27 ms 768 KB Partially correct
22 Partially correct 39 ms 744 KB Partially correct
23 Partially correct 65 ms 764 KB Partially correct
24 Partially correct 3 ms 768 KB Partially correct
25 Partially correct 2 ms 776 KB Partially correct
26 Partially correct 2 ms 768 KB Partially correct
27 Partially correct 3 ms 768 KB Partially correct
28 Partially correct 0 ms 776 KB Partially correct
29 Partially correct 340 ms 684 KB Partially correct
30 Partially correct 348 ms 684 KB Partially correct
31 Partially correct 321 ms 684 KB Partially correct
32 Partially correct 357 ms 688 KB Partially correct
33 Partially correct 366 ms 684 KB Partially correct
34 Partially correct 198 ms 692 KB Partially correct
35 Partially correct 311 ms 1272 KB Partially correct
36 Partially correct 300 ms 932 KB Partially correct
37 Partially correct 321 ms 764 KB Partially correct
38 Partially correct 316 ms 768 KB Partially correct
39 Partially correct 349 ms 772 KB Partially correct
40 Partially correct 295 ms 940 KB Partially correct
41 Partially correct 324 ms 764 KB Partially correct
42 Partially correct 44 ms 768 KB Partially correct
43 Partially correct 55 ms 768 KB Partially correct
44 Partially correct 83 ms 768 KB Partially correct
45 Partially correct 107 ms 684 KB Partially correct
46 Partially correct 220 ms 684 KB Partially correct
47 Partially correct 207 ms 684 KB Partially correct
48 Partially correct 36 ms 768 KB Partially correct
49 Partially correct 28 ms 764 KB Partially correct