QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741688#7028. Renaissance Past in NancySGColinAC ✓1224ms82456kbC++171.7kb2024-11-13 15:00:392024-11-13 15:00:40

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 15:00:40]
  • 评测
  • 测评结果:AC
  • 用时:1224ms
  • 内存:82456kb
  • [2024-11-13 15:00:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

inline int rd() {
    int x = 0;
    bool f = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) f |= (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    return f ? -x : x;
}

#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

const int C = 1007;
const int N = 10007;
const int mod = 1000000007;

int testcase, F[N][C], G[N][C];

void add(int &a, int b) {a = (a + b >= mod ? a + b - mod : a + b);}

inline void work() {
    printf("Case #%d:\n", ++testcase);
    int n = rd(), m = rd();
    rep(j, 1, 1000) G[0][j] = 0;
    rep(i, 1, n) {
        int a = rd(), b = rd();
        int t = (a + 1) * b;
        rep(j, 0, 1000) F[i][j] = F[i - 1][j];
        if (t <= 1000) rep(j, t, 1000) add(F[i][j], mod - F[i - 1][j - t]);
        rep(j, b, 1000) add(F[i][j], F[i][j - b]);
        rep(j, 0, 1000) G[i][j] = G[i - 1][j];
        rep(j, b, 1000) add(G[i][j], mod - G[i - 1][j - b]);
        if (t <= 1000) rep(j, t, 1000) add(G[i][j], G[i][j - t]);
    }
    rep(i, 0, n) rep(j, 1, 1000) add(G[i][j], G[i][j - 1]);
    int lstans = 0;
    rep(i, 1, m) {
        int l = (rd() + lstans) % n + 1;
        int r = (rd() + lstans) % n + 1;
        if (l > r) swap(l, r);
        int c = rd(), ans = 0;
        rep(i, 0, c) ans = (ans + 1ll * F[r][i] * G[l - 1][c - i]) % mod;
        printf("%d\n", lstans = ans);
    }
}

int main() {
    F[0][0] = G[0][0] = 1;
    per(t, rd(), 1) work();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6004kb

input:

1
3 3
1 1
1 2
1 3
1 3 1
1 3 2
1 3 3

output:

Case #1:
2
3
4

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 1224ms
memory: 82456kb

input:

1000
13 17
24 7
20 6
16 11
3 27
23 7
14 13
18 29
7 9
1 11
4 25
3 25
14 1
31 9
5 7 933
9 9 439
2 9 677
9 12 978
2 6 479
2 4 893
1 9 953
2 7 927
3 4 718
8 12 973
9 12 766
7 8 293
4 8 331
6 11 865
12 13 834
5 12 475
3 8 762
74 47
3 604
3 355
2 738
2 552
2 622
3 198
2 817
14 116
2 659
1 962
1 784
2 669
...

output:

Case #1:
2280
21
1568333
9600
19200
1428
153600
153600
10
22800
320
68
4800
602566225
525
771665
7312668
Case #2:
1926
1085
15085974
134200734
52983637
741561
51
736633
22
414295
3207
109210
7812
18122
20709361
540077
2358
58507
9612
679839907
109366763
294
35
4690542
81375272
135
346774225
224116
2...

result:

ok 173268 lines