답안 #934878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
934878 2024-02-28T06:08:23 Z sleepntsheep 통행료 (IOI18_highway) C++17
0 / 100
8 ms 3256 KB
#include "highway.h"
#include<bits/stdc++.h>
using namespace std;

int ban[130000],n,m,a,b;std::vector<int>u,v;std::vector<std::pair<int,int>>g[90001];

int sub12(int src,long long need)
{
    vector<int>d(n,1e9),e(n,0);
    queue<pair<int,int>>q;
    q.emplace(d[src]=src,src);
    while(q.size()){auto[c,u]=q.front();q.pop();for(auto[v,i]:g[u])if(!ban[i]&&d[v]>c+1)q.emplace(d[v]=c+1,v),e[v]=i;}

    vector<int>c(n);
    iota(c.begin(),c.end(),0);
    sort(c.begin(),c.end(),[&d](int i,int v){return d[i]<d[v];});

    int z=0,l=0,r=n-1;
    while(l<=r){
        int y=(l+r)/2;
        vector<int>qq(m,0);
        for(int i=1;i<=y;++i)qq[e[c[i]]]=1;
        if (ask(qq)==need)z=c[y],r=y-1;
        else l=y+1;
    }
    return z;
}

void sub1234(){
    long long need; {vector<int>qq(m,1); need=ask(qq);}
    auto dt = need / b;
    long long light = dt * a;

    int e1,l=0,r=m-1;
    while(l<=r) {
        int y=(l+r)/2;
        vector<int>qq(m);
        for(int i=0;i<=y;++i)qq[i]=1;
        if(ask(qq)>light)r=y-1,e1=y;
        else l=y+1;
    }


    int p=u[e1],q=v[e1];
    ban[e1]=1;
    int s=sub12(p,b+(dt-1)*a);
    int t=sub12(q,need-(b+(dt-1)*a));

    answer(s,t);
}

void find_pair(int n_, std::vector<int> u_, std::vector<int> v_, int A_, int B_) {
    n=n_,u=u_,v=v_,a=A_,b=B_;m=u.size();
    for(int i=0;i<m;++i)g[u[i]].push_back({v[i],i}),g[v[i]].push_back({u[i],i});


}

Compilation message

highway.cpp: In function 'void sub1234()':
highway.cpp:44:15: warning: 'e1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |     int p=u[e1],q=v[e1];
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 2996 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 3248 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 3256 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -