Submission #1041311

# Submission time Handle Problem Language Result Execution time Memory
1041311 2024-08-01T21:02:24 Z HD1 Stations (IOI20_stations) C++14
5 / 100
558 ms 48560 KB
#include "stations.h"
#include<bits/stdc++.h>
#define ss second
#define all(s) s.begin(),s.end()
#define sz(s) ll(s.size())
#define pb push_back
typedef long long ll;
const ll MAX=1e6;
using namespace std;
ll marc=1, q;
vector<ll> gfo[MAX];
ll m[MAX];
bool vst[MAX];
void dfs(int u, int f){
	m[u]=marc;
	//cout<<u<<'.'<<m[u]<<' ';
	for(auto v:gfo[u]){
		if(v!=f){
			marc+=q;
			dfs(v,u);
		}
	}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
	vector<int> labels(n);
	for(int i=0; i<sz(u); i++){
		gfo[u[i]].pb(v[i]);
		gfo[v[i]].pb(u[i]);
	}
	bool xd=false;
	for(int i=0; i<n; i++){
		if(sz(gfo[i])>2){
			cout<<i<<'\n';
			q=sz(gfo[i]);
			m[i]=0;
			for(int j=0; j<sz(gfo[i]); j++){
				int v=gfo[i][j];
				marc=j+1;
				dfs(v, i);
				cout<<'\n';
			}
			xd=true;
			break;
		}
	}
	if(!xd){
		marc=1;
		q=1;
		for(int i=0; i<n; i++){
			if(sz(gfo[i])==1 && m[i]==0) dfs(i, i);
		}
		
	}
	for(int i=0; i<n; i++){
		labels[i]=m[i];
		m[i]=0;
		gfo[i].clear();
	}
	return labels;
}
int find_next_station(int s, int t, vector<int> c){
	sort(all(c));
	// cout<<s<<' '<<t<<' '<<' ';
	// for(auto x:c){
	// 	cout<<x<<' ';
	// }
	// cout<<'\n';
	ll md=abs(c[sz(c)-1]-s);
	if(s==0 || t==0){
		if(s==0){
			for(auto x:c){
				if(x%md==t%md){
					return x;
				}
			}
		}
		return c[0];
	}
	if(s%md != t%md){
		return c[0];
	}
	if(t>s){
		return c[sz(c)-1];
	}
	return c[0];
}
# Verdict Execution time Memory Grader output
1 Correct 312 ms 48556 KB Output is correct
2 Correct 271 ms 48452 KB Output is correct
3 Correct 505 ms 48300 KB Output is correct
4 Correct 383 ms 48044 KB Output is correct
5 Correct 366 ms 48044 KB Output is correct
6 Correct 279 ms 48044 KB Output is correct
7 Correct 260 ms 48556 KB Output is correct
8 Correct 14 ms 48432 KB Output is correct
9 Correct 18 ms 48432 KB Output is correct
10 Correct 16 ms 48172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 24660 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 308 ms 48560 KB Output is correct
2 Correct 257 ms 48556 KB Output is correct
3 Correct 556 ms 48300 KB Output is correct
4 Correct 397 ms 48044 KB Output is correct
5 Correct 359 ms 48300 KB Output is correct
6 Correct 249 ms 48560 KB Output is correct
7 Correct 263 ms 48556 KB Output is correct
8 Correct 12 ms 48412 KB Output is correct
9 Correct 16 ms 48404 KB Output is correct
10 Correct 16 ms 48184 KB Output is correct
11 Runtime error 9 ms 23884 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 558 ms 48048 KB Output is correct
2 Correct 388 ms 48300 KB Output is correct
3 Correct 312 ms 48044 KB Output is correct
4 Correct 17 ms 48276 KB Output is correct
5 Correct 16 ms 48552 KB Output is correct
6 Correct 15 ms 48176 KB Output is correct
7 Runtime error 9 ms 23896 KB Execution killed with signal 13
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 328 ms 48556 KB Output is correct
2 Correct 269 ms 48556 KB Output is correct
3 Correct 511 ms 48300 KB Output is correct
4 Correct 388 ms 48300 KB Output is correct
5 Correct 374 ms 48300 KB Output is correct
6 Correct 286 ms 48556 KB Output is correct
7 Correct 256 ms 48556 KB Output is correct
8 Correct 16 ms 48440 KB Output is correct
9 Correct 16 ms 48172 KB Output is correct
10 Correct 15 ms 48176 KB Output is correct
11 Runtime error 8 ms 24408 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -