답안 #139115

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139115 2019-07-31T09:35:57 Z Mahdi_Jfri 통행료 (IOI18_highway) C++14
51 / 100
236 ms 11860 KB
#include "highway.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define bit(a , b) (((a)>>(b))&1)

const int maxn = 2e5 + 20;

bool hide[maxn];

int x , y , from[maxn] , to[maxn];

ll frst;

vector<int> adj[maxn] , tw;

bool is[maxn] , can[maxn];

void reval(int v)
{
	for(auto e : adj[v])
	{
		int u = from[e] ^ to[e] ^ v;
		if(!hide[u])
			tw[e] = 1;
	}
}

bool diff()
{
	for(int i = 0; i < (int)tw.size(); i++)
		tw[i] = (is[from[i]] == is[to[i]]);

	return (((frst - ask(tw)) / (y - x)) % 2 == 1);
}

void find_pair(int n, vector<int> U, vector<int> V, int A, int B)
{
	x = A , y = B;

	int m = U.size();
	for(int i = 0; i < m; i++)
	{
		tw.pb(1);
		int a = U[i] , b = V[i];

		adj[a].pb(i);
		adj[b].pb(i);

		from[i] = a , to[i] = b;
	}

	if(m == n - 1)
		frst = ask(tw);

	vector<int> ax , bx;
	for(int b = 0; b < 20; b++)
	{
		memset(is , 0 , sizeof is);
		for(int i = 0; i < n; i++)
			is[i] = bit(i , b);

		if(diff())
		{
			for(int i = 0; i < n; i++)
			{
				if(bit(i , b))
					ax.pb(i);
				else
					bx.pb(i);
			}
			break;
		}
	}

	memset(can , 1 , sizeof can);
	for(int b = 0; b < 20; b++)
	{
		if((1 << b) < (int)ax.size())
		{
			memset(is , 0 , sizeof is);
			for(int i = 0; i < (int)ax.size(); i++)
				is[ax[i]] = bit(i , b);

			if(diff())
			{
				for(int i = 0; i < (int)ax.size(); i++)
					if(!bit(i , b))
						can[ax[i]] = 0;
			}
			else
			{
				for(int i = 0; i < (int)ax.size(); i++)
					if(bit(i , b))
						can[ax[i]] = 0;
			}
		}

		if((1 << b) < (int)bx.size())
		{
			memset(is , 0 , sizeof is);
			for(int i = 0; i < (int)bx.size(); i++)
				is[bx[i]] = bit(i , b);

			if(diff())
			{
				for(int i = 0; i < (int)bx.size(); i++)
					if(!bit(i , b))
						can[bx[i]] = 0;
			}
			else
			{
				for(int i = 0; i < (int)bx.size(); i++)
					if(bit(i , b))
						can[bx[i]] = 0;
			}
		}
	}

	int S = -1 , T = -1;
	for(auto v : ax)
		if(can[v])
		{
			while(S != -1);
			S = v;
		}

	for(auto v : bx)
		if(can[v])
		{
			while(T != -1);
			T = v;
		}

	answer(S , T);
}





# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5416 KB Output is correct
2 Correct 6 ms 5500 KB Output is correct
3 Correct 6 ms 5508 KB Output is correct
4 Correct 7 ms 5416 KB Output is correct
5 Correct 7 ms 5416 KB Output is correct
6 Correct 6 ms 5416 KB Output is correct
7 Correct 7 ms 5420 KB Output is correct
8 Correct 7 ms 5416 KB Output is correct
9 Correct 6 ms 5420 KB Output is correct
10 Correct 6 ms 5368 KB Output is correct
11 Correct 6 ms 5500 KB Output is correct
12 Correct 7 ms 5504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5480 KB Output is correct
2 Correct 28 ms 6048 KB Output is correct
3 Correct 224 ms 11536 KB Output is correct
4 Correct 179 ms 11648 KB Output is correct
5 Correct 207 ms 11624 KB Output is correct
6 Correct 213 ms 11628 KB Output is correct
7 Correct 186 ms 11520 KB Output is correct
8 Correct 182 ms 11528 KB Output is correct
9 Correct 194 ms 11596 KB Output is correct
10 Correct 187 ms 11544 KB Output is correct
11 Correct 172 ms 11432 KB Output is correct
12 Correct 197 ms 11520 KB Output is correct
13 Correct 196 ms 11440 KB Output is correct
14 Correct 205 ms 11428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 6160 KB Output is correct
2 Correct 47 ms 6800 KB Output is correct
3 Correct 86 ms 7424 KB Output is correct
4 Correct 144 ms 11500 KB Output is correct
5 Correct 153 ms 11532 KB Output is correct
6 Correct 170 ms 11436 KB Output is correct
7 Correct 153 ms 11444 KB Output is correct
8 Correct 187 ms 11544 KB Output is correct
9 Correct 156 ms 11448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5416 KB Output is correct
2 Correct 37 ms 6096 KB Output is correct
3 Correct 146 ms 10264 KB Output is correct
4 Correct 209 ms 11692 KB Output is correct
5 Correct 211 ms 11636 KB Output is correct
6 Correct 204 ms 11540 KB Output is correct
7 Correct 193 ms 11656 KB Output is correct
8 Correct 190 ms 11532 KB Output is correct
9 Correct 195 ms 11560 KB Output is correct
10 Correct 232 ms 11532 KB Output is correct
11 Correct 236 ms 11456 KB Output is correct
12 Correct 202 ms 11436 KB Output is correct
13 Correct 209 ms 11500 KB Output is correct
14 Correct 216 ms 11452 KB Output is correct
15 Correct 192 ms 11532 KB Output is correct
16 Correct 207 ms 11540 KB Output is correct
17 Correct 205 ms 11432 KB Output is correct
18 Correct 209 ms 11432 KB Output is correct
19 Correct 199 ms 11568 KB Output is correct
20 Correct 226 ms 11444 KB Output is correct
21 Correct 189 ms 11792 KB Output is correct
22 Correct 182 ms 11860 KB Output is correct
23 Correct 191 ms 11788 KB Output is correct
24 Correct 202 ms 11796 KB Output is correct
25 Correct 219 ms 11476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 5992 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 5996 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -