제출 #623576

#제출 시각아이디문제언어결과실행 시간메모리
623576VanioArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; long long n,a[200006],i,t=1,p[200006],j,b[200006],br,f[200006],q; vector<int> l[200006],r[200006]; void upd(int k, int d){ while(k<=n){ b[k]+=d; k=k+(k&(-k)); } } int rsq(int k){ long long s=0; while(k>0){ s=s+b[k]; k=k-(k&(-k)); } return s; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; n=n*2; for(i=1;i<=n;i++){ cin>>a[i]; if(a[i]<0) l[abs(a[i])].push_back(i); else r[abs(a[i])].push_back(i); } for(i=1;i<=n;i++){ if(f[i]==0){ f[i]=1; q=abs(a[i]); if(a[i]<0){ f[r[q][0]]=1; br+=r[q][0]+rsq(r[q][0])-t-1; upd(i,1); upd(r[q][0],-1); l[q].erase(l[q].begin()); r[q].erase(r[q].begin()); } else{ f[l[q][0]]=1; br+=l[q][0]+rsq(l[q][0])-t; upd(i,1); upd(l[q][0],-1); r[q].erase(r[q].begin()); l[q].erase(l[q].begin()); } t+=2; } } cout<<br; return 0; }

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

/usr/bin/ld: /tmp/ccBQXoFw.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cckRGWoy.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccBQXoFw.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