Submission #934875

# Submission time Handle Problem Language Result Execution time Memory
934875 2024-02-28T06:06:02 Z sleepntsheep Highway Tolls (IOI18_highway) C++17
0 / 100
10 ms 3416 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)
{
    vector<int>d(n,1e9),e(n,0);
    queue<pair<int,int>>q;
    q.emplace(d[0]=0,0);
    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];});

    long long need; {vector<int>qq(m,1); need=ask(qq);}

    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);
    int t=sub12(q);

    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:46:15: warning: 'e1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |     int p=u[e1],q=v[e1];
      |               ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 3160 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2896 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 3252 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 3416 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -