Submission #78947

# Submission time Handle Problem Language Result Execution time Memory
78947 2018-10-09T17:15:58 Z wleung_bvg Highway Tolls (IOI18_highway) C++14
0 / 100
30 ms 3120 KB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define FOR(i,b) For(i,0,b)
#define Rev(i,a,b) for(auto i=(a);i>(b);i--)
#define REV(i,a) Rev(i,a,-1)
#define FORE(i,a) for(auto&&i:a)
#define sz(a) (int((a).size()))
#define MIN(a,b) ((a)=min((a),(b)))
#define MAX(a,b) ((a)=max((a),(b)))
using ll=long long;using ld=long double;using uint=unsigned int;using ull=unsigned long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pill=pair<int,ll>;using plli=pair<ll,int>;using pdd=pair<double,double>;using pld=pair<ld,ld>;
constexpr const char nl='\n',sp=' ';constexpr const int INT_INF=0x3f3f3f3f;constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f;
constexpr const double D_INF=numeric_limits<double>::infinity();constexpr const ld LD_INF=numeric_limits<ld>::infinity();constexpr const double EPS=1e-9;

const int MAXN = 90005, MAXM = 130005;

int to[MAXN], ans[2];
bool tr[MAXM];
vector<int> adj[MAXN], verts[2];

void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
    int M = sz(U), lo = 0, hi = M - 1, mid;
    FOR(i, M) {
        adj[U[i]].pb(i);
        adj[V[i]].pb(i);
    }
    vector<int> Q(M, 0);
    fill(tr, tr + M, 0);
    ll DA = ask(Q);
    while (lo < hi) {
        mid = lo + (hi - lo) / 2;
        FOR(i, M) Q[i] = i <= mid;
        if (ask(Q) == DA) lo = mid + 1;
        else hi = mid;
    }
    fill(to, to + N, -1);
    queue<pii> q;
    q.emplace(U[lo], 0);
    q.emplace(V[lo], 1);
    tr[lo] = 1;
    to[U[lo]] = to[V[lo]] = -INT_INF;
    while (!q.empty()) {
        pii v = q.front();
        q.pop();
        verts[v.s].pb(v.f);
        FORE(e, adj[v.f]) {
            int w = v.f ^ U[e] ^ V[e];
            if (to[w] != -1) continue;
            q.emplace(w, v.s);
            tr[to[w] = e] = 1;
        }
    }
    FOR(i, 2) {
        lo = 1, hi = sz(verts[i]) - 1;
        while (lo <= hi) {
            mid = lo + (hi - lo) / 2;
            FOR(j, M) Q[j] = !tr[j];
            For(j, mid, sz(verts[i])) Q[to[verts[i][j]]] = 1;
            if (ask(Q) == DA) hi = mid - 1;
            else lo = mid + 1;
        }
        ans[i] = verts[i][hi];
    }
    cout << ans[0] << sp << ans[1] << endl;
    answer(ans[0], ans[1]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2444 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2424 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 3116 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2496 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 3116 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3120 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -