답안 #978708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978708 2024-05-09T14:16:51 Z bachhoangxuan 통행료 (IOI18_highway) C++17
23 / 100
233 ms 12100 KB
#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
#define pii pair<int,int>
#define fi first
#define se second

int dd[2][maxn];
vector<pii> edge[maxn];

void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
    vector<int> S(2,0),T(2,0);
    int M=(int)U.size();
    for(int i=0;i<M;i++){
        edge[U[i]].push_back({V[i],i});
        edge[V[i]].push_back({U[i],i});
    }

    vector<int> w(M,0);
    int dist=ask(w);
    int l=1,r=M;
    while(l<r){
        int mid=(l+r)>>1;
        w.assign(M,0);
        for(int i=0;i<mid;i++) w[i]=1;
        if(ask(w)!=dist) r=mid;
        else l=mid+1;
    }
    S[0]=U[l-1],S[1]=V[l-1];
    //cout << S[0] << ' ' << S[1] << '\n';
    for(int i=0;i<=1;i++){
        queue<int> qq;
        for(int u=0;u<N;u++) dd[i][u]=-1;
        dd[i][S[i]]=0;qq.push(S[i]);
        while(!qq.empty()){
            int u=qq.front();qq.pop();
            for(auto [v,id]:edge[u]) if(dd[i][v]==-1){
                dd[i][v]=dd[i][u]+1;
                qq.push(v);
            }
        }
    }
    vector<vector<int>> cc(2);
    for(int u=0;u<N;u++){
        if(dd[0][u]<dd[1][u]) cc[0].push_back(u);
        else if(dd[0][u]>dd[1][u]) cc[1].push_back(u);
    }

    for(int i=0;i<=1;i++){
        sort(cc[i].begin(),cc[i].end(),[&](int x,int y){
            return dd[i][x]>dd[i][y];
        });
        //for(int x:cc[i]) cout << x << ' ';
        //cout << '\n';
        T[i]=cc[i].back();
        l=0,r=(int)cc[i].size()-2;
        while(l<=r){
            int mid=(l+r)>>1;
            w.assign(M,0);
            for(int j=0;j<=mid;j++) for(auto [v,id]:edge[cc[i][j]]) w[id]=1;
            if(ask(w)!=dist) T[i]=cc[i][mid],r=mid-1;
            else l=mid+1;
        }
    }
    answer(T[0],T[1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2796 KB Output is correct
2 Correct 1 ms 2800 KB Output is correct
3 Correct 1 ms 2800 KB Output is correct
4 Correct 1 ms 2916 KB Output is correct
5 Correct 1 ms 2796 KB Output is correct
6 Correct 1 ms 2808 KB Output is correct
7 Correct 1 ms 3052 KB Output is correct
8 Correct 1 ms 2796 KB Output is correct
9 Correct 1 ms 2800 KB Output is correct
10 Correct 1 ms 2800 KB Output is correct
11 Correct 1 ms 2800 KB Output is correct
12 Correct 1 ms 2804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2856 KB Output is correct
2 Correct 9 ms 3568 KB Output is correct
3 Correct 130 ms 9424 KB Output is correct
4 Correct 114 ms 9408 KB Output is correct
5 Correct 124 ms 9396 KB Output is correct
6 Correct 90 ms 9144 KB Output is correct
7 Correct 99 ms 9580 KB Output is correct
8 Correct 124 ms 9364 KB Output is correct
9 Correct 121 ms 9168 KB Output is correct
10 Correct 105 ms 9392 KB Output is correct
11 Correct 119 ms 9352 KB Output is correct
12 Correct 113 ms 9024 KB Output is correct
13 Correct 121 ms 9260 KB Output is correct
14 Incorrect 125 ms 8536 KB Output is incorrect: {s, t} is wrong.
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 3496 KB Output is correct
2 Correct 27 ms 4324 KB Output is correct
3 Correct 31 ms 5052 KB Output is correct
4 Correct 91 ms 8816 KB Output is correct
5 Correct 78 ms 8828 KB Output is correct
6 Correct 90 ms 8768 KB Output is correct
7 Correct 77 ms 8744 KB Output is correct
8 Correct 82 ms 9064 KB Output is correct
9 Incorrect 88 ms 8552 KB Output is incorrect: {s, t} is wrong.
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2856 KB Output is correct
2 Correct 18 ms 3536 KB Output is correct
3 Correct 86 ms 8052 KB Output is correct
4 Correct 120 ms 9468 KB Output is correct
5 Correct 112 ms 9640 KB Output is correct
6 Correct 110 ms 9380 KB Output is correct
7 Correct 110 ms 9612 KB Output is correct
8 Correct 148 ms 9592 KB Output is correct
9 Incorrect 87 ms 9172 KB Output is incorrect: {s, t} is wrong.
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 3432 KB Output is correct
2 Correct 16 ms 3852 KB Output is correct
3 Correct 109 ms 10184 KB Output is correct
4 Correct 121 ms 10868 KB Output is correct
5 Correct 181 ms 11912 KB Output is correct
6 Correct 163 ms 11444 KB Output is correct
7 Correct 174 ms 12100 KB Output is correct
8 Correct 162 ms 11764 KB Output is correct
9 Correct 140 ms 8924 KB Output is correct
10 Correct 139 ms 9416 KB Output is correct
11 Correct 143 ms 9940 KB Output is correct
12 Correct 157 ms 11296 KB Output is correct
13 Correct 147 ms 11768 KB Output is correct
14 Correct 211 ms 11744 KB Output is correct
15 Correct 172 ms 11444 KB Output is correct
16 Correct 129 ms 10112 KB Output is correct
17 Correct 114 ms 10048 KB Output is correct
18 Correct 96 ms 10052 KB Output is correct
19 Correct 128 ms 9672 KB Output is correct
20 Correct 90 ms 9788 KB Output is correct
21 Correct 167 ms 11096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 3432 KB Output is correct
2 Correct 12 ms 3628 KB Output is correct
3 Correct 164 ms 10208 KB Output is correct
4 Correct 145 ms 10408 KB Output is correct
5 Correct 160 ms 10704 KB Output is correct
6 Correct 178 ms 11516 KB Output is correct
7 Correct 148 ms 9744 KB Output is correct
8 Correct 154 ms 9896 KB Output is correct
9 Correct 161 ms 10712 KB Output is correct
10 Correct 172 ms 11296 KB Output is correct
11 Correct 192 ms 11380 KB Output is correct
12 Correct 164 ms 11532 KB Output is correct
13 Correct 130 ms 9944 KB Output is correct
14 Correct 124 ms 9388 KB Output is correct
15 Correct 125 ms 10148 KB Output is correct
16 Correct 120 ms 9380 KB Output is correct
17 Correct 130 ms 9724 KB Output is correct
18 Correct 114 ms 9652 KB Output is correct
19 Correct 151 ms 11068 KB Output is correct
20 Correct 213 ms 11496 KB Output is correct
21 Correct 181 ms 11780 KB Output is correct
22 Correct 176 ms 11548 KB Output is correct
23 Correct 233 ms 11776 KB Output is correct
24 Correct 194 ms 11928 KB Output is correct
25 Correct 181 ms 11292 KB Output is correct
26 Correct 167 ms 11744 KB Output is correct
27 Correct 109 ms 9548 KB Output is correct
28 Correct 91 ms 9620 KB Output is correct
29 Correct 113 ms 9860 KB Output is correct
30 Incorrect 87 ms 9720 KB Output is incorrect: {s, t} is wrong.
31 Halted 0 ms 0 KB -