Submission #430085

# Submission time Handle Problem Language Result Execution time Memory
430085 2021-06-16T11:22:42 Z yanire Stations (IOI20_stations) C++17
0 / 100
1269 ms 540 KB
#include <bits/stdc++.h>
using namespace std;
#include "stations.h"
#define fin(i,s,n) for(auto i = s; i < n; ++i)
#define fine(i,s,n) for(auto i = s; i <= n; ++i)
#define x first
#define y second
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
template<class T> ostream& operator<<(ostream& os, vector<T> v) {
	if(v.empty()) return os << "[]";
	os << '[' << v[0];
	fin(i,1,int(v.size())) os << ',' << v[i];
	return os << ']';
}
const int maxn = 1005;
vi l;
int lid = 0;
vi g[maxn];
void dfs(int u) {
	if(l[u]!=-1) return;
	l[u] = lid++;
	for(int v : g[u]) dfs(v);
}
vi label(int n, int k, vi u, vi v) {
	l = vi(n,-1),lid = 0;
	fin(i,0,n) g[i].clear();
	fin(i,0,n-1) g[u[i]].pb(v[i]),g[v[i]].pb(u[i]);
	// fin(i,0,n) if(g[i].size()==1) { dfs(i); break; }
	iota(all(l),0);
	return l;
}
int dir(int a, int b){ 
	if(a==b) return 0;
	return b>a?1:-1;
}
bool anc(int u, int v) {
	while(v>=u) {
		if(u==v) return 1;
		v>>=1;
	}
	return 0;
}
int find_next_station(int s, int t, vi c) {
	if(anc(s,t)) {
		vi ops;
		for(int v : c) if(anc(v,t)) ops.pb(v);
		if(ops.empty()) return c[0];
		int r = ops[0];
		fin(i,1,int(ops.size())) if(anc(r,i)) r = i;
		return r;
	}
	for(int v : c) if(anc(v,s)) return v;
	return c[0];
}
# Verdict Execution time Memory Grader output
1 Incorrect 762 ms 512 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 617 ms 500 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 643 ms 500 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1269 ms 540 KB Output is correct
2 Incorrect 1182 ms 400 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 763 ms 516 KB Wrong query response.
2 Halted 0 ms 0 KB -