제출 #483479

#제출 시각아이디문제언어결과실행 시간메모리
483479Bogdan1110Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define pb push_back #define fi first #define se second #define ld long double #define n_4 10010 #define n_5 100010 #define n_6 1000010 #define n_7 10000010 #define n_8 100000010 #define pii pair<int,int> #define pll pair<long long,long long> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ld, null_type,less<ld>, rb_tree_tag,tree_order_statistics_node_update> // order_of_key -> # less than k // find_by_order -> k-th element // pq max element const int NMAX = 20010; int seg[2*NMAX]; int lejzi[2*NMAX]; int nalaz[NMAX]; int mikimaus[NMAX]; void update(int l, int r, int nl, int nr, int node, int value) { if ( l <= nl && r >= nr ) { lejzi[node] += value; return; } if ( r < nl || l > nr ) return; update(l, r, (nl+nr)/2+1, nr, node*2+2, value); update(l, r, nl, (nl+nr)/2, node*2+1, value); } int pronadji(int ind, int nl, int nr, int node) { if ( nl == nr ) { seg[node] += lejzi[node]; lejzi[node] = 0; return seg[node]; } seg[node] += lejzi[node]; lejzi[node*2+1] += lejzi[node]; lejzi[node*2+2] += lejzi[node]; lejzi[node] = 0; if ( ind <= (nl + nr)/2 ) { return pronadji(ind, nl, (nl + nr)/2, node*2+1); } else { return pronadji(ind, (nl + nr)/2+1, nr, node*2+2); } } void solve () { int n; cin >> n; int N = 2*n; vector<int>v(2*n); unordered_map<int,int>m; for (int i = 0 ; i < 2*n ; i++ ) { cin >> v[i]; m[v[i]] = i; if ( m.find(-v[i]) != m.end() ) { nalaz[i] = m[-v[i]]; } else nalaz[i] = -1; } for (int i = N-1; i >= 0 ; i-- ) { if ( nalaz[i] != -1) { mikimaus[nalaz[i]] = i; } } ll rez = 0; for (int i = 0 ; i < N; i++ ) { //cout << mikimaus[i] << ' '; if (mikimaus[i] ) { int r = mikimaus[i] + pronadji(mikimaus[i],0,N-1,0); int l = i + pronadji(i,0,N-1,0); int cnt = r-l-1; if ( v[i] > 0 ) cnt++; l = i + 1; r = mikimaus[i]-1; if ( r >= l ) { //cout << l << ' ' << r << ' ' ; update(l,r,0,N-1,0,1); } //cout << cnt << endl ; rez += cnt; } //for ( int j = 0 ; j < N ; j++ ) { // cout << pronadji(j, 0, N-1, 0) << ' '; //}cout << endl ; } cout << rez << endl ; } int main () { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; //cin >>t ; int i = 1 ; while(t--) { //cout << "Case #" << i++ << ": " ; solve(); } }

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

shoes.cpp: In function 'int main()':
shoes.cpp:115:9: warning: unused variable 'i' [-Wunused-variable]
  115 |     int i = 1 ;
      |         ^
/usr/bin/ld: /tmp/ccUXBSMV.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc8f1mgX.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccUXBSMV.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