이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=2e5+99;
int n,ans,a[N],L[N],R[N];
vector<int> A[N],B[N];
ll count_swaps(vector<int> D) {
n=D.size()/2;
f(i,0,2*n){
a[i]=D[i];
if(a[i]>0) A[a[i]].pb(i);
else B[-a[i]].pb(i);
}
int cnt=0;
f(i,1,n+1){
f(j,0,A[i].size()){
L[cnt]=B[i][j],R[cnt]=A[i][j];
if(R[cnt]<L[cnt]){
ans++;
swap(L[cnt],R[cnt]);
}
cnt++;
}
}
vector<int> vec(n);
iota(all(vec),0);
sort(all(vec),[&](int u,int v){ return L[u]<L[v]; });
//dbgv(vec);
f(i,0,n){
f(j,i+1,n){
int u=vec[i],v=vec[j];
ans+=(L[v]<R[u])+(R[v]<R[u]);
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:9:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | #define f(i,a,b) for(int i=a;i<b;i++)
......
38 | f(j,0,A[i].size()){
| ~~~~~~~~~~~~~~~
shoes.cpp:38:3: note: in expansion of macro 'f'
38 | f(j,0,A[i].size()){
| ^
# | 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... |