제출 #143132

#제출 시각아이디문제언어결과실행 시간메모리
143132mat_vArranging Shoes (IOI19_shoes)C++14
0 / 100
6 ms4984 KiB
#include "shoes.h" #include <bits/stdc++.h> #define pb push_back using namespace std; int n; vector<int> tike[100005][2]; int dokle[100005][2]; long long count_swaps(std::vector<int> s) { n = s.size()/2; for(int i=0; i<2*n; i++){ if(s[i] < 0)tike[abs(s[i])][0].pb(i); else tike[s[i]][1].pb(i); } int l = 0; int shift = 0; long long res = 0; while(l < 2*n){ //cout << l << endl; int koji = s[l]; koji = abs(koji); int ind; if(s[l] < 0)ind = 1; else ind = 0; int gde = tike[koji][ind][dokle[koji][ind]]; gde -= shift; res += gde + 1 - ind; dokle[koji][ind]++; l += 2; shift += 1; } return res; }
#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...