Submission #409317

#TimeUsernameProblemLanguageResultExecution timeMemory
409317MDarioRail (IOI14_rail)C++11
56 / 100
99 ms892 KiB
#include "rail.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
void findLocation(int N, int first, int location[], int stype[]){
    for(int i=0; i<N; i++){
        stype[i]=0;
    }
    location[0]=first;
    stype[0]=1;
    if(N==1)return;
    int a[N];
    a[0]=0;
    map<ll, ll> m;
    vector<pair<ll, ll>> v, v1;
    for(int i=0; i<N; i++){
        if(stype[i]==0){
            a[i]=getDistance(0, i);
            v.push_back({a[i], i});
        }
    }
    sort(v.begin(), v.end());
    int l=0, r=v[0].S, dl=0, dr=0, c=0;
    location[r]=first+v[0].F;
    stype[r]=2;
    m[location[l]]=1;
    m[location[r]]=2;
    for(int i=1; i<v.size(); i++){
        dl=getDistance(l, v[i].S);
        dr=getDistance(r, v[i].S);
        c=(location[l]+dl+location[r]-dr)/2;
        if(m[c]==0){
            if(dl>dr){
                stype[v[i].S]=2;
                location[v[i].S]=location[l]+dl;
                if(location[v[i].S]>location[r])r=v[i].S;
            }
            else{
                stype[v[i].S]=1;
                location[v[i].S]=location[r]-dr;
                if(location[v[i].S]<location[l])l=v[i].S;
            }
        }
        else if(m[c]==1){
            stype[v[i].S]=2;
            location[v[i].S]=location[l]+dl;
            if(location[v[i].S]>location[r])r=v[i].S;
        }
        else{
            stype[v[i].S]=1;
            location[v[i].S]=location[r]-dr;
            if(location[v[i].S]<location[l])l=v[i].S;
        }
        m[location[v[i].S]]=stype[v[i].S];
    }
    return ;
}

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=1; i<v.size(); 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...