제출 #704317

#제출 시각아이디문제언어결과실행 시간메모리
704317firewaterArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include<queue> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define N 202300 #include "shoes.h" using namespace std; ll n,x,y,ans,c[N],p[N]; queue<ll>d[N]; void add(ll x,ll y) { x++; for(;x<=n*2;x+=x&-x) c[x]+=y; return; } ll ask(ll x) { ll sum=0; for(;x;x-=x&-x) sum+=c[x]; return sum; } long long count_swaps(std::vector<ll> s) { n=s.size()/2; ans=0; for(ll i=2*n-1;i>=0;--i){ add(i,1); x=s[i]; d[x+n].push(i); } for(ll i=2*n-1;i>=0;--i){ if(p[i])continue; x=s[i]; y=-s[i]; if(x<0)ans++; ll j=d[y+n].front(); d[x+n].pop(); d[y+n].pop(); ans+=ask(i-1)-ask(j); add(j,-1); p[j]=1; } return ans; } //int main() //{ // vector<ll>aaa; // aaa.push_back(2); // aaa.push_back(1); // aaa.push_back(-1); // aaa.push_back(-2); // printf("%lld\n",count_swaps(aaa)); // return 0; //}

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

/usr/bin/ld: /tmp/cc3iwTtC.o: in function `main':
grader.cpp:(.text.startup+0x29d): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status