Submission #411585

# Submission time Handle Problem Language Result Execution time Memory
411585 2021-05-25T14:41:26 Z AKaan37 Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long lo; 
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 1005;
const lo mod = 1000000007;

vector<int> vec[li],vv;

inline void dfs(int node,int ata){
	//~ cout<<node<<endl;
	vv.pb(node);
	for(auto go:vec[node]){
		if(go==ata)continue;
		dfs(go,node);
	}
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> vvv) {
	std::vector<int> labels(n);
	for(int i=0;i<n-1;i++){
		vec[u[i]].pb(vvv[i]);
		vec[vvv[i]].pb(u[i]);
	}
	int ind=0;
	for(int i=0;i<n;i++){
		if((int)vec[i].size()==1)ind=i;
	}
	//~ cout<<ind<<endl;
	dfs(ind,-1);
	//~ for(auto go:vv)printf("%d **\n",go);
	for (int i = 0; i < n; i++) {
		//~ cout<<vv[i]<<endl;
		labels[i] = i;
	}
	return labels;
}

inline int f(int sira,int hedef){
	int cevv=0;
	if(sira>hedef)return 0;
	if(sira==hedef)return 1;
	cevv=max(cevv,f(sira*2+1,hedef));
	cevv=max(cevv,f(sira*2+2,hedef));
	return cevv;
}

int find_next_station(int s, int t, std::vector<int> c) {
	//~ cout<<s<<" :: "<<t<<" :: "<<c[0]<<" :: "<<c[1]<<endl;
	if((int)c.size()==2){
		if(f(c[0],t))return c[0];
		else return c[1];
	}
	if(f(c[1],t))return c[1];
	if(f(c[2],t))return c[2];
	return c[0];
}
# Verdict Execution time Memory Grader output
1 Runtime error 2315 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3131 ms 1051164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2163 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1002 ms 400 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3163 ms 1667420 KB Time limit exceeded
2 Halted 0 ms 0 KB -