Submission #812589

#TimeUsernameProblemLanguageResultExecution timeMemory
812589AndreyRail (IOI14_rail)C++14
30 / 100
3079 ms197628 KiB
#include "rail.h"
#include<bits/stdc++.h>
using namespace std;

priority_queue<pair<int,pair<int,int>>> idk;

void findLocation(int n, int first, int location[], int stype[]) {
    location[0] = first;
    stype[0] = 1;
    for(int i = 1; i < n; i++) {
        location[i] = -INT_MAX;
    }
    for(int i = 1; i < n; i++) {
        idk.push({-getDistance(0,i),{0,i}});
    }
    int a,b,c,t,p;
    while(!idk.empty()) {
        a = -idk.top().first;
        b = idk.top().second.first;
        c = idk.top().second.second;
        idk.pop();
        if(location[c] != -INT_MAX) {
            continue;
        }
        t = stype[b];
        if(t == 1) {
            location[c] = location[b]+a;
            stype[c] = 2;
        }
        else {
            location[c] = location[b]-a;
            stype[c] = 1;
        }
        for(int i = 0; i < n; i++) {
            if(location[i] == -INT_MAX) {
                idk.push({-getDistance(c,i),{c,i}});
            }
        }
    }
}

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:16:17: warning: unused variable 'p' [-Wunused-variable]
   16 |     int a,b,c,t,p;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...