QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#317962 | #7615. Sequence Folding | nhuang685 | WA | 189ms | 16384kb | C++20 | 1.4kb | 2024-01-30 05:28:05 | 2024-01-30 05:28:06 |
Judging History
answer
/**
* @file qoj7615-1.cpp
* @author n685
* @brief
* @date 2024-01-28
*
*
*/
#include <bits/stdc++.h>
#ifdef LOCAL
#include "dd/debug.h"
#else
#define dbg(...) 42
#define dbgR(...) 4242
#define dbgP(...) 420
#define dbgRP(...) 420420
void nline() {}
#endif
int main() {
#ifdef LOCAL
std::freopen("input.txt", "r", stdin);
std::freopen("output.txt", "w", stdout);
#else
std::cin.tie(nullptr)->sync_with_stdio(false);
#endif
int64_t n;
int m;
std::cin >> n >> m;
std::map<int64_t, int> val;
for (int i = 0; i < m; ++i) {
int p;
std::cin >> p;
--p;
val[p] = 1;
}
int ans = 0;
while (n > 1) {
std::map<int64_t, int> cval = val;
for (auto [aa, bb] : val) {
int64_t a = aa;
if (a >= n) {
break;
}
if (a >= n / 2) {
if (val.contains(n - 1 - a)) {
continue;
}
}
if (a >= n / 2) {
a = n - 1 - a;
}
int64_t b = n - 1 - a;
int c, d;
if (val.contains(a)) {
c = val[a];
} else {
c = 0;
}
if (val.contains(b)) {
d = val[b];
} else {
d = 0;
}
if ((c == 0 && d == 1) || (c == 1 && d == 0)) {
++ans;
cval[a] = 2;
} else if (c == 2) {
cval[a] = d;
}
}
val.swap(cval);
n /= 2;
}
std::cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
8 3 1 5 8
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 189ms
memory: 16384kb
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:
99998
result:
wrong answer 1st lines differ - expected: '99999', found: '99998'