Submission #420415

#TimeUsernameProblemLanguageResultExecution timeMemory
420415yuto1115Arranging Shoes (IOI19_shoes)C++17
30 / 100
36 ms7736 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); } rep(i, n) if (l[i].size()) { ll ans = 0; rep(j, n) { if (l[i][j] < r[i][j]) { auto it = lower_bound(all(r[i]), l[i][j]); ans += j - (it - r[i].begin()); } else { auto it = lower_bound(all(l[i]), r[i][j]); ans += j - (it - l[i].begin()) + 1; } } return ans; } }

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(vi)':
shoes.cpp:46:12: warning: control reaches end of non-void function [-Wreturn-type]
   46 |     vvi l(n), r(n);
      |            ^
#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...