이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
//template by Geothermal
void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define dbg(x...) cerr << " [" << #x << "] = ["; _print(x);
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef tuple<int, int, int> t3i;
typedef tuple<int, int, int, int> t4i;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<PI> VPI;
typedef vector<bool> VB;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VB> VVB;
typedef vector<VL> VVL;
typedef vector<VS> VVS;
typedef vector<VC> VVC;
typedef vector<VPI> VVPI;
#define FOOR(i, a, b) for(int i = a; i <= b; i++)
#define ROOF(i, a, b) for(int i = a; i >= b; i--)
#define FORR(i, a, b) FOOR(i, a, b - 1)
#define ROFF(i, a, b) ROOF(i, a - 1, b)
#define FOR(i, a) FORR(i, 0, a)
#define ROF(i, a) ROFF(i, a, 0)
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define lla(a) (a).rbegin(), (a).rend()
#define bk back()
#define fr front()fr
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define LB lower_bound
#define UB upper_bound
#define MINE min_element
#define MAXE max_element
#define f first
#define s second
#define MP make_pair
#define MT make_tuple
template<typename T> using PQ = priority_queue<T>;
template<typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template<typename T> bool ckmin(T& a, const T& b) { return b < a ? a = b, true : false; }
template<typename T> bool ckmax(T& a, const T& b) { return a < b ? a = b, true : false; }
const vector<int> dx = {0, 0, -1, 1};
const vector<int> dy = {-1, 1, 0, 0};
const ll infll = 10000000000000000;
const int inf = 2000000000;
const int mod = 1000000007;
const int mod99 = 998244353;
ll count_swaps(vector<int> a){
int n = sz(a) / 2;
vector<bool> vis(2 * n, false);
ll ans = 0;
for(int i = 0; i < 2 * n; i += 2){
int j = i + 1;
while(a[j] != a[i] * -1){
j++;
}
for(int k = j; k >= i + 2; k--){
swap(a[k], a[k - 1]);
ans++;
}
if(a[i] > 0){
swap(a[i + 1], a[i]);
ans++;
}
}
return ans;
}
# | 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... |