| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 332334 | blue | Arranging Shoes (IOI19_shoes) | C++17 | 113 ms | 15724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <iostream>
#include <vector>
using namespace std;
long long count_swaps(vector<int> S)
{
int n = S.size()/2;
long long res = 0;
vector<int> left[n+1], right[n+1];
vector<int> othershoe(2*n, -1);
for(int i = 0; i < 2*n; i++)
{
if(S[i] < 0) left[-S[i]].push_back(i);
else right[S[i]].push_back(i);
}
for(int i = 1; i <= n; i++)
{
for(int j = 0; j < left[i].size(); j++)
{
if(left[i][j] < right[i][j]) othershoe[left[i][j]] = right[i][j];
else
{
othershoe[right[i][j]] = left[i][j];
res++;
}
}
}
vector<int> rightshift(2*n, 0);
for(int i = 0; i < 2*n; i++)
{
if(othershoe[i] == -1) continue;
res += othershoe[i] - i - 1;
for(int j = i; j >= 1; j -= j&-j) res -= rightshift[j];
for(int j = othershoe[i]; j >= 1; j -= j&-j) res += rightshift[j];
for(int j = i+1; j < 2*n; j += j&-j) rightshift[j]++;
for(int j = othershoe[i]+1; j < 2*n; j += j&-j) rightshift[j]--;
}
return res;
}
컴파일 시 표준 에러 (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... | ||||
