제출 #1263877

#제출 시각아이디문제언어결과실행 시간메모리
1263877piolkArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> tree;
int len=0;

void update(int v,int currStart,int currEnd,int lookStart,int lookEnd){
    if (currStart>=lookStart && currEnd<=lookEnd){
        tree[v]++;
        return;
    }

    if (currStart>lookEnd || currEnd<lookStart) return;

    int mid=(currStart+currEnd)/2;
    update(2*v,currStart,mid,lookStart,lookEnd);
    update(2*v+1,mid+1,currEnd,lookStart,lookEnd);
}

int get(int pos){
    pos+=len;
    int ans=tree[pos];

    while (pos>1){
        pos/=2;
        ans+=tree[pos];
    }
    return ans;
}

int64_t count_swaps(vector<int> S){
    tree.clear();
    int n=S.size();

    for (int i=1;i<=21;i++){
        int p=(1<<i);
        if (p>=n){
            len=p;
            break;
        }
    }

    tree.resize(2*len);

    vector<bool> skip(n);
    iota(tree.begin()+len+1,tree.end(),1);
    vector<pair<queue<int,vector<int>>,queue<int,vector<int>>>> pqs(n+1);

    for (int i=0;i<n;i++){
        if (S[i]>0){
            pqs[S[i]].first.push(i);
        } else {
            pqs[S[i]*-1].second.push(i);
        }
    }

    int64_t swaps=0;

    for (int i=0;i<n;i++){
        if (skip[i]) continue;

        int now=get(i);
        int next;

        if (S[i]>0){
            //szukam w ujemnych na .second
            next=pqs[S[i]].second.front();
            pqs[S[i]].second.pop();

            pqs[S[i]].first.pop(); //usuwamy now
        } else {
            //szukam w dodatnich na .first
            next=pqs[S[i]*-1].first.front();
            pqs[S[i]*-1].first.pop();

            pqs[S[i]*-1].second.pop();//usuwamy now
        }

        update(1,0,len-1,0,next-1);

        skip[i]=true;
        skip[next]=true;

        next=get(next);

        swaps+=next-now-1;

        if (S[i]>0) swaps++;
    }
    return swaps;
}

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

In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from shoes.cpp:1:
/usr/include/c++/11/bits/stl_queue.h: In instantiation of 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = int; _Sequence = std::vector<int>]':
shoes.cpp:68:33:   required from here
/usr/include/c++/11/bits/stl_queue.h:301:11: error: 'class std::vector<int>' has no member named 'pop_front'
  301 |         c.pop_front();
      |         ~~^~~~~~~~~