답안 #589211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
589211 2022-07-04T10:34:43 Z Koosha_mv 통행료 (IOI18_highway) C++14
90 / 100
267 ms 15100 KB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=2e5+99;

int n,m,cnt,S,T,par[N],mark[N],f[N];
ll A,B,ST;
vector<int> w,vec,U,V;
vector<pair<int,int>> g[N];

ll Ask(vector<int> w){
  cnt++;
  if(cnt>52) assert(0);
  return ask(w);
}
void reset(int x){
  fill(all(w),x);
}
int Root(){
  int l=0,r=m;
  while(l+1<r){
    int mid=(l+r)>>1;
    reset(0);
    f(i,0,mid) w[i]=1;
    if(ST*A<Ask(w)){
      r=mid;
    }
    else{
      l=mid;
    }
  }
  return U[l];
}
int find(int x){
  fill(mark,mark+N,0);
  vector<int> vec;
  vec.pb(x);
  mark[x]=1;
  f(i,0,int(vec.size())){
    int u=vec[i];
    for(auto [v,id] : g[u]){
      if(mark[v]==0){
        vec.pb(v);
        f[v]=id;
        mark[v]=1;
      }
    }
  }
  if(vec.size()!=n) assert(0);
  int l=1,r=n;
  while(l+1<r){
    int mid=(l+r)>>1;
    reset(1);
    f(i,1,mid){
      w[f[vec[i]]]=0;
    }
    if(Ask(w)==A*ST){
      r=mid;
    }
    else{
      l=mid;
    }
  }
  return vec[l];
}

void find_pair(int _n,vector<int> _U,vector<int> _V,int _A,int _B){
  U=_U,V=_V;
  n=_n,m=U.size(),A=_A,B=_B;
  f(i,0,m){
    g[U[i]].pb({V[i],i});
    g[V[i]].pb({U[i],i});
  }
  w.resize(m);
  ST=Ask(w)/A;
  int rt=Root();
  S=find(rt);
  T=find(S);
  answer(S,T);
}
/*
3 2 1 2 1 2
0 1
1 2
*/

Compilation message

highway.cpp: In function 'int find(int)':
highway.cpp:61:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   61 |     for(auto [v,id] : g[u]){
      |              ^
highway.cpp:69:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |   if(vec.size()!=n) assert(0);
      |      ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5784 KB Output is correct
2 Correct 3 ms 5784 KB Output is correct
3 Correct 4 ms 5712 KB Output is correct
4 Correct 4 ms 5688 KB Output is correct
5 Correct 3 ms 5712 KB Output is correct
6 Correct 3 ms 5712 KB Output is correct
7 Correct 3 ms 5712 KB Output is correct
8 Correct 3 ms 5712 KB Output is correct
9 Correct 3 ms 5784 KB Output is correct
10 Correct 3 ms 5712 KB Output is correct
11 Correct 3 ms 5712 KB Output is correct
12 Correct 3 ms 5712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5840 KB Output is correct
2 Correct 16 ms 6608 KB Output is correct
3 Correct 178 ms 12860 KB Output is correct
4 Correct 172 ms 12840 KB Output is correct
5 Correct 184 ms 12844 KB Output is correct
6 Correct 220 ms 12848 KB Output is correct
7 Correct 154 ms 12848 KB Output is correct
8 Correct 148 ms 12972 KB Output is correct
9 Correct 185 ms 12852 KB Output is correct
10 Correct 188 ms 12952 KB Output is correct
11 Correct 181 ms 12296 KB Output is correct
12 Correct 182 ms 12328 KB Output is correct
13 Correct 185 ms 12424 KB Output is correct
14 Correct 161 ms 12300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 6480 KB Output is correct
2 Correct 23 ms 7312 KB Output is correct
3 Correct 34 ms 8052 KB Output is correct
4 Correct 113 ms 12300 KB Output is correct
5 Correct 104 ms 12308 KB Output is correct
6 Correct 102 ms 12292 KB Output is correct
7 Correct 107 ms 12304 KB Output is correct
8 Correct 114 ms 12284 KB Output is correct
9 Correct 106 ms 12308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5840 KB Output is correct
2 Correct 16 ms 6612 KB Output is correct
3 Correct 124 ms 11504 KB Output is correct
4 Correct 177 ms 12864 KB Output is correct
5 Correct 143 ms 12852 KB Output is correct
6 Correct 119 ms 12848 KB Output is correct
7 Correct 168 ms 12856 KB Output is correct
8 Correct 111 ms 12852 KB Output is correct
9 Correct 172 ms 12844 KB Output is correct
10 Correct 145 ms 12848 KB Output is correct
11 Correct 178 ms 12300 KB Output is correct
12 Correct 195 ms 12368 KB Output is correct
13 Correct 187 ms 12296 KB Output is correct
14 Correct 149 ms 12296 KB Output is correct
15 Correct 115 ms 12852 KB Output is correct
16 Correct 154 ms 12864 KB Output is correct
17 Correct 182 ms 12304 KB Output is correct
18 Correct 139 ms 12408 KB Output is correct
19 Correct 159 ms 12856 KB Output is correct
20 Correct 137 ms 12308 KB Output is correct
21 Correct 127 ms 13452 KB Output is correct
22 Correct 126 ms 13452 KB Output is correct
23 Correct 169 ms 13152 KB Output is correct
24 Correct 139 ms 12932 KB Output is correct
25 Correct 160 ms 12396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 6680 KB Output is correct
2 Correct 17 ms 6688 KB Output is correct
3 Correct 176 ms 13460 KB Output is correct
4 Correct 192 ms 13808 KB Output is correct
5 Correct 186 ms 14928 KB Output is correct
6 Correct 223 ms 14896 KB Output is correct
7 Correct 233 ms 14888 KB Output is correct
8 Correct 223 ms 14896 KB Output is correct
9 Correct 151 ms 13200 KB Output is correct
10 Correct 138 ms 13616 KB Output is correct
11 Correct 217 ms 14020 KB Output is correct
12 Correct 214 ms 14652 KB Output is correct
13 Correct 178 ms 14732 KB Output is correct
14 Correct 238 ms 14904 KB Output is correct
15 Correct 267 ms 14924 KB Output is correct
16 Correct 229 ms 14400 KB Output is correct
17 Correct 139 ms 13072 KB Output is correct
18 Correct 131 ms 13372 KB Output is correct
19 Correct 145 ms 13192 KB Output is correct
20 Correct 122 ms 13296 KB Output is correct
21 Correct 171 ms 14972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 6596 KB Output is correct
2 Correct 24 ms 6728 KB Output is correct
3 Correct 144 ms 13336 KB Output is correct
4 Correct 200 ms 13532 KB Output is correct
5 Correct 179 ms 13920 KB Output is correct
6 Partially correct 228 ms 14904 KB Output is partially correct
7 Partially correct 164 ms 13424 KB Output is partially correct
8 Partially correct 151 ms 13528 KB Output is partially correct
9 Partially correct 155 ms 13836 KB Output is partially correct
10 Partially correct 172 ms 14904 KB Output is partially correct
11 Partially correct 246 ms 14952 KB Output is partially correct
12 Partially correct 197 ms 15052 KB Output is partially correct
13 Correct 154 ms 13936 KB Output is correct
14 Correct 210 ms 13648 KB Output is correct
15 Correct 182 ms 13956 KB Output is correct
16 Correct 137 ms 13704 KB Output is correct
17 Correct 229 ms 13948 KB Output is correct
18 Correct 177 ms 13760 KB Output is correct
19 Correct 241 ms 14556 KB Output is correct
20 Correct 218 ms 14748 KB Output is correct
21 Partially correct 197 ms 14936 KB Output is partially correct
22 Partially correct 252 ms 14936 KB Output is partially correct
23 Partially correct 199 ms 14904 KB Output is partially correct
24 Partially correct 203 ms 14996 KB Output is partially correct
25 Partially correct 223 ms 14912 KB Output is partially correct
26 Correct 190 ms 15008 KB Output is correct
27 Partially correct 199 ms 13328 KB Output is partially correct
28 Correct 113 ms 13140 KB Output is correct
29 Partially correct 128 ms 13380 KB Output is partially correct
30 Partially correct 132 ms 13260 KB Output is partially correct
31 Correct 180 ms 13260 KB Output is correct
32 Correct 150 ms 13228 KB Output is correct
33 Correct 147 ms 13352 KB Output is correct
34 Correct 144 ms 13224 KB Output is correct
35 Partially correct 121 ms 13180 KB Output is partially correct
36 Correct 181 ms 13080 KB Output is correct
37 Partially correct 147 ms 13304 KB Output is partially correct
38 Correct 169 ms 13292 KB Output is correct
39 Partially correct 227 ms 15100 KB Output is partially correct
40 Partially correct 240 ms 15072 KB Output is partially correct
41 Partially correct 253 ms 14980 KB Output is partially correct
42 Partially correct 172 ms 14980 KB Output is partially correct