Submission #743972

#TimeUsernameProblemLanguageResultExecution timeMemory
743972drdilyorArranging Shoes (IOI19_shoes)C++17
50 / 100
1069 ms3520 KiB
#include <bits/stdc++.h> #ifdef ONPC #include "t_debug.cpp" #else #define debug(...) 42 #endif using namespace std; //namespace pbds = __gnu_pbds; using ll = long long; const int inf = 1e9; const ll infl = 1e18; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); mt19937 rng(RANDOM); template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; } template<typename Cont> int sz(const Cont& cont) { return int(cont.size()); } const string fileio = ""; constexpr int tests = 1, nmax = 2e5, nlog = __lg(nmax), mod = 1e9+7; long long count_swaps(std::vector<int> s) { int n = s.size(); vector<int> pr(2*n,-1); for (int i = 0; i < n+n; i++) { if (s[i] > 0) continue; for (int j = 0; j < n+n; j++) { if (i == j) continue; if (~pr[j]) continue; if (-s[j] == s[i]) { pr[j] = i; pr[i] = j; break; } } } ll res = 0; for (int i = 0; i < n; i++) { if (s[i] > 0) continue; int a = i, b = pr[i]; if (a > b) swap(a, b),res++; for (int j = a+1; j <= b-1; j++) if (pr[j] <= b) res++; } 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...