QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834333 | #9913. 绝顶之战 | hhoppitree# | 15 | 1ms | 4064kb | C++14 | 2.1kb | 2024-12-27 15:32:55 | 2024-12-27 15:32:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 30;
int n;
long long a[N];
vector<long long> res;
void dfs(int x, vector< pair<int, int> > y, vector<long long> z, long long now) {
int m = y.size();
for (int i = 1; i < m; ++i) {
if (y[i].first) z[y[i].first] = min(z[y[i].first], z[i]);
if (y[i].second) z[y[i].second] = min(z[y[i].second], z[i]);
}
for (int i = m - 1; i; --i) {
z[i] = min(z[i], !y[i].first ? now : z[y[i].first] + z[y[i].second]);
}
if ((!y[0].first ? now : z[y[0].first] + z[y[0].second]) <= z[0]) return;
if (x == n + 1) {
res.push_back(z[0]);
return;
}
y.push_back({0, 0}), y.push_back({0, 0});
z.push_back(now), z.push_back(now);
vector<int> fa(m);
for (int i = 0; i < m; ++i) {
fa[y[i].first] = fa[y[i].second] = i;
}
fa[0] = -1;
pair<int, int> mn = {1e9, 0}, mx = {-1e9, 0};
for (int i = 0; i < m; ++i) {
if (y[i].first || z[i] <= a[x] || z[0] < a[x]) continue;
mn = min(mn, {z[i], i}), mx = max(mx, {z[i], i});
}
vector<int> con;
if (mn.first < 1e8) con.push_back(mn.second);
if (mx.first > -1e8 && mx.second != mn.second) con.push_back(mx.second);
for (auto i : con) {
y[i].first = m, y[i].second = m + 1;
for (int j = i; ~j; j = fa[j]) z[j] -= a[x];
dfs(x + 1, y, z, now);
y[i].first = y[i].second = 0;
for (int j = i; ~j; j = fa[j]) z[j] += a[x];
}
y.pop_back(), y.pop_back();
z.pop_back(), z.pop_back();
dfs(x + 1, y, z, min(now, a[x]));
}
signed main() {
long long m;
scanf("%lld%d", &m, &n);
for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
dfs(1, {{}}, {m}, m + 1);
sort(res.begin(), res.end());
res.erase(unique(res.begin(), res.end()), res.end());
reverse(res.begin(), res.end());
printf("%d\n", (int)res.size());
for (int i = 0; i < (int)res.size(); ++i) {
printf("%lld%c", m - res[i], " \n"[i + 1 == (int)res.size()]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 0ms
memory: 3860kb
input:
9 5 5 4 5 3 5
output:
3 5 8 9
result:
ok 4 number(s): "3 5 8 9"
Test #2:
score: 15
Accepted
time: 0ms
memory: 3772kb
input:
10 5 7 4 5 4 6
output:
1 7
result:
ok 2 number(s): "1 7"
Test #3:
score: 15
Accepted
time: 0ms
memory: 3852kb
input:
9 5 8 4 3 5 6
output:
1 8
result:
ok 2 number(s): "1 8"
Test #4:
score: 15
Accepted
time: 0ms
memory: 3868kb
input:
10 5 6 6 5 4 5
output:
2 6 10
result:
ok 3 number(s): "2 6 10"
Test #5:
score: 15
Accepted
time: 0ms
memory: 3864kb
input:
10 5 6 6 5 3 4
output:
2 6 9
result:
ok 3 number(s): "2 6 9"
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 5
Accepted
time: 0ms
memory: 3784kb
input:
9146201596026093 2 1959292328727211 3046691025174768
output:
1 5005983353901979
result:
ok 2 number(s): "1 5005983353901979"
Test #7:
score: 5
Accepted
time: 0ms
memory: 3864kb
input:
9275681991750590 2 5186569060202341 3113841469169509
output:
2 5186569060202341 8300410529371850
result:
ok 3 number(s): "2 5186569060202341 8300410529371850"
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 4064kb
input:
9401675366106951 2 149091771205127 6947611558612479
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 3860kb
input:
9107037180352846 3 2775941126614211 2097129959011760 1941377836547846
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 5
Accepted
time: 0ms
memory: 4020kb
input:
9035514376902827 5 1861522865446152 1901640741231313 2239047273044626 2596933481542076 2408801444166990
output:
4 3763163606677465 6002210879722091 8411012323889081 8599144361264167
result:
ok 5 number(s): "4 3763163606677465 60022108797...11012323889081 8599144361264167"
Test #17:
score: 5
Accepted
time: 0ms
memory: 3768kb
input:
9720759307951601 5 5245904226180530 3078325181926984 1664005610640026 897140663439037 545770017429336
output:
5 7807050500259593 8324229408107514 8352820517688929 8869999425536850 9221370071546551
result:
ok 6 numbers
Test #18:
score: 0
Wrong Answer
time: 0ms
memory: 3796kb
input:
9914984513811788 5 143280160480180 109619234770197 6890320393268943 5403376030977054 4137173786378446
output:
0
result:
wrong answer 1st numbers differ - expected: '5', found: '0'
Subtask #5:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 0ms
memory: 3840kb
input:
9023163981511792 7 1910131726862762 2116561201938147 2221366112235172 2543084904983947 2627118050952859 1894287864736168 2673898998406780
output:
0
result:
wrong answer 1st numbers differ - expected: '5', found: '0'
Subtask #6:
score: 0
Wrong Answer
Test #26:
score: 0
Wrong Answer
time: 0ms
memory: 3792kb
input:
9843534281138117 9 2077071368628181 2828099538983996 3196114494343630 3055890563571162 2057088847509186 2194463607939255 2091779370708588 3167995993737888 2800516708286895
output:
0
result:
wrong answer 1st numbers differ - expected: '6', found: '0'
Subtask #7:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 0ms
memory: 3768kb
input:
9431564240371856 11 2072502046158126 2066316271517661 2163529290633843 2033552924777258 2060295112538633 2170963915845858 2830153069449699 2750192266102216 2436460356484587 2070428523960501 2346826281628005
output:
0
result:
wrong answer 1st numbers differ - expected: '5', found: '0'
Subtask #8:
score: 0
Wrong Answer
Test #36:
score: 10
Accepted
time: 0ms
memory: 3780kb
input:
9205033666499013 12 2850462003249404 2805242660077069 2429054981777503 2963815386637346 2482550367349595 1986471485219802 2520994127845999 2437529223970625 2627469170446910 1921642320209105 2645728927620059 2290578758228158
output:
4 5655704663326473 7577346983535578 7642176148546275 8084759645103976
result:
ok 5 number(s): "4 5655704663326473 75773469835...42176148546275 8084759645103976"
Test #37:
score: 10
Accepted
time: 1ms
memory: 3808kb
input:
9312008144548179 12 5098312777552324 2828210584202914 1698846116084863 972763022136388 536323112196116 296239601985823 168374174447656 95736456798989 55681139272124 31357956485449 16061655649327 9384457843970
output:
37 8442757358256913 8599358804238576 8682840868467206 8810706296005373 8839442314448869 8883344013654040 8923399331180905 8967307741987036 8979080470453029 9039945459635703 9080000777162568 9104323959949243 9107508049941485 9124464628318028 9135681916434692 9180145767590152 9188843128631568 92202010...
result:
ok 38 numbers
Test #38:
score: 0
Wrong Answer
time: 0ms
memory: 3852kb
input:
9156085216063046 12 123047715954567 102070372364803 6915592549395858 5255619619792358 3803494030028777 3144753698528503 2201976837739733 1637371070914506 1246360406659115 942243938371027 740235765048371 549861629651347
output:
0
result:
wrong answer 1st numbers differ - expected: '92', found: '0'
Subtask #9:
score: 0
Wrong Answer
Test #41:
score: 0
Wrong Answer
time: 0ms
memory: 3724kb
input:
9386101775874151 13 2988434015746527 2531638596517047 2952017129004226 2532501379103299 2134686632728924 2723134092613376 2734705006477432 2790707225133977 2417142090510094 2242777209869653 2707931539021407 2508571481588074 2833570313484694
output:
0
result:
wrong answer 1st numbers differ - expected: '4', found: '0'
Subtask #10:
score: 0
Wrong Answer
Test #46:
score: 0
Wrong Answer
time: 0ms
memory: 3852kb
input:
9001324849976175 14 2825925335672803 2025589127489736 2269614904415361 1837491879093462 2158539836494236 2426078823971452 1924825856346157 2746394845754343 2268412247933575 2230951690565408 2494052463977166 2855920747842645 2234733913430870 2001499177846439
output:
0
result:
wrong answer 1st numbers differ - expected: '6', found: '0'