제출 #404079

#제출 시각아이디문제언어결과실행 시간메모리
404079Theo830Arranging Shoes (IOI19_shoes)C++17
0 / 100
1 ms256 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "shoes.h"
long long count_swaps(std::vector<int> s){
    ll m = s.size();
    ll ans = 0;
    f(i,0,m){
        ll pos = i+1;
        while(s[pos] == -s[i]){
            pos++;
        }
        f(j,i,pos-1){
            swap(s[j],s[j+1]);
            ans++;
        }
        if(s[pos-1] > 0){
            swap(s[pos-1],s[pos]);
            ans++;
        }
    }
    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...