제출 #651852

#제출 시각아이디문제언어결과실행 시간메모리
651852jiahngArranging Shoes (IOI19_shoes)C++14
10 / 100
45 ms10892 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector <int> vi; typedef vector <pi> vpi; typedef pair<pi, ll> pii; typedef set <ll> si; typedef long double ld; #define f first #define s second #define mp make_pair #define FOR(i,s,e) for(int i=s;i<=int(e);++i) #define DEC(i,s,e) for(int i=s;i>=int(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end() #define lbd(x, y) lower_bound(all(x), y) #define ubd(x, y) upper_bound(all(x), y) #define aFOR(i,x) for (auto i: x) #define mem(x,i) memset(x,i,sizeof x) #define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define maxn 200010 #define INF (ll)1e9 #define MOD 1000000007 typedef pair <vi, int> pvi; typedef pair <int,pi> ipi; typedef vector <pii> vpii; vi A[maxn]; long long count_swaps(std::vector<int> s) { long long ans = 0; FOR(i,0,s.size()-1){ int val = (s[i] < 0 ? -i : i); //cout << val << ' '; if (A[abs(s[i])].empty() || (A[abs(s[i])].back() < 0) == (val < 0)){ A[abs(s[i])].pb(val); }else{ ans += abs(A[abs(s[i])].back() + val) - 1; if (val < 0) ans++; A[abs(s[i])].pop_back(); } } 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...