Submission #139389

# Submission time Handle Problem Language Result Execution time Memory
139389 2019-07-31T15:39:15 Z CaroLinda Highway Tolls (IOI18_highway) C++14
0 / 100
46 ms 3240 KB
#include "highway.h"
#include <bits/stdc++.h>

#define debug //
#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair

const int MAXN = 9e4+ 10 ;
const int MAXM = 13e4+10 ;

using namespace std ;

struct Edge
{

	int j , id ;

	Edge(int j = 0 , int id = 0) 
		: j(j) , id(id) {}

} ;

int n , m , S = 0 , T ;

ll dist , tot ;

int v[MAXM] , u[MAXM] ;

vector<int> toAsk ;

vector<Edge> adj[MAXN] ;

pii edge[MAXM] ;

bool marc[MAXM] ;

// --------------------------------

void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
  
  m = U.size();
  n = N ;
  lp(i,0,m) u[i] = U[i] , v[i] = V[i] ;

  lp(i,0,m)
  {

  		
  	int a = u[i] , b = v[i] ;

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

  	toAsk.pb(0) ;

  	edge[i] = mk(a,b) ;

  }

  tot = ask(toAsk) ;

  int cur = 0 ;
  
  while(true)
  {


  	int l = 0 , r = adj[cur].size() - 1 , best = -1 ;

  	while( l <= r )
  	{
  		int mid = (l+r)/2 ;

  		lp(i,0,m) toAsk[i] = 0 ;

  		lp(i , l , mid+1 ) 
  			if(!marc[ adj[cur][i].id ])
  			{
  				toAsk[ adj[cur][i].id ] = 1 ;
  				marc[ adj[cur][i].id ] = true ;
  			}

  		ll newTot = ask(toAsk) ;

  		if( A < B ? newTot > tot : newTot < tot ) { best = mid ; r = mid-1 ; }
  		else l = mid+1 ;

  	}


  	if(best == -1) { T = cur ; break ; }

  	cur = adj[cur][best].j ;

  }


  answer(S,T) ;

}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2424 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2516 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 3024 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2472 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 3240 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 3228 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -