Submission #1160773

#TimeUsernameProblemLanguageResultExecution timeMemory
1160773SmuggingSpunRail (IOI14_rail)C++20
8 / 100
32 ms584 KiB
#include<bits/stdc++.h>
#include "rail.h"
using namespace std;
const int INF = 1e9;
template<class T>bool minimize(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
void findLocation(int n, int first, int location[], int stype[]){
    location[0] = first;
    vector<int>f0(n);
    int best = INF;
    for(int i = stype[0] = 1; i < n; i++){
        if((f0[i] = getDistance(0, i)) != getDistance(i, 0)){
            stype[i] = 1;
        }
        else{
            stype[i] = 2;
            minimize(best, f0[i]);
        }
    }
    for(int i = 1; i < n; i++){
        if(stype[i] == 1){
            location[i] = first - f0[i] + (best << 1);
        }
        else{
            location[i] = first + f0[i];
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...