제출 #819808

#제출 시각아이디문제언어결과실행 시간메모리
819808BulaArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; #define ll long long #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define ff first #define sc second //#define int ll const ll mod=1e9+7, N = 2e5 + 1; vector<int> t(4 * N); int get(int v, int tl, int tr, int l, int r) { if (l > r) return 0; if (l == tl && r == tr) { return t[v]; } int tm = (tl + tr) / 2; return get(v*2, tl, tm, l, min(r, tm))+get(v*2+1, tm+1, tr, max(l, tm+1), r); } void up(int v, int tl, int tr, int pos, int new_val) { if (tl == tr) { t[v] = new_val; } else { int tm = (tl + tr) / 2; if (pos <= tm) up(v*2, tl, tm, pos, new_val); else up(v*2+1, tm+1, tr, pos, new_val); t[v] = t[v*2]+t[v*2+1]; } } ll count_swaps(vector<int> &s){ int n = s.size(); vector< set<int> > v(n + 1); for(int i = 0; i < n; i++){ v[s[i]].insert(i); } int ans = 0; for(int i = 0; i < n; i++){ if(get(1, 0, n - 1, i, i) != 0) continue; int id = *v[-s[i]].begin(); v[s[i]].erase(v[s[i]].begin()); v[-s[i]].erase(v[-s[i]].begin()); if(s[i] > 0) ans++; ans += id - i - 1 - get(1, 0, n - 1, i + 1, id - 1); up(1, 0, n - 1, id, 1); up(1, 0, n - 1, i, 1); } return ans; }

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

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