QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227298 | #7615. Sequence Folding | Giga_Cronos# | WA | 0ms | 3624kb | C++23 | 1.3kb | 2023-10-27 10:59:36 | 2023-10-27 10:59:36 |
Judging History
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> pip;
#define MAXN (ll)(1e6 + 5)
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, m;
cin >> n >> m;
map<ll, pii> dp;
vector<ll> pos;
set<ll> pxx;
for (int i = 0; i < m; i++) {
ll x;
cin >> x;
x--;
pos.push_back(x);
pxx.insert(x);
}
ll p = 0;
while ((1ll << p) != n)
p++;
for (auto x : pos) {
dp[x] = pii(1, 0);
}
for (auto x : pos)
if (!pxx.count(n - x - 1))
dp[n - x - 1] = pii(0, 1);
// for (auto x : dp) {
// cout << x.first << ' ' << x.second.first << ' ' << x.second.second
// << "\n";
// }
for (int i = 0; i < p; i++) {
vector<pip> tp;
for (auto p : dp) {
if (p.first < n / 2) {
ll v0 = dp[p.first].first + dp[n - p.first - 1].first;
ll v1 = dp[p.first].second + dp[n - p.first - 1].second;
v0 = min(v0, v1 + 1);
v1 = min(v1, v0 + 1);
tp.push_back(pip(p.first, pii(v0, v1)));
}
}
n /= 2;
set<ll> pxx;
for (auto x : tp)
pxx.insert(x.first);
for (auto x : pxx)
if (!pxx.count(n - x - 1))
tp.push_back(pip(n - x - 1, pii(0, 1)));
dp.clear();
for (auto x : tp)
dp[x.first] = x.second;
}
cout << dp[0].first << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
8 3 1 5 8
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3484kb
input:
1 1 1
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'