# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
758792 | Blagoj | Arranging Shoes (IOI19_shoes) | C++17 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()
struct FenwickTree {
vector<ll> fwt;
FenwickTree(int n) {
fwt.resize(n);
}
void add(int n) {
for (n++; n < fwt.size(); n += n & -n) {
fwt[n]++;
}
}
ll get(int n) {
ll s = 0;
for (n++; n > 0; n -= n & -n) {
s += fwt[n];
}
return s;
}
};
long long count_swaps(std::vector<int> s) {
map<int, queue<int>> mp;
for (int i = 0; i < s.size(); i++) {
mp[s[i]].push(i);
}
int d[s.size() + 2], cur = 1;
memset(d, 0, sizeof(d));
for (int i = 0; i < s.size(); i++) {
if (d[i] != 0) continue;
if (s[i] < 0) {
d[i] = cur;
mp[s[i]].pop();
d[mp[-s[i]].front()] = cur + 1;
mp[-s[i]].pop();
}
else {
d[i] = cur + 1;
mp[s[i]].pop();
d[mp[-s[i]].front()] = cur;
mp[-s[i]].pop();
}
cur += 2;
}
ll ans = 0;
FenwickTree fwt(cur + 2);
for (int i = s.size() - 1; i >= 0; i++) {
ans += fwt.get(d[i] - 1);
fwt.add(d[i]);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |