Submission #512539

#TimeUsernameProblemLanguageResultExecution timeMemory
512539DJ035Arranging Shoes (IOI19_shoes)C++17
50 / 100
20 ms4780 KiB
#include "shoes.h" # pragma GCC optimize ("O3") # pragma GCC optimize ("Ofast") # pragma GCC optimize ("unroll-loops") #include <bits/stdc++.h> #define MEM 111111 #define sanic ios_base::sync_with_stdio(0) #define x first #define y second #define pf push_front #define pb push_back #define all(v) v.begin(), v.end() #define sz size() using namespace std; typedef long long ll; typedef pair<ll, ll> pi; const ll MOD = 1e9+7; const ll INF = 2e14+7; ll mul(ll a, ll b){ return ((a*b)%MOD+MOD)%MOD; } ll add(ll a, ll b){ return ((a+b)%MOD+MOD)%MOD; } ll t,n,ans,m,q,k; ll v[MEM]; long long count_swaps(std::vector<int> s) { ll n=s.sz; ll ans=0; for(int i=n-1; i>=0; i--){ if(v[i]) continue; ll o=0; for(int j=i-1; j>=0; j--){ if(v[j]) { o++; continue; } if(-s[j]==s[i]){ if(s[i]>0) ans += i-j-1-o; else ans += i-j-o; v[j] = 1; v[i] = 1; break; } } //cout << i << ' ' << o << ' ' << ans << '\n'; } 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...