# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
526467 | Deepesson | Arranging Shoes (IOI19_shoes) | C++17 | 237 ms | 156128 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "shoes.h"
#define MAX 150000
#define LSB(A) (A&(-A))
int ft[MAX];
void add(int p,int k){
p+=3;
while(p<MAX){
ft[p]+=k;
p+=LSB(p);
}
}
int query(int p){
p+=3;
int ans=0;
while(p>0){
ans+=ft[p];
p-=LSB(p);
}
return ans;
}
int seg(int l,int r){
return query(r)-query(l-1);
}
long long num_inversoes(std::vector<int> x){
long long ans=0;
for(int i=0;i!=x.size();++i){
ans+=seg(x[i]+1,MAX-3);
add(x[i],1);
}
return ans;
}
long long count_swaps(std::vector<int> s) {
std::vector<int> posicoes;
std::vector<int> ordem;
std::map<int,std::queue<int>> mapa;
for(int i=0;i!=s.size();++i){
if(s[i]>0){
mapa[s[i]].push(i);
}else ordem.push_back(i);
}
for(auto&x:ordem){
posicoes.push_back(x);
int val = abs(s[x]);
posicoes.push_back(mapa[val].front());
mapa[val].pop();
}
return num_inversoes(posicoes);
}
컴파일 시 표준 에러 (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... |