提交记录 14066
用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
---|---|---|---|---|---|---|---|
saffah | 2003. 【NOI2020】美食家(加强版) | Accepted | 100 | 1.25 s | 222800 KB | C++ | 3.18 KB |
提交时间 | 评测时间 |
---|---|
2020-08-28 22:34:12 | 2020-08-28 22:34:47 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 100;
const int MAXM = 1000;
const int MAXW = 100;
const int MAXK = 10002;
static inline void upd(ll& x, const ll y) {
x -= ((x - y) & ((x - y) >> 63));
}
static int n, m, c[MAXN];
struct Edge {
char u, v, w;
} e[MAXM];
struct Event {
int t, x, y;
bool operator <(const Event& rhs) const {
return t < rhs.t;
}
} q[MAXK];
static ll pool[500000][MAXN];
static ll (*buf)[MAXN] = &pool[0];
static int xjj;
struct Pre {
ll (*dp)[MAXN];
int orig, anot; ll dx;
void init(int s) {
dp = buf;
memset(dp, 0xcc, sizeof(*dp) * MAXW);
dp[0][s] = 0;
vector<ull> hs;
for (int i = 0;; i++) {
for (int j = 0; j < n; j++)
dp[i][j] += c[j];
ull h = 0;
for (int j = 0; j < n; j++)
h ^= (j + 1) * (ull) (dp[i][j] - dp[i][s]);
hs.push_back(h);
if (xjj) {
if (i > xjj + MAXW && !memcmp(hs.data() + i - xjj - MAXW, hs.data() + i - MAXW, MAXW * sizeof(ull))) {
orig = i - xjj;
anot = i;
break;
}
} else {
for (int j = MAXW; j + MAXW < i; j++)
if (!memcmp(hs.data() + i - MAXW, hs.data() + j - MAXW, MAXW * sizeof(ull))) {
orig = j;
anot = i;
goto ok;
}
}
memset(dp + i + MAXW, 0xcc, sizeof(*dp));
for (int j = 0; j < m; j++)
upd(dp[i + e[j].w][e[j].v], dp[i][e[j].u]);
}
ok:;
dx = dp[anot][s] - dp[orig][s];
xjj = anot - orig;
buf += anot;
// fprintf(stderr, "pre %d, orig %d, anot %d, dx %lld\n", s, orig, anot, dx);
}
ll query(int T, int t) {
if (T < anot)
return dp[T][t];
return dp[orig + (T - orig) % xjj][t] + (T - orig) / xjj * dx;
}
} pre[MAXN];
static ll calc(int s, int t, int T) {
return pre[s].query(T, t) - c[t];
}
int main() {
// #ifdef ONLINE_JUDGE
// freopen("delicacy.in", "r", stdin);
// freopen("delicacy.out", "w", stdout);
// #endif
int T, k;
cin >> n >> m >> T >> k;
for (int i = 0; i < n; i++)
cin >> c[i];
for (int i = 0; i < m; i++) {
int u, v, w;
cin >> u >> v >> w;
e[i].u = u - 1; e[i].v = v - 1; e[i].w = w;
}
for (int i = 0; i < n; i++)
pre[i].init(i);
cerr << "Loop length " << xjj << ", weight " << pre[0].dx << endl;
for (int i = 1; i <= k; i++) {
cin >> q[i].t >> q[i].x >> q[i].y;
q[i].x--;
}
sort(q + 1, q + k + 1);
q[0].t = 0; q[0].x = 0; q[0].y = 0;
q[k + 1].t = T; q[k + 1].x = 0; q[k + 1].y = c[0];
static ll dp[MAXK];
memset(dp, 0xcc, sizeof(dp));
dp[0] = 0;
for (int i = 1; i <= k + 1; i++) {
for (int j = 0; j < i; j++)
upd(dp[i], dp[j] + calc(q[j].x, q[i].x, q[i].t - q[j].t));
dp[i] += q[i].y;
}
upd(dp[k + 1], -1);
cout << dp[k + 1] << endl;
cerr << buf - pool << endl;
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 714.471 ms | 30 MB + 36 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 880.298 ms | 75 MB + 144 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #3 | 809.133 ms | 57 MB + 44 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #4 | 723.375 ms | 32 MB + 60 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 727.123 ms | 34 MB + 260 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 1.211 s | 186 MB + 576 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 1.033 s | 153 MB + 344 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 887.528 ms | 42 MB + 848 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 715.162 ms | 28 MB + 544 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 747.43 ms | 32 MB + 540 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 976.213 ms | 73 MB + 60 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 740.108 ms | 30 MB + 832 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 727.749 ms | 26 MB + 764 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #14 | 1.102 s | 153 MB + 896 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #15 | 706.236 ms | 30 MB + 736 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #16 | 846.694 ms | 39 MB + 104 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #17 | 720.167 ms | 28 MB + 592 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #18 | 1.191 s | 217 MB + 592 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #19 | 736.585 ms | 29 MB + 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #20 | 711.521 ms | 31 MB + 340 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #21 | 734.422 ms | 29 MB + 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #22 | 732.036 ms | 30 MB + 380 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #23 | 725.292 ms | 34 MB + 568 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #24 | 767.929 ms | 36 MB + 968 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #25 | 720.919 ms | 31 MB + 1020 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #26 | 774.633 ms | 33 MB + 760 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #27 | 824.429 ms | 53 MB + 240 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #28 | 722.402 ms | 35 MB + 900 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #29 | 824.285 ms | 55 MB + 588 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #30 | 772.556 ms | 34 MB + 220 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #31 | 786.375 ms | 32 MB + 704 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #32 | 752.555 ms | 30 MB + 300 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #33 | 738.147 ms | 29 MB + 968 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #34 | 1.25 s | 181 MB + 84 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #35 | 893.165 ms | 44 MB + 352 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #36 | 829.534 ms | 38 MB + 84 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #37 | 739.813 ms | 29 MB + 896 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #38 | 723.028 ms | 31 MB + 980 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #39 | 753.21 ms | 32 MB + 600 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #40 | 892.497 ms | 40 MB + 36 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #41 | 816.538 ms | 36 MB + 736 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #42 | 749.232 ms | 32 MB + 688 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #43 | 744.46 ms | 29 MB + 304 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #44 | 796.375 ms | 39 MB + 48 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #45 | 743.728 ms | 31 MB + 48 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #46 | 809.998 ms | 34 MB + 864 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #47 | 742.525 ms | 28 MB + 272 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #48 | 723.759 ms | 33 MB + 192 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #49 | 915.318 ms | 48 MB + 820 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #50 | 828.149 ms | 61 MB + 664 KB | Accepted | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-11-21 20:34:40 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠