제출 #219165

#제출 시각아이디문제언어결과실행 시간메모리
219165sidiq_haArranging Shoes (IOI19_shoes)C++14
50 / 100
1099 ms84856 KiB
#include<bits/stdc++.h> #include "shoes.h" #define pb push_back #define fi first #define se second #define mp make_pair #define all(v) v.begin(), v.end() using namespace std; typedef long long LL; const LL MOD = 1e9 + 7; const double PI = 2 * acos(0); queue<int> kanan[121212]; int BIT[121212]; void update(int p) { for (int i = p; i <= 1e5; i += (i & (-i))) BIT[i]++; } int query(int p) { int cnt = 0; for (int i = p; i > 0; i -= (i & (-i))) { cnt += BIT[i]; } return cnt; } long long count_swaps(vector<int> s) { int n = s.size(); //priority_queue<pair<int, int> > pq; LL ans = 0; for (int i = 0; i < n; i += 2) { if (s[i] < 0) { for (int j = i + 1; j < n; j++) { if (s[j] == -s[i]) { int idx = j; while (idx != i + 1) { swap(s[idx], s[idx - 1]); ans++; idx--; } break; } } } else { for (int j = i + 1; j < n; j++) { if (s[j] == -s[i]) { int idx = j; while (idx != i) { swap(s[idx - 1], s[idx]); ans++; idx--; } break; } } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...