Submission #427458

# Submission time Handle Problem Language Result Execution time Memory
427458 2021-06-14T15:37:44 Z Monchito Highway Tolls (IOI18_highway) C++14
6 / 100
200 ms 4232 KB
#include "highway.h"
using namespace std;

#define sz(x) (int)x.size()

const int MAXN = 9e4;

int M;
vector<pair<int,int>> G[MAXN];
bool vis[MAXN];

vector<int> p;
long long cost;

/*
void DFS(int u, int& ans) {
	vis[u] = true;

	for(pair<int,int> v : G[u]) {
		if(!vis[v.first]) {
			p[v.second] = 1;
			if(ask(p) > cost) {
				p[v.second] = 0;
				DFS(v.first, ans);			
				return;
			}
		}	
	}

	ans = u;
}
*/

int bs1() {
	int l=1, r=M, mid, ret=-1;
	while(r >= l) {
		mid = l + (r-l)/2;		

		for(int i=0; i<mid; i++) p[i] = 1;

		if(ask(p) > cost) {
			r = mid-1;
			ret = mid-1;
		} 

		else l = mid+1;	

		for(int i=0; i<mid; i++) p[i] = 0;
	}

	return ret;
}

int bs2() {
	int l=1, r=M, mid, ret=-1;
	while(r >= l) {
		mid = l + (r-l)/2;		

		for(int i=M-1; i>=M-mid; i--) p[i] = 1;

		if(ask(p) > cost) {
			r = mid-1;
			ret = M-mid;
		} 

		else l = mid+1;	

		for(int i=M-1; i>=M-mid; i--) p[i] = 0;
	}

	return ret;
}

void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {	
	M = sz(U);
	p = vector<int>(M, 0);

	cost = ask(p);

	int s = U[bs1()], t = V[bs2()];
	answer(s, t);
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2376 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2376 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2504 KB Output is correct
2 Correct 39 ms 2752 KB Output is correct
3 Correct 67 ms 2968 KB Output is correct
4 Correct 179 ms 4232 KB Output is correct
5 Correct 99 ms 4160 KB Output is correct
6 Correct 144 ms 4164 KB Output is correct
7 Correct 111 ms 4164 KB Output is correct
8 Correct 148 ms 4156 KB Output is correct
9 Correct 200 ms 4164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2376 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 2504 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 2512 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -