Submission #1154995

#TimeUsernameProblemLanguageResultExecution timeMemory
1154995steveonalexRail (IOI14_rail)C++17
30 / 100
34 ms584 KiB

/*

 ________  ___  ________  ________          ________   ___  ________  ________  ________     
    |\   ____\|\  \|\   ____\|\   __  \        |\   ___  \|\  \|\   ____\|\   ____\|\   __  \    
    \ \  \___|\ \  \ \  \___|\ \  \|\  \       \ \  \\ \  \ \  \ \  \___|\ \  \___|\ \  \|\  \   
     \ \  \  __\ \  \ \  \  __\ \   __  \       \ \  \\ \  \ \  \ \  \  __\ \  \  __\ \   __  \  
      \ \  \|\  \ \  \ \  \|\  \ \  \ \  \       \ \  \\ \  \ \  \ \  \|\  \ \  \|\  \ \  \ \  \ 
       \ \_______\ \__\ \_______\ \__\ \__\       \ \__\\ \__\ \__\ \_______\ \_______\ \__\ \__\
        \|_______|\|__|\|_______|\|__|\|__|        \|__| \|__|\|__|\|_______|\|_______|\|__|\|__|
                                                                                                 
                                                                                             
                                                                                             
     ________  ________  ________  ________  ___  ___  ________ _________  ___  ________  ________      
|\   __  \|\   __  \|\   __  \|\   ___ \|\  \|\  \|\   ____\\___   ___\\  \|\   __  \|\   ___  \    
\ \  \|\  \ \  \|\  \ \  \|\  \ \  \_|\ \ \  \\\  \ \  \___\|___ \  \_\ \  \ \  \|\  \ \  \\ \  \   
 \ \   ____\ \   _  _\ \  \\\  \ \  \ \\ \ \  \\\  \ \  \       \ \  \ \ \  \ \  \\\  \ \  \\ \  \  
  \ \  \___|\ \  \\  \\ \  \\\  \ \  \_\\ \ \  \\\  \ \  \____   \ \  \ \ \  \ \  \\\  \ \  \\ \  \ 
   \ \__\    \ \__\\ _\\ \_______\ \_______\ \_______\ \_______\  \ \__\ \ \__\ \_______\ \__\\ \__\
    \|__|     \|__|\|__|\|_______|\|_______|\|_______|\|_______|   \|__|  \|__|\|_______|\|__| \|__|
                                                                                                    
                                                                                                    
    Written by: giga nigga                                                                               

*/


// #include "largest.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
 
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll gcd(ll a, ll b){return __gcd(a, b);}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
 
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ull mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
 
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
// mt19937_64 rng(1);
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
double rngesus_d(double l, double r){
    double wow = (double) ((ull) rng()) / ((ull)(0-1));
    return wow * (r - l) + l;
}
 
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b) {a = b; return true;}
        return false;
    }
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b) {a = b; return true;}
        return false;
    }
 
template <class T>
    void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){
        for(auto item: container) out << item << separator;
        out << finish;
    }
 
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

#include "rail.h"

void findLocation(int n, int first, int location[], int stype[]);
namespace InteractorLib{
    int getDistance(int i, int j){
        cout << "? " << i << " " << j << endl;
        int ans; cin >> ans;
        return ans;
    }
}
// using namespace InteractorLib;

void findLocation(int n, int first, int location[], int stype[]){
    location[0] = first; stype[0] = 1;
    vector<int> dis0(n);
    for(int i = 1; i < n; ++i) dis0[i] = getDistance(0, i);

    vector<pair<int, int>> stations;
    for(int i = 1; i < n; ++i) stations.push_back(make_pair(dis0[i], i));

    sort(ALL(stations));

    int i1 = stations[0].second;
    location[i1] = location[0] + dis0[i1];
    stype[i1] = 2;

    vector<int> dis1(n);
    for(int i = 1; i < n; ++i) if (i != i1){
        dis1[i] = getDistance(i1, i);
    }

    for(int  i = 1; i < n; ++i) if (i != i1){
        if (dis0[i1] + dis1[i] == dis0[i]) {
            stype[i] = 1;
            location[i] = location[i1] - dis1[i];
        }
        else{
            stype[i] = 2;
            location[i] = location[0] + dis0[i];
        }
    }
}

// int main(void){
//     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//     clock_t start = clock();

//     int n; cin >> n;
//     int first; cin >> first;

//     int location[n], stype[n];
//     findLocation(n, first, location, stype);

//     for(int i = 0; i < n; ++i) cout << location[i] << " " << stype[i] << "\n";

//     cerr << "Time elapsed: " << clock() - start << "ms!\n";
//     return 0;
// }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...