Submission #293940

# Submission time Handle Problem Language Result Execution time Memory
293940 2020-09-08T13:54:21 Z Trickster Highway Tolls (IOI18_highway) C++14
100 / 100
628 ms 24012 KB
#include <algorithm>
#include "highway.h"
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define maxN 200010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <ll, ll>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
ll bigmod(ll a,ll e) {if(e==0)return 1;ll x=bigmod(a*a%mod,e>>1);return e&1?x*a%mod:x;}

int L[maxN];
int n, m, dis;
vector <pii> E[maxN];
vector <int> T[maxN];

int tap(vector <int> v)
{
    int sz = v.size();
    int l = 0, r = sz-1, md, in = 0;
    while(l <= r) {
        md = (l+r)/2;

        vector <int> arr;
        for(int i = 0; i < m; i++) arr.pb(0);

        for(int i = md; i < sz; i++)
            for(auto h: E[v[i]])
                arr[h.ss] = 1;

        int cur = ask(arr);

        if(dis != cur) l = md+1, in = md;
        else r = md-1;
    }
    return v[in];
}

void find_pair(int N, vector <int> U, vector <int> V, int A, int B) 
{
    m = U.size(), n = N;

    for(int i = 0; i < m; i++) {
        E[U[i]].pb({V[i], i});
        E[V[i]].pb({U[i], i});
    }

    vector <int> arr;
    for(int i = 0; i < m; i++) arr.pb(0);

    dis = ask(arr);

    int l = 0, r = m-1, md, in = 0;
    while(l <= r) {
        md = (l+r)/2;

        vector <int> arr;
        for(int i = 0; i < m; i++) arr.pb((i <= md ? 1 : 0));

        int cur = ask(arr);

        if(dis != cur) r = md-1, in = md;
        else l = md+1;
    }

    // cout << in << " " << U[in] << " " << V[in] << "\n";

    queue <pii> Q;
    vector <int> C, D;

    Q.push({U[in], 1});
    Q.push({V[in], 2});
    
    L[U[in]] = 1;
    L[V[in]] = 2;
    while(!Q.empty()) {
        int nd = Q.front().ff;
        int tp = Q.front().ss;
        Q.pop();

        if(tp == 1) C.pb(nd);
        if(tp == 2) D.pb(nd);

        for(auto i: E[nd]) {
            int to = i.ff;
            
            if(L[to]) continue;

            L[to] = tp;
            Q.push({to, tp});
            T[to].pb(i.ss);
        }
    }
    // for(auto i: C)
    // 	for(auto h: T[i])
    // 		cout << U[h] << " " << V[h] << "\n";

    // cout << tap(C) << " " << tap(D) << "\n";

    answer(tap(C), tap(D));
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9704 KB Output is correct
2 Correct 7 ms 9776 KB Output is correct
3 Correct 7 ms 9728 KB Output is correct
4 Correct 7 ms 9728 KB Output is correct
5 Correct 7 ms 9780 KB Output is correct
6 Correct 7 ms 9728 KB Output is correct
7 Correct 7 ms 9728 KB Output is correct
8 Correct 7 ms 9728 KB Output is correct
9 Correct 7 ms 9728 KB Output is correct
10 Correct 9 ms 9728 KB Output is correct
11 Correct 8 ms 9720 KB Output is correct
12 Correct 8 ms 9728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 9848 KB Output is correct
2 Correct 30 ms 11008 KB Output is correct
3 Correct 319 ms 20992 KB Output is correct
4 Correct 296 ms 20968 KB Output is correct
5 Correct 303 ms 20972 KB Output is correct
6 Correct 235 ms 20984 KB Output is correct
7 Correct 330 ms 20976 KB Output is correct
8 Correct 478 ms 20992 KB Output is correct
9 Correct 478 ms 21096 KB Output is correct
10 Correct 288 ms 20984 KB Output is correct
11 Correct 409 ms 20888 KB Output is correct
12 Correct 319 ms 20796 KB Output is correct
13 Correct 396 ms 20864 KB Output is correct
14 Correct 351 ms 20820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 10880 KB Output is correct
2 Correct 50 ms 12164 KB Output is correct
3 Correct 75 ms 13316 KB Output is correct
4 Correct 182 ms 20668 KB Output is correct
5 Correct 193 ms 20616 KB Output is correct
6 Correct 217 ms 20588 KB Output is correct
7 Correct 156 ms 20616 KB Output is correct
8 Correct 170 ms 20704 KB Output is correct
9 Correct 172 ms 20640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9856 KB Output is correct
2 Correct 25 ms 11008 KB Output is correct
3 Correct 243 ms 18700 KB Output is correct
4 Correct 369 ms 20968 KB Output is correct
5 Correct 438 ms 20976 KB Output is correct
6 Correct 418 ms 20964 KB Output is correct
7 Correct 458 ms 20968 KB Output is correct
8 Correct 410 ms 21032 KB Output is correct
9 Correct 373 ms 20972 KB Output is correct
10 Correct 331 ms 21020 KB Output is correct
11 Correct 392 ms 20808 KB Output is correct
12 Correct 313 ms 20796 KB Output is correct
13 Correct 346 ms 20776 KB Output is correct
14 Correct 415 ms 20816 KB Output is correct
15 Correct 447 ms 20988 KB Output is correct
16 Correct 431 ms 20976 KB Output is correct
17 Correct 335 ms 20776 KB Output is correct
18 Correct 326 ms 20796 KB Output is correct
19 Correct 398 ms 20988 KB Output is correct
20 Correct 451 ms 20900 KB Output is correct
21 Correct 201 ms 22136 KB Output is correct
22 Correct 174 ms 21988 KB Output is correct
23 Correct 244 ms 21284 KB Output is correct
24 Correct 241 ms 21248 KB Output is correct
25 Correct 239 ms 20812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 11000 KB Output is correct
2 Correct 32 ms 11128 KB Output is correct
3 Correct 273 ms 21708 KB Output is correct
4 Correct 376 ms 22440 KB Output is correct
5 Correct 500 ms 24012 KB Output is correct
6 Correct 536 ms 23928 KB Output is correct
7 Correct 625 ms 23828 KB Output is correct
8 Correct 434 ms 23804 KB Output is correct
9 Correct 255 ms 20008 KB Output is correct
10 Correct 261 ms 20716 KB Output is correct
11 Correct 298 ms 21548 KB Output is correct
12 Correct 450 ms 22912 KB Output is correct
13 Correct 495 ms 23400 KB Output is correct
14 Correct 558 ms 23788 KB Output is correct
15 Correct 519 ms 23812 KB Output is correct
16 Correct 368 ms 21624 KB Output is correct
17 Correct 276 ms 22124 KB Output is correct
18 Correct 360 ms 22464 KB Output is correct
19 Correct 192 ms 22132 KB Output is correct
20 Correct 370 ms 22304 KB Output is correct
21 Correct 559 ms 23676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 11000 KB Output is correct
2 Correct 34 ms 11136 KB Output is correct
3 Correct 474 ms 21812 KB Output is correct
4 Correct 486 ms 21992 KB Output is correct
5 Correct 496 ms 22356 KB Output is correct
6 Correct 499 ms 23732 KB Output is correct
7 Correct 450 ms 21840 KB Output is correct
8 Correct 506 ms 22156 KB Output is correct
9 Correct 536 ms 22460 KB Output is correct
10 Correct 548 ms 23852 KB Output is correct
11 Correct 552 ms 23760 KB Output is correct
12 Correct 538 ms 23880 KB Output is correct
13 Correct 271 ms 21520 KB Output is correct
14 Correct 264 ms 20648 KB Output is correct
15 Correct 266 ms 21616 KB Output is correct
16 Correct 241 ms 20624 KB Output is correct
17 Correct 254 ms 21596 KB Output is correct
18 Correct 289 ms 20720 KB Output is correct
19 Correct 489 ms 22916 KB Output is correct
20 Correct 492 ms 23432 KB Output is correct
21 Correct 575 ms 23872 KB Output is correct
22 Correct 542 ms 23792 KB Output is correct
23 Correct 623 ms 23720 KB Output is correct
24 Correct 510 ms 23812 KB Output is correct
25 Correct 612 ms 23928 KB Output is correct
26 Correct 628 ms 23832 KB Output is correct
27 Correct 249 ms 22336 KB Output is correct
28 Correct 316 ms 22092 KB Output is correct
29 Correct 373 ms 22740 KB Output is correct
30 Correct 274 ms 22276 KB Output is correct
31 Correct 278 ms 22280 KB Output is correct
32 Correct 366 ms 22108 KB Output is correct
33 Correct 238 ms 22652 KB Output is correct
34 Correct 302 ms 22284 KB Output is correct
35 Correct 338 ms 22184 KB Output is correct
36 Correct 369 ms 22060 KB Output is correct
37 Correct 369 ms 22552 KB Output is correct
38 Correct 251 ms 22216 KB Output is correct
39 Correct 587 ms 23640 KB Output is correct
40 Correct 554 ms 23828 KB Output is correct
41 Correct 331 ms 23664 KB Output is correct
42 Correct 386 ms 23680 KB Output is correct