Submission #1082118

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10821182024-08-30 17:40:05logangdArranging Shoes (IOI19_shoes)C++14
100 / 100
106 ms19664 KiB
#include "shoes.h"
using namespace std;
vector<int>p[300005],a(800005);
void bld(int nd,int l,int r){
if(l==r)return a[nd]=1,void();
int md=(l+r)/2;
bld(nd*2,l,md);
bld(nd*2+1,md+1,r);
a[nd]=a[nd*2]+a[nd*2+1];
}
void res(int p,int nd,int l,int r){
if(l==r)return a[nd]=0,void();
int md=(l+r)/2;
if(p<=md)res(p,nd*2,l,md);
else res(p,nd*2+1,md+1,r);
a[nd]=a[nd*2]+a[nd*2+1];
}
int qry(int p,int q,int nd,int l,int r){
if(q<l||r<p)return 0;
if(p<=l&&r<=q)return a[nd];
int md=(l+r)/2;
return qry(p,q,nd*2,l,md)+qry(p,q,nd*2+1,md+1,r);
}
long long count_swaps(vector<int>s){
int n=s.size();
bld(1,0,n-1);
for(int i=n-1;0<=i;i--)p[s[i]+n].push_back(i);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...