제출 #420402

#제출 시각아이디문제언어결과실행 시간메모리
420402yuto1115Arranging Shoes (IOI19_shoes)C++17
10 / 100
1091 ms15060 KiB
#include "shoes.h" #include <bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++) #define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; using vs = vector<string>; template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int inf = 1001001001; const ll linf = 1001001001001001001; ll count_swaps(vi s) { int n = s.size() / 2; vvi l(n), r(n); rep(i, 2 * n) { if (s[i] < 0) l[-s[i] - 1].pb(i); else r[s[i] - 1].pb(i); } vp v; rep(i, n) rep(j, l[i].size()) v.eb(l[i][j], r[i][j]); sort(all(v)); vi ls; for (auto[i, j] : v) ls.pb(i), ls.pb(j); ll ans = 0; rep(i, 2 * n) rep2(j, i + 1, 2 * n){ ans += ls[i] > ls[j]; } 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...