# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305940 | 2020-09-24T06:32:34 Z | kylych03 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include "shoes.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; long long res[200010]; int vis[200011]; long long count_swaps(std::vector<int> s) { long long sum = 0; for(int i = 0 ; i < s.size(); i++){ if(vis[i]==1) continue; int j = i+1; while( 1 ){ if(s[i] == (-1)*s[j] && vis[j]==0) break; res[j]++; j++; } sum += (j - i - 1 + (res[j] - res[i])); if(s[i] > 0) sum++; vis[j]=1; } return sum; }