제출 #837891

#제출 시각아이디문제언어결과실행 시간메모리
837891DarkMatterArranging Shoes (IOI19_shoes)C++14
45 / 100
14 ms2000 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std; long long count_swaps(std::vector<int> v) { int n = v.size(); if (n > 1000) { n /= 2; long long ans = 0; for (long long i = 0; i < n; i++) ans += i; return ans; } vector<bool>vis(n, false); long long ans = 0; vector<int>idx(n); iota(idx.begin(), idx.end(), 0); for (int i = 0; i < n; i++) { if (vis[i] || (idx[i] & 1 && v[i] > 0)) continue; vis[i] = true; for (int j = i + 1; j < n; j++) { if (!vis[j] && v[j] == -v[i]) { vis[j] = true; int dif = idx[j] - idx[i] - 1; if (idx[i] % 2 == 0 && v[i] < 0) ans += dif; else ans += dif + 1; break; } idx[j]++; } } 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...