| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 423609 | Mazaalai | Arranging Shoes (IOI19_shoes) | C++14 | 1 ms | 204 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
long long count_swaps(vector<int> s) {
ll ans = 0, n = s.size();
map <int, vector <int> > l, r;
for (int i = 0; i < n; i++) {
if (s[i] < 0)
l[-s[i]].push_back(i);
else
r[s[i]].push_back(i);
}
vector <pair <int, int> > lines;
vector <int> lineCnt(n+5, 0);
for (auto el : l) {
int val = el.first;
vector <int> a = el.second, b = r[val];
for (int i = 0; i < a.size(); i++) {
int x = a[i], y = b[i];
// cout << x << ' ' << y << '\n';
if (x < y && x + 1 <= y) {
ans += y - (x+1);
lines.push_back({x+1, y-1});
lineCnt[x+1]++;
lineCnt[y]--;
}
if (x > y && y <= x-1) {
swap(x, y);
ans += y - x;
lines.push_back({x, y-1});
lineCnt[x]++;
lineCnt[y]--;
}
}
}
for (int i = 1; i < n+5; i++) lineCnt[i] += lineCnt[i-1];
// for (int i = 0; i < n; i++) cout << lineCnt[i] << ' ';
// cout << '\n';
for (auto [a, b] : lines) {
// cout << a << ' ' << b << '\n';
if (lineCnt[a] < lineCnt[b]) {
ans -= lineCnt[b] - lineCnt[a];
}
}
// sort(lines.begin(), lines.end());
// for
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... | ||||
