제출 #249799

#제출 시각아이디문제언어결과실행 시간메모리
249799eohomegrownapps코끼리 (Dancing Elephants) (IOI11_elephants)C++14
컴파일 에러
0 ms0 KiB
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
#include <bits/extc++.h>
using namespace __gnu_pbds;
template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename V>
using pbds_map = tree<T, V, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
int n,l;
pbds_set<int> elephants;
vector<int> elpos;
vector<int> dp;
 
void init(int N, int L, int X[]) {
    n=N;l=L;
    elpos.resize(n);
    dp.resize(n);
    for (int i = 0; i<n; i++){
        elpos[i]=X[i];
        elephants.insert(X[i]);
    }
}
 
int update(int i, int y) {
    if (l==0){
        return n;
    }
    int minchanged = min(elpos[i],y);
    //cout<<minchanged<<'\n';
    elephants.erase(elpos[i]);
    elpos[i]=y;
    elephants.insert(y);
    auto it = elephants.lower_bound(minchanged-10*l);
    if (it!=elephants.begin()){
        it--;
    }
    if (it!=elephants.begin()){
        it--;
    }
    auto it = elephants.begin();
    int ptr = int(elephants.order_of_key(*it));
    //cout<<ptr<<'\n';
    while (it!=elephants.end()){
        int e = *it;
        //cout<<e<<'\n';
        int lastel = elephants.order_of_key(e-l);
        if (lastel==0){
            dp[ptr]=1;
        } else {
            dp[ptr]=dp[lastel-1]+1;
        }
        ptr++;
        it++;
    }
    return dp[n-1];
}

컴파일 시 표준 에러 (stderr) 메시지

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:42:10: error: conflicting declaration 'auto it'
     auto it = elephants.begin();
          ^~
elephants.cpp:35:10: note: previous declaration as '__gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<int, long unsigned int, std::allocator<char> >*, int, int*, const int*, int&, const int&, true, std::allocator<char> > it'
     auto it = elephants.lower_bound(minchanged-10*l);
          ^~