Submission #161699

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1616992019-11-03 18:43:09InkretBearArranging Shoes (IOI19_shoes)C++14
10 / 100
11 ms9724 KiB
#include <bits/stdc++.h>
#include "shoes.h"
using namespace std;
const int MAXN=200000+100;
int fen[MAXN];
int querry(int j){
if (j==0){
return 0;
}
return fen[j]+querry(j-(j&-j));
}
long long count_swaps(vector<int> a){
int n=a.size();
int f=0;
long long rez=0;
vector<int> v1[MAXN],v2[MAXN];
for (int i=0;i<n;++i){
int curr=a[i];
if (curr>0){
v1[curr].push_back(i);
if (!v2[curr].empty()){
int x=*--v2[curr].end();
v2[curr].pop_back();
v1[curr].pop_back();
rez+=i+x-4*f-querry(i+1)-querry(x+1)+2*querry(1+2*f)-1;
for (int j=i+1;j<=MAXN;j+=j&-j){
++fen[j];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...