제출 #991379

#제출 시각아이디문제언어결과실행 시간메모리
991379amine_arouaArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include <cstdio> #include <cassert> #define Int long long #define fore(i , n) for(int i = 0 ; i<n;i++) #define pb push_back #define forn(i , x , y) for(int i = x ; i >= y; i--) Int swaps(vector<int> a , vector<int> b) { map<Int , vector<Int>> pos; Int m = (Int)a.size(); fore(i , m) { pos[a[i]].pb(i); } Tree<Int> t; Int ans = 0; forn(i , m - 1 , 0) { t.insert(pos[b[i]].back()); ans+=(Int)t.order_of_key(pos[b[i]].back()); pos[b[i]].pop_back(); } return ans; } Int count_swaps(vector<int> s) { deque<int> cur; int n = (int)s.size(); vector<int> t(n); for(int i = 0 ; i < n;i+=2) { cur.pb(abs(s[i])); if(abs(s[i + 1]) != abs(s[i]) || s[i] == s[i + 1]) cur.pb(abs(s[i + 1])); t[i] = -cur.front(); t[i + 1] = cur.front(); cur.pop_front(); } return swaps(s , t); } int main() { int n; assert(1 == scanf("%d", &n)); vector<int> S(2 * n); for (int i = 0; i < 2 * n; i++) assert(1 == scanf("%d", &S[i])); fclose(stdin); long long result = count_swaps(S); printf("%lld\n", result); fclose(stdout); return 0; } /* 5 -5 -5 -4 -4 -3 5 5 4 4 3 */

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

/usr/bin/ld: /tmp/cciXPRWe.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccbaXLrd.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status