이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename R> using o_map = tree<T, R, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define N 200005
long long count_swaps(std::vector<int> s) {
ll n=s.size()/2;
vector<ll> dst;
map<ll,ll> mp;
queue<ll> Q[2*n+2];
for(auto u:s){
if(mp[u]==0){
dst.push_back(min(u,-u));
dst.push_back(max(-u,u));
mp[-u]=1;
}
else{
mp[u]=0;
}
}
for(ll i=0;i<dst.size();i++){
Q[dst[i]+n].push(i+1);
}
vector<ll> inv;
for(auto u:s){
inv.push_back(Q[u+n].front());
Q[u+n].pop();
}
ll cnt=0;
o_set<ll> st;
for(auto u:inv){
cnt+=st.order_of_key(-u);
st.insert(-u);
}
return cnt;
}
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:29:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(ll i=0;i<dst.size();i++){
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |