이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define y2 y9090
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#include "shoes.h"
using namespace std;
ll f_la_fel (vi v) {
int n = sz(v);
auto to_equal = [&n] (vi v, vi to) {
vi p1, p2;
int i, j, z;
for (i = 0; i < n; i++)
if (v[i] < 0) p1.pb(i);
for (i = 0; i < n; i++)
if (to[i] < 0) p2.pb(i);
ll ans = 0;
for (i = 0; i < n/2; i++) ans += abs(p2[i]-p1[i]);
return ans;
};
int x = abs(v[0]);
vi to1(n, x), to2(n, -x);
for (int i = 0; i < n; i += 2) {
to1[i] *= -1;
to2[i] *= -1;
}
return min(to_equal(v, to1), to_equal(v, to2));
}
ll count_swaps (vi v) {
int n = sz(v);
if (n == 2) {
if (v[0] > v[1]) return 1;
return 0;
}
return f_la_fel(v);
}
//int main () {
// int n; cin >> n;
// int i, j, z;
// vi v(n*2);
// for (i = 0; i < 2*n; i++) cin >> v[i];
// cout << count_swaps(v);
// return 0;
//}
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp: In lambda function:
shoes.cpp:32:12: warning: unused variable 'j' [-Wunused-variable]
32 | int i, j, z;
| ^
shoes.cpp:32:15: warning: unused variable 'z' [-Wunused-variable]
32 | int i, j, z;
| ^
# | 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... |