Submission #1068177

# Submission time Handle Problem Language Result Execution time Memory
1068177 2024-08-21T08:17:51 Z Faisal_Saqib Highway Tolls (IOI18_highway) C++17
5 / 100
68 ms 9040 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
long long ask(const std::vector<int> &w);
void answer(int s, int t);
const ll NP=1e5;
vector<pair<ll,ll>> ma[NP],tmp;
vector<int> w;
ll mi,a,b,calls=0;
int dfs(int x,int p=-1)
{
	tmp.clear();
	for(auto i:ma[x])
	{
		if(i.second!=p)
		{
			tmp.pb(i);
		}
	}
	int s=-1;
	int e=tmp.size();
	while(s+1<e)
	{
		int mid=(s+e)/2;
		for(int j=s+1;j<=mid;j++)
			w[tmp[j].first]=1;
		calls++;
		if(calls > 100)
			answer(-1,-1);
		ll cost=ask(w);
		for(int j=s+1;j<=mid;j++)
			w[tmp[j].first]=0;
		if((cost>mi)) // edge is inside
		{
			e=mid;
		}
		else{
			s=mid;
		}
	}
	if(e==(tmp.size()))
	{
		// no edge
		return x;
	}
	else
	{
		return dfs(tmp[e].second,x);
	}
}
void find_pair(int n, std::vector<int> u, std::vector<int> v, int A, int B)
{
	int m=u.size();
	w.resize(m,0);
	a=A;
	b=B;
	calls=0;
	calls++;
	if(calls > 100)
		answer(-1,-1);
	mi=ask(w);
	for(int i=0;i<n;i++)
	{
		ma[i].clear();
	}
	for(int i=0;i<m;i++)
	{
		ma[u[i]].pb({i,v[i]});
		ma[v[i]].pb({i,u[i]});
	}
	answer(0,dfs(0));
}

Compilation message

highway.cpp: In function 'int dfs(int, int)':
highway.cpp:42:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  if(e==(tmp.size()))
      |     ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 2 ms 2648 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 2 ms 2648 KB Output is correct
10 Correct 2 ms 2648 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 9 ms 3416 KB Output is correct
3 Incorrect 68 ms 9040 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 3416 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 3416 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 3416 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -