제출 #574332

#제출 시각아이디문제언어결과실행 시간메모리
574332Trisanu_DasArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

const int N = 2e5 + 5;

int n, fenwick[N];

queue<int> vall[N], valr[N];  // keep track of left and right shoe

void upd(int i, int val){
  for(int j = i; j <= n; j += j & (-j)) fenwick[j] += val;
}
int get(int i){
  int val = 0;
  for(int j = i; j <= n; j = j & (-j)) val += fenwick[i];
  return val;
}

ll count_swaps(vector<int> s){
  n = s.sizes();
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int temp = s[i - 1];
    if(temp < 0){
      temp *= -1;
      if(valr[temp].size()){
        int other = valr[temp].front(); valr[temp].pop(); ans += get(i) - get(other - 1); upd(other, 1);
      }else{
        vall[temp].push(i); upd(i,+1);
      }
    }else{
      if(vall[temp].size()){
        int other = vall[temp].front(); vall[temp].pop(); ans += get(i) - get(other); upd(other, 1);
      }else{
        vall[temp].push(i); upd(i,+1);
      }
    }
  }
  return ans;
}

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:22:9: error: 'class std::vector<int>' has no member named 'sizes'; did you mean 'size'?
   22 |   n = s.sizes();
      |         ^~~~~
      |         size