Submission #125504

# Submission time Handle Problem Language Result Execution time Memory
125504 2019-07-05T13:52:55 Z TuGSGeReL Highway Tolls (IOI18_highway) C++17
5 / 100
362 ms 262148 KB
#include "highway.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
 
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
 
int mn, m, a, b, par[90000], num[90000];
vector <pii> edg[90000];
vector <int> check, arr;
 
void dfs(int u, int pr)
{
	arr.pub(u);
	
	for (auto x : edg[u])
	{
		if ( x.ff != pr )
		{
			par[x.ff] = u;
			num[x.ff] = x.ss;
			dfs(x.ff, u);
		}
	}
}
 
bool shal(int k, int p)
{
	for (int i = k; i <= p; i++)
		check[num[arr[i]]] = 0;
	
	if ( ask(check) > mn )
		return 1;
	
	return 0;
}
 
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
	for (int i = 0; i < U.size(); i++)
	{
		edg[U[i]].pub(mp(V[i], i));
		edg[V[i]].pub(mp(U[i], i));
	}
	
	m = U.size();
	
	for (int i = 0; i < m; i++)
		check.pub(0);
	
	dfs(0, -1);
	mn = ask(check);
	int l = 1, r = arr.size() - 1;

	for (int i = 0; i < m; i++)
		check[i] = 1;
	
	while (l != r)
	{
		int mid = (l + r) / 2;
		
		if ( shal(l, mid) )
			l = mid + 1;
		
		else
		{
			r = mid;
			
			for ( int i = l; i <= mid; i++)
				check[num[arr[i]]] = 1;
		}
	}
	
	a = arr[l];
	arr.clear();
	dfs(a, -1);
	l = 1, r = arr.size() - 1;
	
	for (int i = 0; i < m; i++)
		check[i] = 1;
	
	while (l != r)
	{
		int mid = (l + r) / 2;
		
		if ( shal(l, mid) )
			l = mid + 1;
		
		else
		{
			r = mid;
			
			for ( int i = l; i <= mid; i++)
				check[num[arr[i]]] = 1;
		}
	}
	
	b = arr[l];
	answer(a, b);
}

Compilation message

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:56:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < U.size(); i++)
                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2424 KB Output is correct
2 Correct 4 ms 2424 KB Output is correct
3 Correct 4 ms 2424 KB Output is correct
4 Correct 4 ms 2424 KB Output is correct
5 Correct 4 ms 2424 KB Output is correct
6 Correct 4 ms 2424 KB Output is correct
7 Correct 4 ms 2344 KB Output is correct
8 Correct 4 ms 2552 KB Output is correct
9 Correct 4 ms 2424 KB Output is correct
10 Correct 4 ms 2424 KB Output is correct
11 Correct 3 ms 2344 KB Output is correct
12 Correct 4 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2424 KB Output is correct
2 Correct 24 ms 3196 KB Output is correct
3 Correct 192 ms 9052 KB Output is correct
4 Correct 216 ms 9020 KB Output is correct
5 Correct 200 ms 9032 KB Output is correct
6 Correct 216 ms 9032 KB Output is correct
7 Correct 206 ms 9036 KB Output is correct
8 Correct 189 ms 9056 KB Output is correct
9 Correct 209 ms 9040 KB Output is correct
10 Correct 204 ms 9048 KB Output is correct
11 Correct 223 ms 10196 KB Output is correct
12 Correct 225 ms 10928 KB Output is correct
13 Correct 220 ms 10300 KB Output is correct
14 Incorrect 217 ms 9588 KB Output is incorrect: {s, t} is wrong.
# Verdict Execution time Memory Grader output
1 Correct 23 ms 3912 KB Output is correct
2 Correct 48 ms 5396 KB Output is correct
3 Correct 61 ms 6812 KB Output is correct
4 Correct 176 ms 15336 KB Output is correct
5 Correct 175 ms 15332 KB Output is correct
6 Correct 171 ms 15252 KB Output is correct
7 Correct 169 ms 15368 KB Output is correct
8 Correct 158 ms 15260 KB Output is correct
9 Incorrect 203 ms 15252 KB Output is incorrect: {s, t} is wrong.
# Verdict Execution time Memory Grader output
1 Correct 9 ms 2512 KB Output is correct
2 Correct 22 ms 3148 KB Output is correct
3 Correct 154 ms 7728 KB Output is correct
4 Correct 191 ms 9028 KB Output is correct
5 Correct 210 ms 9032 KB Output is correct
6 Correct 201 ms 9032 KB Output is correct
7 Correct 201 ms 9028 KB Output is correct
8 Correct 199 ms 9024 KB Output is correct
9 Incorrect 204 ms 9028 KB Output is incorrect: {s, t} is wrong.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 362 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 349 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -