Submission #772610

#TimeUsernameProblemLanguageResultExecution timeMemory
772610khshgStations (IOI20_stations)C++14
8 / 100
845 ms508 KiB
#include"stations.h"
#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> adj;

vector<int> label(int N, int K, vector<int> u, vector<int> v) {
	vector<int> labels(N); iota(begin(labels), end(labels), 0);
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	vector<int> S, T;
	int start = s, target = t;
	while(s > 0) {
		S.push_back(s);
		s = (s - 1) / 2;
	}
	while(t > 0) {
		T.push_back(t);
		t = (t - 1) / 2;
	}
	int LCA = 0;
	while((int)S.size() && (int)T.size() && S.back() == T.back()) {
		LCA = S.back();
		S.pop_back();
		T.pop_back();
	}
	if(LCA == start) {
		return T.back();
	}
	return (start - 1) / 2;
}

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:14:17: warning: unused variable 'target' [-Wunused-variable]
   14 |  int start = s, target = t;
      |                 ^~~~~~
#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...