QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#325876 | #5535. Popeala | Camillus | 17 | 1737ms | 4948kb | C++20 | 2.8kb | 2024-02-12 02:49:28 | 2024-02-12 02:49:28 |
Judging History
answer
/// @author Camillus <3
#include "bits/stdc++.h"
#define int long long
using namespace std;
namespace st {
static constexpr int size = 32 * 1024;
struct node {
int min = 0;
int add = 0;
} tree[size * 2 - 1];
void set(int i, int v) {
int x = size + i - 1;
tree[x].min = v;
tree[x].add = 0;
while (x) {
x = (x - 1) / 2;
tree[x].min = min(tree[x * 2 + 1].min, tree[x * 2 + 2].min);
tree[x].add = 0;
}
}
void add(int l, int r, int v, int x = 0, int lx = 0, int rx = size) {
if (l <= lx && rx <= r) {
tree[x].add += v;
tree[x].min += v;
return;
}
if (l >= rx || lx >= r) {
return;
}
add(l, r, v, x * 2 + 1, lx, (lx + rx) / 2);
add(l, r, v, x * 2 + 2, (lx + rx) / 2, rx);
tree[x].min = min(
tree[x * 2 + 1].min,
tree[x * 2 + 2].min
) + tree[x].add;
}
int get(int l, int r, int x = 0, int lx = 0, int rx = size) {
if (l <= lx && rx <= r) {
return tree[x].min;
}
if (l >= rx || lx >= r) {
return INT32_MAX;
}
return min(
get(l, r, x * 2 + 1, lx, (lx + rx) / 2),
get(l, r, x * 2 + 2, (lx + rx) / 2, rx)
) + tree[x].add;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, t, s;
cin >> n >> t >> s;
vector<int> points(t + 1);
for (int i = 1; i <= t; i++) {
cin >> points[i];
}
vector<vector<bool>> solved(n, vector<bool>(t + 1));
for (int i = 0; i < n; i++) {
for (int j = 1; j <= t; j++) {
char x;
cin >> x;
solved[i][j] = (x == '1');
}
}
vector<vector<int>> dp(s + 1, vector<int>(t + 1, INT32_MAX));
dp[0][0] = 0;
for (int i = 1; i <= s; i++) {
vector<vector<int>> A(n);
for (int p = 0; p < n; p++) {
A[p].reserve(t + 1);
}
vector<int> B(n);
for (int j = 1; j <= t; j++) {
st::set(j, dp[i - 1][j - 1]);
for (int p = 0; p < n; p++) {
if (solved[p][j]) {
A[p].push_back(j);
st::add(B[p] + 1, j + 1, points[j]);
} else {
for (int _j : A[p]) {
st::add(B[p] + 1, _j + 1, -points[_j]);
}
A[p].resize(0);
B[p] = j;
}
}
dp[i][j] = min(dp[i][j], st::get(1, j + 1));
}
}
for (int i = 1; i <= s; i++) {
cout << dp[i][t] << '\n';
}
return 0;
}
詳細信息
Subtask #1:
score: 8
Accepted
Test #1:
score: 8
Accepted
time: 1ms
memory: 3572kb
input:
2 3 3 4 3 5 101 110
output:
0 8 16
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 4ms
memory: 3660kb
input:
35 40 15 3657 2870 9633 4742 6403 1197 1327 9983 5095 1033 2356 2681 9948 6851 6494 1965 6698 5860 8718 3453 9739 5794 7452 9556 5798 5141 4009 1869 2474 6480 8270 6280 4446 8052 2155 3226 1667 843 2851 6305 1001111110101111111111111110111111111111 1111111111111111111111111111111111111111 1111111111...
output:
2237081 2324849 2390859 2474206 2512547 2586745 2634155 2721923 2787933 2965077 3067335 3199190 3273388 3320798 3497942
result:
ok 15 lines
Subtask #2:
score: 9
Accepted
Test #3:
score: 9
Accepted
time: 278ms
memory: 3784kb
input:
50 500 50 2038 388 7128 2805 5579 3731 7082 6271 5626 5928 8728 304 2767 8798 8311 8389 7924 1727 8612 7438 6588 7056 4588 3823 4615 4201 6337 370 1178 2694 7211 5841 6159 5419 7907 7080 1436 1867 4643 7361 1743 3185 9089 2317 593 9466 8700 9757 8776 8077 1274 1951 4362 1077 3344 2876 4067 1267 8350...
output:
0 95786 114798 244998 580014 717459 985251 1168070 1515088 1816096 2029416 2220312 2309682 2390264 2424480 2759496 2896941 3164733 3347552 3694570 3964964 4276878 4561422 4894290 5003990 5139573 5527629 5756985 5971037 6262492 6443498 6612787 6894109 7085248 7273926 7535859 7746387 8014179 8196998 8...
result:
ok 50 lines
Test #4:
score: 0
Accepted
time: 264ms
memory: 3808kb
input:
48 500 50 446 3830 1528 4330 8911 4558 846 2868 9188 1998 3322 1814 2987 5215 7205 9816 5235 4701 4702 6676 2319 1784 5640 9926 8364 4807 4576 1935 9599 4040 2345 1633 4142 6357 9262 9937 4120 3173 7766 9601 8936 3122 4307 4714 6174 6772 9560 3922 8704 5953 5511 2445 7737 4847 3210 886 6021 9644 803...
output:
0 21408 78954 207754 262858 446698 518514 726354 1052758 1260598 1379440 1514236 1803401 1987241 2059057 2266897 2437072 2676962 2919983 3054779 3409065 3587711 3747167 3834239 3977615 4217505 4548935 4878013 5209443 5467997 5688991 5975512 6111756 6195604 6455044 6809330 7115552 7538608 7744528 783...
result:
ok 50 lines
Test #5:
score: 0
Accepted
time: 274ms
memory: 3772kb
input:
50 500 50 6699 143 4520 2827 506 5190 6117 6490 2219 1723 8693 6430 268 7651 2239 5694 9812 7679 7286 919 6700 9632 2940 3900 9214 7738 3303 1608 8103 406 8651 1959 3280 9029 9278 8175 7398 1742 2818 5354 6941 7740 5687 2549 5345 2267 516 1112 3027 1353 238 8848 8516 1674 4127 8982 4214 1833 2398 94...
output:
0 75650 328273 403923 602803 686125 761775 1016085 1263535 1517845 1718599 1829161 2142083 2330921 2591745 2785985 3027953 3209469 3407613 3617926 3687751 3942061 4152895 4239093 4493403 4755137 4967314 5030524 5284834 5590684 5743514 5867414 6091442 6345752 6651602 6810900 6934800 7158828 7573484 7...
result:
ok 50 lines
Subtask #3:
score: 0
Time Limit Exceeded
Test #6:
score: 9
Accepted
time: 1217ms
memory: 4384kb
input:
48 2200 50 337 3453 6137 1365 4085 2098 573 5755 4273 791 629 3815 1240 5977 8595 9987 9020 5999 9071 655 8343 4000 5410 3356 4673 7505 8440 259 5473 9902 7131 1896 8264 816 2911 1052 8757 5517 4111 9878 7684 3757 5880 6524 6338 7356 1354 3100 9447 8440 8994 4598 1942 7759 3915 3175 980 5528 3090 77...
output:
0 0 0 0 0 0 660 1718 3383 7088 12274 27776 53830 98036 155047 181101 309819 445072 559490 686254 836830 992254 1134321 1269574 1383992 1510756 1661332 1775704 1904422 2038217 2154093 2280857 2431433 2586857 2729260 2884684 3039287 3166051 3321475 3488325 3640414 3790990 3917932 4068508 4209483 43362...
result:
ok 50 lines
Test #7:
score: 0
Accepted
time: 1737ms
memory: 4948kb
input:
50 3000 50 5950 9687 1494 6034 4761 8813 28 5374 6549 5784 7122 6628 7625 1592 8053 6314 9372 6900 648 6460 9268 1116 8934 4230 1174 7325 9231 2614 772 4884 4623 9657 1066 3497 7229 1688 8252 2304 5745 1326 9955 3210 8024 6132 3843 5064 2006 6419 71 2345 198 8006 1436 7082 1269 7055 9759 5497 6895 1...
output:
0 0 0 245 1568 12203 29667 79846 154150 252262 360356 458468 602146 700258 855538 993529 1104983 1252566 1350678 1505958 1643949 1764141 1943732 2063924 2253778 2462901 2583093 2772947 2989382 3146278 3362713 3520158 3736593 4006843 4193364 4383218 4628512 4756549 5002392 5130429 5400679 5674379 588...
result:
ok 50 lines
Test #8:
score: -9
Time Limit Exceeded
input:
50 4000 50 4834 5642 7536 3065 7147 350 2008 8039 3592 4684 3322 807 7023 2937 6910 1227 2027 164 2114 9086 8542 3383 552 4788 35 1988 3351 3344 1515 47 1778 5064 6486 3858 6470 8794 796 4418 93 8192 6908 6828 5856 8724 4727 5801 9128 149 9060 442 7609 4429 555 476 6766 8033 9525 7092 1087 9092 2261...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%