QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#624874 | #7615. Sequence Folding | HDU-T12# | TL | 3930ms | 22596kb | C++20 | 1.3kb | 2024-10-09 16:47:28 | 2024-10-09 16:47:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define X first
#define Y second
#define umap unordered_map
using ll = long long;
using ull = unsigned long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int maxn = 2e5 + 5, mod = 1e9 + 7, maxp = 31, inf = 1e9;
const ll INF = 1e18;
const double eps = 1e-6;
void solve() {
ll n, m;
cin >> n >> m;
map<ll, int> f;
for (int i = 0; i < m; i++) {
ll x;
cin >> x;
f[x] = 1;
}
int ans = 0;
ll len = n;
while (len > 1) {
map<ll, int> g;
for (auto [x, y] : f) {
int p = min(x, len + 1 - x);
if (f[x] == f[len + 1 - x]) {
g[p] = f[x];
continue;
}
if (f[x] == 2 || f[len + 1 - x] == 2) {
g[p] = min(f[x], f[len + 1 - x]);
}
else {
// cout << x << endl;
ans++;
f[x] = f[len + 1 - x] = 2;
g[p] = 2;
}
}
f = g;
len /= 2;
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
// cin >> tt;
while (tt--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
input:
8 3 1 5 8
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 3185ms
memory: 22596kb
input:
17179869184 100000 138476 774165 993977 1152277 1236393 1244970 1534017 1693701 1763926 1778781 1842066 1874644 1885666 2120429 2485344 2977941 3158255 3340476 3504862 4000117 4066652 4197639 4338723 4389163 4576965 4761601 5097091 5175412 5295902 5810551 5855982 6001770 6111262 6163309 6351547 6582...
output:
99999
result:
ok single line: '99999'
Test #4:
score: 0
Accepted
time: 3930ms
memory: 22348kb
input:
549755813888 100000 16886305 20807233 27844305 30727441 30898344 35755457 38085835 43336454 47877882 50347884 53237225 53718183 60030541 66954859 80773500 82511603 84025040 86398615 93070876 94502940 98906398 100677488 103720017 105522694 116741042 122492007 135222584 155167916 160926866 166110647 1...
output:
100000
result:
ok single line: '100000'
Test #5:
score: -100
Time Limit Exceeded
input:
17592186044416 100000 44842545 229248515 253567434 347949154 349195610 404810585 639421407 650796923 1019260054 1250861689 1315840401 1318619991 1339387462 1388173647 1406074815 1459749263 1707998226 1902480662 2060860604 2075157570 2410720375 2589192480 2742051226 2784829021 3019629868 3194189913 3...