Submission #1328329

#TimeUsernameProblemLanguageResultExecution timeMemory
1328329orgiloogiiRail (IOI14_rail)C++20
8 / 100
31 ms588 KiB
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
//int getDistance(int i, int j);
void findLocation(int n, int first, int location[], int stype[]) {
    location[0] = first;
    stype[0] = 1;

    int dist[n] = {0};
    dist[0] = 0;
    int dist1[n] = {0};
    dist1[0] = 0;

    int mdx = 0;
    int mx = 0;
    for (int i = 1;i < n;i++) {
        dist[i] = getDistance(0, i);
        dist1[i] = getDistance(i, 0);
        if (dist[i] == dist1[i]) {
            stype[i] = 2;
            location[i] = first + dist[i];
            if (dist[i] > mx) {
                mx = dist[i];
                mdx = i;
            }
        }
        else {
            stype[i] = 1;
        }
    }
    for (int i = 1;i < n;i++) {
        if (stype[i] == 1) {
            location[i] = location[mdx] - getDistance(mdx, 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...