Submission #587836

#TimeUsernameProblemLanguageResultExecution timeMemory
587836FatihSolak철로 (IOI14_rail)C++17
8 / 100
81 ms18684 KiB
#include "rail.h"
#include <bits/stdc++.h>
#define N 5005
using namespace std;
int d[N][N];
int get(int i,int j){
    if(i > j)swap(i,j);
    if(i == j)return 0;
    if(d[i][j])
        return d[i][j];
    return d[i][j] = getDistance(i,j);
}
void findLocation(int n, int first, int location[], int stype[])
{
    location[0] = first;
    stype[0] = 1;
    if(n == 1)return;
    vector<pair<int,int>> v;
    for(int i = 1;i<n;i++){
        v.push_back({get(0,i),i});
    }
    sort(v.begin(),v.end());
    int last = v[0].second;
    location[last] = v[0].first + first;
    stype[last] = 2;
    for(int i = 1;i<n-1;i++){
        if(get(last,v[i].second) != get(0,v[i].second) - location[last] + first){
            last = v[i].second;
            location[last] = v[i].first + first;
            stype[last] = 2;
        }
    } 



    // for(int i = 0;i<n;i++){
    //     cout << location[i] << " " << stype[i] << endl;
    // }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...