답안 #1005844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005844 2024-06-23T07:00:39 Z irmuun 통행료 (IOI18_highway) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
//#include "highway.h"
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

const int maxn=9e4+5;

int n,m,u,v,a,b;

vector<pair<int,int>>adj[maxn];
vector<int>par(maxn,0),dep(maxn,0),edge(maxn,0),w;
vector<bool>used(maxn);

void dfs(int x,int p){
    par[x]=p;
    for(auto [y,e]:adj[x]){
        if(y!=p){
            dep[y]=dep[x]+1;
            edge[y]=e;
            dfs(y,x);
        }
    }
}


void find_pair(int N,vector<int>U,vector<int>V,int A, int B){
    n=N,u=U,v=V,a=A,b=B;
    m=u.size();
    w.resize(m);
    fill(all(w),0);
    for(int i=0;i<m;i++){
        adj[u[i]].pb({v[i],i});
        adj[v[i]].pb({u[i],i});
    }
    ll C=ask(w);
    dep[0]=0;
    dfs(0,-1);
    vector<int>ver;
    for(int i=1;i<n;i++){
        if((ll)dep[i]*(ll)a==C){
            ver.pb(i);
        }
    }
    int l=0,r=ver.size()-1;
    while(l<r){
        int mid=(l+r)/2;
        fill(all(w),0);
        for(int i=0;i<=mid;i++){
            w[edge[ver[i]]]=1;
        }
        ll cost=ask(w);
        if(cost>C){
            r=mid;
        }
        else{
            l=mid+1;
        }
    }
    answer(0,ver[l]);
    return;
}

Compilation message

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:34:11: error: cannot convert 'std::vector<int>' to 'int' in assignment
   34 |     n=N,u=U,v=V,a=A,b=B;
      |           ^
      |           |
      |           std::vector<int>
highway.cpp:34:15: error: cannot convert 'std::vector<int>' to 'int' in assignment
   34 |     n=N,u=U,v=V,a=A,b=B;
      |               ^
      |               |
      |               std::vector<int>
highway.cpp:35:9: error: request for member 'size' in 'u', which is of non-class type 'int'
   35 |     m=u.size();
      |         ^~~~
highway.cpp:39:14: error: invalid types 'int[int]' for array subscript
   39 |         adj[u[i]].pb({v[i],i});
      |              ^
highway.cpp:39:24: error: invalid types 'int[int]' for array subscript
   39 |         adj[u[i]].pb({v[i],i});
      |                        ^
highway.cpp:40:14: error: invalid types 'int[int]' for array subscript
   40 |         adj[v[i]].pb({u[i],i});
      |              ^
highway.cpp:40:24: error: invalid types 'int[int]' for array subscript
   40 |         adj[v[i]].pb({u[i],i});
      |                        ^
highway.cpp:42:10: error: 'ask' was not declared in this scope
   42 |     ll C=ask(w);
      |          ^~~
highway.cpp:66:5: error: 'answer' was not declared in this scope
   66 |     answer(0,ver[l]);
      |     ^~~~~~