Submission #1021503

#TimeUsernameProblemLanguageResultExecution timeMemory
1021503MarwenElarbiRail (IOI14_rail)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
void findLocation(int N, int first, int location[], int stype[])
{
    vector<pair<int,int>> a;
    location[0]=first;
    stype[0]=1;
    for (int i = 1; i < N; ++i)
    {
        a[i].pb({getDistance(0,i),i});
    }
    sort(a.begin(),a.end());
    int left=0;
    int right=a[0].se;
    stype[a[0].se]=2;
    location[a[0].se]=a[0].fi;
    for (int i = 1; i < a.size(); ++i)
    {
        int cura=getDistance(left,a[i].se);
        int curb=getDistance(right,a[i].se);
        if(cura>curb){
            location[a[i].se]=location[right]-curb;
            stype[a[i].se]=1;
            left=a[i].se;
        }else{
            location[a[i].se]=location[left]+cura;
            stype[a[i].se]=2;
            right=a[i].se;
        }
    }
    return;
}

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:7:12: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back'
    7 | #define pb push_back
      |            ^~~~~~~~~
rail.cpp:15:14: note: in expansion of macro 'pb'
   15 |         a[i].pb({getDistance(0,i),i});
      |              ^~
rail.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 1; i < a.size(); ++i)
      |                     ~~^~~~~~~~~~