Submission #581460

#TimeUsernameProblemLanguageResultExecution timeMemory
581460kamelfanger83Rail (IOI14_rail)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>
#include <limits>
#include "rail.h"
#include <algorithm>
#include <cassert>

using namespace std;

void findlocation(int n, int first, int location[], int stype[]){
    
    int fl = numeric_limits<int>::max();
    int ifl;
    for(int c = 1; c < n; ++c){
        if(getDistance(0,c) < fl){
            fl = getDistance(0,c);
            ifl = c;
        }
    }
    location[ifl] = first + fl;
    stype[ifl] = 2;

    int fr = numeric_limits<int>::max();
    int ifr;
    for(int c = 0; c < n; c++){
        if(c != ifl && getDistance(ifl,c) < fr){
            fr = getDistance(ifl,c);
            ifr = c;
        }
    }

    location[ifr] = first + fl - fr;
    stype[ifr] = 1;

    vector<vector<int>> ts;

    for(int sol = 0; sol < n; sol++){
        int tu = getDistance(ifl,sol);
        int td = getDistance(ifr,sol);
        ts.push_back({tu, td, sol});
    }

    sort(ts.begin(), ts.end());

    vector<int> leftdowns;
    vector<int> rightups;
    for(vector<int> t : ts){
        int tu = t[0], td = t[1], sol = t[1];
        if(tu + fr == td){
            for(int uc : leftdowns){
                int d = getDistance(uc, sol);
                if(d + (location[ifl] - location[uc]) == tu){
                    location[sol] = location[uc] + d;
                    stype[sol] = 2;
                    goto done;
                }
            }
            location[sol] = location[ifl] - tu;
            stype[sol] = 1;
            leftdowns.push_back(sol);
            done:
        }
        if(td + fr == tu){
            for(int uc : rightups){
                int d = getDistance(uc, sol);
                if(d + (location[uc] - location[ifr]) == td){
                    location[sol] = location[uc] - d;
                    stype[sol] = 1;
                    goto alsodone;
                }
            }
            location[sol] = location[ifr] + td;
            stype[sol] = 2;
            rightups.push_back(sol);
            alsodone:
        }
        else{
            assert(false);
        }
    }
}   

Compilation message (stderr)

rail.cpp: In function 'void findlocation(int, int, int*, int*)':
rail.cpp:62:9: error: expected primary-expression before '}' token
   62 |         }
      |         ^
rail.cpp:76:9: error: expected primary-expression before '}' token
   76 |         }
      |         ^