제출 #863404

#제출 시각아이디문제언어결과실행 시간메모리
86340420163070Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" const int N=4e5+10; int n; int tr[N]; int vis[N]; int a[N]; vector<int> pos[N]; int lowbit(int x) { return x&-x; } int sum(int x) { int res=0; for(int i=x;i;i-=lowbit(i)) res+=tr[i]; return res; } void add(int x,int c) { for(int i=x;i<=n;i+=lowbit(i)) tr[i]+=c; } long long count_swaps(std::vector<int> s) { n=s.size(); for(int i=0;i<n;i++) a[i+1]=s[i]; for(int i=1;i<=n;i++) { pos[a[i]+n].push_back(i); add(i,1); } long long ans=0; for(int i=n;i>=1;i--) { if(vis[i]) continue; vis[i]=1; pos[a[i]+n].pop_back(); int res=pos[n-a[i]].back(); pos[n-a[i]].pop_back(); vis[res]=1; ans=ans+(long long)(sum(i-1)-sum(res))+((a[i]<0)?1:0); add(res,-1); } return ans; }

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

shoes.cpp:9:1: error: 'vector' does not name a type
    9 | vector<int> pos[N];
      | ^~~~~~
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:34:3: error: 'pos' was not declared in this scope
   34 |   pos[a[i]+n].push_back(i);
      |   ^~~
shoes.cpp:42:3: error: 'pos' was not declared in this scope
   42 |   pos[a[i]+n].pop_back();
      |   ^~~