# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
157468 | 2019-10-11T18:09:40 Z | keta_tsimakuridze | Arranging Shoes (IOI19_shoes) | C++14 | 279 ms | 269724 KB |
#include<bits/stdc++.h> using namespace std; long long noneg,k,b[100005],curindex,cursum,ans,n,a[100005]; queue<int>q[400005]; vector<int>s; void update(int ind,int value) { for(int i=ind; i<=s.size(); i+=i&(-i)) b[i]+=value; } int curs(int ind1) { cursum=0; for(int i=ind1; i>=1; i-=i&(-i)) cursum+=b[i]; return cursum; } void count_swaps(std:: vector<int>s) { noneg=100002; n=s.size(); for(k=0; k<s.size(); k++){ a[k+1]=s[k]; } for(k=1;k<=n;k++) update(k+1,1); for(k=1; k<=s.size(); k++) { if(q[a[k]+noneg].size()>0) { curindex=q[a[k]+noneg].front(); q[a[k]+noneg].pop(); ans+=curs(k)-curs(curindex)-1; if(a[k]<0) ans++; update(k,-1); update(curindex,1); } else q[a[k]*(-1)+noneg].push(k); } cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 279 ms | 269688 KB | secret mismatch |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 279 ms | 269688 KB | secret mismatch |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 279 ms | 269688 KB | secret mismatch |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 275 ms | 269724 KB | secret mismatch |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 279 ms | 269688 KB | secret mismatch |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 279 ms | 269688 KB | secret mismatch |
2 | Halted | 0 ms | 0 KB | - |