답안 #823263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823263 2023-08-12T10:09:54 Z Trumling 통행료 (IOI18_highway) C++14
12 / 100
182 ms 262144 KB
#include "highway.h"
#include<bits/stdc++.h>
using namespace  std;
#define F first 
#define S second 
#define all(x) x.begin(),x.end()  
typedef long long ll;
#define INF 99999999999999
#define pb  push_back

vector<vector<pair<int,int> > >g;
vector<int>d,R;


void dfs(int start,int pre)
{
    for(pair<int,int> x:g[start])
        if(x.F!=pre)
        {
            d[x.F]=d[start]+1;
            R[x.F]=x.S;
            dfs(x.F,start);
        }
}

void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
  int M = U.size();
  g.assign(N,vector<pair<int,int> >());
  d.assign(N,0);
  R.assign(N,0);
  for(int i=0;i<M;i++)
  {
    g[U[i]].pb({V[i],i});
    g[V[i]].pb({U[i],i});
  }
 dfs(0,0);
 vector<int>a(M,0);

 ll ans=ask(a);
 
 vector<int>v;
 for(int i=1;i<N;i++)
 if(d[i]==ans/A)
 {
    v.pb(R[i]);
 }

 


 ll l=0,r=v.size()-1;
 ll idx=0;
//cout<<'\n';

 while(l<r)
 {
    
    ll  mid=(l+r)/2;
    for(int  i=l;i<=mid;i++)
    a[v[i]]=(idx+1)%2;

    ll curr=ask(a);
    if(idx==0)
    {
        if(curr>ans)
        {
           r=mid; 
           idx=1;
        }
        else
        l=mid+1;
    }
    else
    {
        if(curr==ans)
        {
            r=mid;
            idx=0;
        }
        else
        l=mid+1;
    }
    //cout<<l<<' '<<r<<'\n';
 }
 for(int i=1;i<N;i++)
 if(R[i]==v[l])
 {
    ans=i;
    break;
 }
 
answer(0,ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 6 ms 1140 KB Output is correct
3 Correct 62 ms 8356 KB Output is correct
4 Correct 58 ms 8352 KB Output is correct
5 Correct 59 ms 8352 KB Output is correct
6 Correct 63 ms 8244 KB Output is correct
7 Correct 56 ms 8284 KB Output is correct
8 Correct 54 ms 8476 KB Output is correct
9 Correct 59 ms 8216 KB Output is correct
10 Correct 60 ms 8364 KB Output is correct
11 Correct 88 ms 8796 KB Output is correct
12 Correct 58 ms 9112 KB Output is correct
13 Correct 63 ms 8732 KB Output is correct
14 Correct 69 ms 8288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1488 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 182 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 168 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -