# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
603212 | 2022-07-23T17:11:07 Z | Abdulmohsen1284 | Arranging Shoes (IOI19_shoes) | C++14 | 1 ms | 316 KB |
#include"bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class x> using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void usaco(){freopen("cruise.out","w",stdout);freopen("cruise.in","r",stdin);} #include "shoes.h" long long ls[100005],rs[100005],seg[4000005],l,r,N=1; bool used[100005]; long long lef(long long fr,long long sc,long long ind) { if(l<=fr&&r>=sc) return seg[ind]; if(r<fr||sc<l) return 0; long long mid=fr+sc; mid/=2; return lef(fr,mid,ind*2)+lef(mid+1,sc,ind*2+1); } long long count_swaps(std::vector<int> s) { long long n=s.size()/2; while(N<s.size()) N*=2; long long sum=0; //cout<<"YO"<<endl; for(int i=N;i<N+s.size();i++) seg[i]=1; for(int i=N-1;i>=1;i--) seg[i]=seg[i*2]+seg[i*2+1]; for(int i=0;i<s.size();i++) { if(s[i]<0) ls[s[i]*-1]=i; else rs[s[i]]=i; } //cout<<"YO"<<endl; for(int i=0;i<s.size();i++) { if(!used[max(s[i]*-1,s[i])]) { if(s[i]<0) { l=i+2; r=rs[s[i]*-1]; sum+=lef(1,N,1); } else{ l=i+1; r=ls[s[i]]; sum+=lef(1,N,1); } long long cur=r+N-1; seg[cur]=0; while(cur>1) { cur/=2; seg[cur]=seg[cur*2]+seg[cur*2+1]; } used[max(s[i]*-1,s[i])]=true; //cout<<sum<<" "; } } return sum; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 316 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 312 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Incorrect | 1 ms | 212 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 312 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 316 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 312 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Incorrect | 1 ms | 212 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 316 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 312 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Incorrect | 1 ms | 212 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |