QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#426084 | #7615. Sequence Folding | real_sigma_team# | WA | 1ms | 3652kb | C++20 | 1.5kb | 2024-05-30 20:55:26 | 2024-05-30 20:55:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
ll n;
int m;
cin >> n >> m;
map<ll, int> cost, val;
vector<ll> pts;
for (int i = 0; i < m; ++i) {
ll x;
cin >> x;
cost[x] = 1;
val[x] = 1;
pts.push_back(x);
}
ll pw = 1;
ll ans = 0;
while (n != 1) {
for (auto& x : pts) {
x = min(x, n + 1 - x);
}
sort(pts.begin(), pts.end());
pts.resize(unique(pts.begin(), pts.end()) - pts.begin());
// cout << n << ' ' << ans << endl;
// for (auto x : pts) cout << x << ' ';
// cout << endl;
for (auto x : pts) {
ll y = n + 1 - x;
if (!val.count(x) || !cost.count(x)) {
val[x] = 0;
cost[x] = pw;
}
if (!val.count(y) || !cost.count(y)) {
val[y] = 0;
cost[y] = pw;
}
// cerr << n << ' ' << x << ' ' << y << ' ' << val[x] << ' ' << cost[x] << ' ' << val[y] << ' ' << cost[y] << endl;
if (val[x] == val[y]) {
cost[x] += cost[y];
} else {
if (cost[y] < cost[x]) swap(cost[x], cost[y]), swap(val[x], val[y]);
ans += cost[x];
val[x] = val[y];
cost[x] = cost[y] - cost[x];
}
}
n /= 2;
pw *= 2;
}
cout << ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3652kb
input:
8 3 1 5 8
output:
3
result:
wrong answer 1st lines differ - expected: '2', found: '3'