Submission #576088

#TimeUsernameProblemLanguageResultExecution timeMemory
576088elazarkorenRail (IOI14_rail)C++17
30 / 100
80 ms500 KiB
#include "rail.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

const int MAX_N = 5005;

int dist0[MAX_N], dist1[MAX_N], dist2[MAX_N];

void findLocation(int n, int first, int location[], int stype[]) {
    int closest = 1;
    for (int i = 1; i < n; i++) {
        dist0[i] = getDistance(0, i);
        if (dist0[i] < dist0[closest]) closest = i;
    }
    int farthest = closest;
//    for (int i = 1; i < n; i++) {
//        if (i != closest) {
//            dist1[i] = getDistance(closest, i);
//            if (dist0[i] < dist1[i] && dist0[i] > dist0[farthest]) {
//                farthest = i;
//            }
//        }
//    }
    for (int i = 0; i < n; i++) {
        if (i != farthest) {
            dist2[i] = getDistance(farthest, i);
        }
    }
    location[0] = first, stype[0] = 1;
    location[farthest] = dist0[farthest] + first, stype[farthest] = 2;
    for (int i = 1; i < n; i++) {
        if (i == farthest) continue;
        if (dist0[i] < dist2[i]) {
            location[i] = dist0[i] + first;
            stype[i] = 2;
        } else {
            location[i] = location[farthest] - dist2[i];
            stype[i] = 1;
        }
    }
}
//2 10
//1 5
//1 2
//1 1
//1 3
//1 4
//2 7
//2 8
//2 6
//2 9
//2 10
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...