Submission #806633

# Submission time Handle Problem Language Result Execution time Memory
806633 2023-08-04T08:26:04 Z Trisanu_Das Highway Tolls (IOI18_highway) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "highway.h"
using namespace std;
#define int long long
 
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
	int M = size(U), x = 0, u, d[2][N];
	ll least = ask(vector<int> (M));
	for(int b = 1<<17; b/=2; ) if(x + b < M) {
		vector<int> w(M);
		fill(begin(w), begin(w) + x + b, 1);
		if(ask(w) == least) x |= b;
	}
 
	array<int, 2> S = {U[x], V[x]}, ans {};
	vector<array<int, 2>> g[N], a;
	for(int i = x; i < M; i++) {
		g[U[i]].push_back({V[i], i});
		g[V[i]].push_back({U[i], i});
	}
	for(int k : {0, 1}) {
		fill(d[k], d[k] + N, N);
		queue<int> q;
		d[k][S[k]] = 0;
		q.push(S[k]);
		while(!empty(q)) {
			u = q.front(); q.pop();
			for(auto &[v, e] : g[u]) if(d[k][v] > d[k][u] + 1) d[k][v] = d[k][u] + 1, q.push(v);
		}
	}
	for(int k : {0, 1}) {
		a.clear();
		for(int i = 0; i < N; i++) if(d[k][i] < d[!k][i]) a.push_back({-d[k][i], i});
		sort(a.begin(), a.end());
		for(int b = 1<<17; b/=2; ) if(ans[k] + b < size(a)) {
			vector<int> w(M);
			fill(begin(w), begin(w) + x, 1);
			for(int i = ans[k] + b; --i >= 0; ) for(auto &[v, e] : g[a[i][1]]) w[e] = 1;
			if(ask(w) == least) ans[k] |= b;
		}
		ans[k] = a[ans[k]][1];
	}
	answer(ans[0], ans[1]);
}

Compilation message

highway.cpp: In function 'void find_pair(long long int, std::vector<long long int>, std::vector<long long int>, long long int, long long int)':
highway.cpp:8:2: error: 'll' was not declared in this scope
    8 |  ll least = ask(vector<int> (M));
      |  ^~
highway.cpp:12:10: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   12 |   if(ask(w) == least) x |= b;
      |          ^
In file included from highway.cpp:2:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp:12:16: error: 'least' was not declared in this scope
   12 |   if(ask(w) == least) x |= b;
      |                ^~~~~
highway.cpp:35:44: warning: comparison of integer expressions of different signedness: 'std::array<long long int, 2>::value_type' {aka 'long long int'} and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int b = 1<<17; b/=2; ) if(ans[k] + b < size(a)) {
highway.cpp:39:11: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   39 |    if(ask(w) == least) ans[k] |= b;
      |           ^
In file included from highway.cpp:2:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp:39:17: error: 'least' was not declared in this scope
   39 |    if(ask(w) == least) ans[k] |= b;
      |                 ^~~~~