제출 #1274231

#제출 시각아이디문제언어결과실행 시간메모리
1274231gazizmadi11Arranging Shoes (IOI19_shoes)C++20
0 / 100
1 ms332 KiB
#include <bits/stdc++.h>
#include "shoes.h"
#define pb push_back
// #define pf push_front
// #define F first
// #define S second
// #define all(v) v.begin(),v.end()
// #define pii pair<int,int>
// #define tm (tl+tr)/2
// #define TL v+v, tl, tm
// #define TR v+v+1, tm+1, tr
// #define DA l <= tl && tr <= r
// #define NE r < tl || tr < l
// #define double long double
// #define int long long s
using namespace std;
 
// const int N=2e5+7;
// const int mod=998244353;
// const int inf=2e9;

long long count_swaps(vector<int>S){
    vector<int>a[S.size()+1];
    vector<int>b[S.size()+1];
    long long ans=0;
    for(int i=0; i < S.size(); i++){
        int x = S[i];
        if(x > 0){
            if(a[x].size()){
                ans+=i-a[x].back()-1;
                a[x].pop_back();
            }
            else b[x].pb(i);
        }
        else{
            if(b[x].size()){
                ans+=i-b[x].back();
                b[x].pop_back();
            }
            else a[x].pb(i);
        }
    }
    return ans;
}

// void solve(){
    
// }

// signed main(){
 
//     ios_base::sync_with_stdio(0);
//     cin.tie(0);
//     int dioz=1;
//     cin >> dioz; 	
//     while(dioz--)solve();
    
// return 0;
// }
#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...