제출 #1026388

#제출 시각아이디문제언어결과실행 시간메모리
1026388ezzzayArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include"shoes.h" #include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=3e5+5; int bit[N]; int a[N]; vector<int>v[N]; vector<int>ans; int n; const int mxN=2e5; vector<int> tree(4*mxN); int cal(int node, int L, int R, int l, int r){ if(L>r||R<l) return 0; if(L>=l&&R<=r) return tree[node]; return cal(node*2,L,(L+R)/2,l,r)+cal(node*2+1,(L+R)/2+1,R,l,r); } void up(int node, int L, int R, int l, int r){ if(L>r||R<l) return; if(L==R){ tree[node]=1; return; } up(node*2,L,(L+R)/2,l,r); up(node*2+1,(L+R)/2+1,R,l,r); tree[node]=tree[node*2]+tree[node*2+1]; } int find(int idx){ int s=0; while(idx>0){ s+=bit[idx]; idx-= idx & -idx; } return s; } void update(int idx, int val){ while(idx<N){ bit[idx]+=val; idx+= idx & -idx; } } int fun(){ int s=0; for(int i=1;i<=n;i++){ s+=cal(1,1,n,a[i],n); up(1,1,n,a[i],a[i]); } return s; } long long count_swaps(vector<int> s) { n=s.size(); vector<pair<int,int>>vc; for(int i=0;i<n;i++){ if(s[i]<0){ vc.pb({i,s[i]}); } else{ v[s[i]].pb(i); } } for(int i=0;i<3e5;i++){ reverse(v[i].begin(),v[i].end()); } sort(vc.begin(),vc.end()); for(int i=0;i<n/2;i++){ int h=vc[i].ss*-1; a[vc[i].ff+1]=i*2+1; a[v[h].back()+1]=i*2+2; v[h].pop_back(); } return fun(); }

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

/usr/bin/ld: /tmp/ccYscMA8.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