# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
158389 | nickmet2004 | Arranging Shoes (IOI19_shoes) | C++14 | 157 ms | 136696 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
//#include<shoes.h>
using namespace std;
const int NAX = 1e5 + 5;
const int l = 1e5 + 5;
int N;
// fenwick tree to count range sums (+0 , +1 , +2)
int f[2 * NAX + 1];
void update(int idx , int u){
++idx;
while(idx <= N){
f[idx] += u;
idx += idx & (-idx);
}
}
long long sum(int idx){
long long sum = 0;
++idx;
while(idx){
sum += f[idx];
idx -= idx & (-idx);
}
return sum;
}
queue<int> q[NAX];
long long count_swaps(vector<int> S){
N = S.size();
long long ans = 0;
// update BIT
for(int i = 0; i < N; ++i){
update(i , 1);
}
for(int i = 0; i < N; ++i){
int x = abs(S[i]);
int k = S[i];
if(!q[i + l].empty()){
ans += (sum(i) - (q[i + l].front() - 1) - 1);
if(k > 0){
--ans;
}
update(i , -1);
update(q[i + l].front() , 1);
} else {
// q[i * -1 + l] because its opposite is the same as the next x
// i * -1 + l == next_x(i + l)
q[i * -1 + l].push(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... |