Submission #106583

# Submission time Handle Problem Language Result Execution time Memory
106583 2019-04-19T06:49:12 Z tictaccat Highway Tolls (IOI18_highway) C++14
0 / 100
40 ms 1172 KB
#include "highway.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int N,A,B,M;
ll length;
vector<vector<pair<int,int>>> adj;
vector<pair<int,int>> pos;
vector<int> w;

pair<int,int> find(int L, int R) {

    //cout << L << " " << R << "\n";

    if (R-L == 1) return make_pair(L,R);

    int mid = (L+R)/2;
    
    for (int i = L; i < mid; i++) w[i] = 0;
    for (int i = mid; i < R; i++) w[i] = 1;

    ll z = ask(w);

    int k = (z-length*A)/(B-A);

    if (k == 0) return find(L,mid);
    if (k == length) return find(mid,R);

    return make_pair(mid-(length-k),mid+k);
}

void find_pair(int tempN, std::vector<int> U, std::vector<int> V, int tempA, int tempB) {

    N = tempN; A = tempA; B = tempB; M = U.size(); adj.resize(N); w.resize(M,0);

    for (int i = 0; i < M; i++) {
    adj[U[i]].push_back(make_pair(V[i],i));
    adj[V[i]].push_back(make_pair(U[i],i));
    }
    length = ask(w)/A;

    pair<int,int> res = find(0,N-1);

    cout << res.first << " " << res.second << "\n";

    answer(res.first,res.second);
   // answer(0, pos[0].first);
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 252 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 1024 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 1164 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1172 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -