답안 #406063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406063 2021-05-17T07:32:59 Z urd05 통행료 (IOI18_highway) C++14
51 / 100
200 ms 15136 KB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;

int ind[100000];
int pos[100000];
typedef pair<int,int> P;
vector<P> adj[90000];
int cnt=1;

void dfs(int v,int prev) {
    for(int i=0;i<adj[v].size();i++) {
        int nt=adj[v][i].first;
        if (nt==prev)
            continue;
        pos[adj[v][i].second]=nt;
        ind[cnt++]=adj[v][i].second;
        dfs(nt,v);
    }
}

void find_pair(int n,vector<int> u,vector<int> v,int a,int b) {
    int m=u.size();
    for(int i=0;i<u.size();i++) {
      adj[u[i]].push_back(P(v[i],i));
      adj[v[i]].push_back(P(u[i],i));
    }
    dfs(0,-1);
    vector<int> vec(m);
    int l=ask(vec)/a;
    int lo=0; //impossible
    int hi=n-1; //possible
    while (lo+1<hi) {
        int mid=(lo+hi)/2;
        for(int i=0;i<m;i++) {
            vec[i]=0;
        }
        for(int i=1;i<=mid;i++) {
            vec[ind[i]]=1;
        }
        if (ask(vec)==1LL*l*b) {
            hi=mid;
        }
        else {
            lo=mid;
        }
    }
    int v1=pos[ind[hi]];
    cnt=1;
    dfs(v1,-1);
    for(int i=0;i<m;i++) {
        vec[i]=0;
    }
    lo=0; //impossible
    hi=n-1; //possible
    while (lo+1<hi) {
        int mid=(lo+hi)/2;
        for(int i=0;i<m;i++) {
            vec[i]=0;
        }
        for(int i=1;i<=mid;i++) {
            vec[ind[i]]=1;
        }
        if (ask(vec)==1LL*l*b) {
            hi=mid;
        }
        else {
            lo=mid;
        }
    }
    int v2=pos[ind[hi]];
    answer(v1,v2);
}

Compilation message

highway.cpp: In function 'void dfs(int, int)':
highway.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<adj[v].size();i++) {
      |                 ~^~~~~~~~~~~~~~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<u.size();i++) {
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2376 KB Output is correct
2 Correct 2 ms 2376 KB Output is correct
3 Correct 3 ms 2376 KB Output is correct
4 Correct 3 ms 2376 KB Output is correct
5 Correct 2 ms 2376 KB Output is correct
6 Correct 2 ms 2388 KB Output is correct
7 Correct 2 ms 2376 KB Output is correct
8 Correct 2 ms 2376 KB Output is correct
9 Correct 3 ms 2376 KB Output is correct
10 Correct 2 ms 2376 KB Output is correct
11 Correct 2 ms 2376 KB Output is correct
12 Correct 2 ms 2376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2376 KB Output is correct
2 Correct 15 ms 3016 KB Output is correct
3 Correct 141 ms 8352 KB Output is correct
4 Correct 194 ms 8364 KB Output is correct
5 Correct 115 ms 8256 KB Output is correct
6 Correct 166 ms 8256 KB Output is correct
7 Correct 151 ms 8256 KB Output is correct
8 Correct 166 ms 8264 KB Output is correct
9 Correct 188 ms 8256 KB Output is correct
10 Correct 133 ms 8256 KB Output is correct
11 Correct 184 ms 9160 KB Output is correct
12 Correct 166 ms 9960 KB Output is correct
13 Correct 154 ms 9228 KB Output is correct
14 Correct 145 ms 9288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 3504 KB Output is correct
2 Correct 31 ms 4724 KB Output is correct
3 Correct 37 ms 6028 KB Output is correct
4 Correct 118 ms 13336 KB Output is correct
5 Correct 100 ms 13316 KB Output is correct
6 Correct 154 ms 13336 KB Output is correct
7 Correct 151 ms 13340 KB Output is correct
8 Correct 109 ms 13332 KB Output is correct
9 Correct 106 ms 13496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2376 KB Output is correct
2 Correct 15 ms 3016 KB Output is correct
3 Correct 106 ms 6972 KB Output is correct
4 Correct 136 ms 8280 KB Output is correct
5 Correct 174 ms 8252 KB Output is correct
6 Correct 168 ms 8252 KB Output is correct
7 Correct 139 ms 8316 KB Output is correct
8 Correct 129 ms 8252 KB Output is correct
9 Correct 198 ms 8252 KB Output is correct
10 Correct 186 ms 8264 KB Output is correct
11 Correct 185 ms 8704 KB Output is correct
12 Correct 145 ms 9844 KB Output is correct
13 Correct 193 ms 9332 KB Output is correct
14 Correct 187 ms 9688 KB Output is correct
15 Correct 150 ms 8248 KB Output is correct
16 Correct 105 ms 8256 KB Output is correct
17 Correct 200 ms 9420 KB Output is correct
18 Correct 133 ms 9524 KB Output is correct
19 Correct 131 ms 8248 KB Output is correct
20 Correct 130 ms 10216 KB Output is correct
21 Correct 153 ms 8400 KB Output is correct
22 Correct 157 ms 8424 KB Output is correct
23 Correct 155 ms 8464 KB Output is correct
24 Correct 160 ms 8964 KB Output is correct
25 Correct 185 ms 12800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 25 ms 14468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 15136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -