제출 #301862

#제출 시각아이디문제언어결과실행 시간메모리
301862NicolaAbusaad2014Arranging Shoes (IOI19_shoes)C++14
0 / 100
1 ms384 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { map<long,vector<long> >m; map<long,long>now; map<long,bool>ok; long n=s.size(); long long arr[2*n]={},x,z,ans=0; for(long i=0;i<2*n;i++){ m[s[i]].push_back(i); } for(long i=0;i<2*n;i++){ if(ok[abs(s[i])]){ ok[abs(s[i])]=false; } else{ ok[abs(s[i])]=true; z=now[abs(s[i])]; x=m[-s[i]][z]; now[abs(s[i])]++; for(long j=x+1;j<2*n;j++){ arr[j]--; } ans+=x-i-1+arr[x]; if(s[i]>0){ ans++; } } } return ans; }
#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...