제출 #1217774

#제출 시각아이디문제언어결과실행 시간메모리
1217774JuanJLArranging Shoes (IOI19_shoes)C++20
10 / 100
1095 ms1864 KiB
#include "shoes.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define fst first #define snd second #define pb push_back #define forn(i,a,b) for(int i = a; i<b; i++) #define SZ(x) (int)x.size() #define ALL(x) x.begin(),x.end() #define mset(a,v) memset(a,v,sizeof(a)) #define FIN ios::sync_with_stdio(0); cout.tie(); cin.tie(0); using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> iset; long long count_swaps(std::vector<int> s) { ll n = SZ(s); ll res = 0; /*forn(i,0,n){ ll pos = -1; forn(j,i+1,n){ if(abs(s[j])==abs(s[i])){ pos=j; break; } } ll aux = -1; for(int j = pos-1; (s[i]<0?(j>i):(j>=i)); j--){ res++; aux=s[j]; s[j]=s[j+1]; s[j+1]=aux; } i++; }*/ for(int i = n-1; i>=0; i--){ ll pos = -1; for(int j = i-1; j>=0; j--){ if(abs(s[j])==abs(s[i])){ pos=j; break; } } ll aux = -1; forn(j,pos+1, (s[i]<0?(i+1):(i))){ res++; aux=s[j]; s[j]=s[j-1]; s[j-1]=aux; } i--; } return res; }
#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...