Submission #1078232

#TimeUsernameProblemLanguageResultExecution timeMemory
1078232woodHighway Tolls (IOI18_highway)C++17
18 / 100
137 ms3256 KiB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vi vector<int>
#define vp32 vector<p32>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//never guess
//never debug without reviewing code
//never try adding ones or substracting them
//only step by step debug when necessay


void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
    int m = U.size();
    ll curxor = 0, curs = 0;
    int x = 1, p = 0;
    while(x<N){
        vi w(m,1);
        for(int i = 0; i<m; i++){
            if((U[i]&x)^(V[i]&x))  w[i] = 0;
        }
        curxor+=(ask(w)&1)<<p;
        x<<=1;
        p++;
    }
    x = 1, p = 0;
    while(x<N){
        vi w(m,1);
        bool done[N]; memset(done,0,sizeof done);
        bool include[N]; memset(include,0,sizeof include);
        int mask = (x<<1)-1;
        for(int i = 0; i<N; i++){
            if(done[i])continue;
            if((i&mask)==curs){
                include[i] = true;
                done[i] = true;
                if((i^curxor)<N)
                done[i^curxor] = true;
            }
        }
        for(int i = 0; i<m; i++){
            if(include[U[i]]^include[V[i]]) w[i] = 0;
        }
        curs+=(!(ask(w)&1))<<p;
        x<<=1;
        p++;
    }
    answer(curs,curs^curxor);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...