This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "shoes.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mxN = 2e5 + 1;
int seg[4 * mxN];
int n;
void update(int tar, int l = 1, int r = n, int idx = 1) {
if (l == r) {
seg[idx] ^= 1;
return;
}
int mid = (l + r) >> 1;
if (tar <= mid) update(tar, l, mid, (idx << 1));
else update(tar, mid + 1, r, (idx << 1) + 1);
seg[idx] = seg[(idx << 1)] + seg[(idx << 1) + 1];
return;
}
int query(int tarl, int tarr, int l = 1, int r = n, int idx = 1) {
if (tarl > tarr) return 0;
if (tarl <= l && r <= tarr) return seg[idx];
else if (tarr < l || r < tarl) return 0;
int mid = (l + r) >> 1;
return query(tarl, min(tarr, mid), l, mid, (idx << 1)) + query(max(tarl, mid + 1), tarr, mid + 1, r, (idx << 1) + 1);
}
long long st1(vector<int> &s) {
if (s[0] == -1 && s[1] == 1) return 0;
else if (s[0] == 1 && s[1] == -1) return 1;
else {
while (true) continue;
}
}
long long st2(vector<int> &s) {
return -1;
}
long long st3(vector<int> &s) {
return -1;
}
long long st4(vector<int> &s) {
long long n = s.size() / 2;
n = (n - 1) * n / 2;
return n;
}
long long count_swaps(vector<int> s) {
n = s.size();
if (n == 1) return st1(s);
// else if (n <= 8) return st2(s);
// bool ckst3 = true;
// for (int i = 1; i < n; i++) {
// if (abs(s[0]) != abs(s[i])) {
// ckst3 = false;
// break;
// }
// }
// if (ckst3) return st3(s);
bool ckst4 = true;
for (int i = 0; i < n / 2; i++) {
if (s[i] + s[i + n] != 0 || s[i] > 0) {
ckst4 = false;
break;
}
}
if (ckst4) return st4(s);
}
Compilation message (stderr)
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
64 | }
| ^
# | 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... |