# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
70480 | KLPP | Bubble Sort 2 (JOI18_bubblesort2) | C++14 | 7435 ms | 525312 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bubblesort2.h"
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
class FT{
int arr[100000];
int n;
public:
void init(int N){
n=N;
for(int i=0;i<=n;i++){
arr[i]=0;
}
}
int query(int prefix){
prefix++;
int ans=0;
for(;prefix>0;prefix-=(prefix&(-prefix))){
ans+=arr[prefix];
}return ans;
}
void update(int pos){
pos++;
for(;pos<=n;pos+=(pos&(-pos))){
arr[pos]++;
}
}
void print(){
for(int i=0;i<=n;i++){
cout<<arr[i]<<" ";
}cout<<endl;
}
};
int compute(vector<int> v){
int n=v.size();
FT *A=new FT();
A->init(n);
pair<int,int> arr[n];
for(int i=0;i<n;i++){
arr[i]=pair<int,int>(v[i],i);
}sort(arr,arr+n);
int prev=n-1;
int ans=0;
for(int i=n-1;i>-1;i--){
if(i==0 || arr[i-1]!=arr[i]){
for(int j=prev;j>=i;j--){
ans=max(ans,A->query(arr[j].second));
}
for(int j=prev;j>=i;j--){
A->update(arr[j].second);
}
//A->print();
prev=i-1;
}
}
return ans;
}
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
vector<int> ans;
for(int i=0;i<X.size();i++){
A[X[i]]=V[i];
ans.push_back(compute(A));
}
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... |