QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#737115#7022. Best ACMer Solves the Hardest ProblemSGColin#AC ✓9657ms8680kbC++172.4kb2024-11-12 14:40:492024-11-12 14:40:50

Judging History

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

  • [2024-11-12 14:40:50]
  • 评测
  • 测评结果:AC
  • 用时:9657ms
  • 内存:8680kb
  • [2024-11-12 14:40:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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 N = 6001;

int testcase;

map<int, int> p[N];

inline void work() {
    printf("Case #%d:\n", ++testcase);
    rep(i, 1, N - 1) p[i].clear();
    int n = rd(), m = rd();
    ll lstans = 0;
    rep(i, 1, n) {
        int x = rd(), y = rd(), w = rd();
        p[x][y] = w;
    }
    rep(i, 1, m) {
        int op = rd();
        int x = (rd() + lstans) % 6000 + 1;
        int y = (rd() + lstans) % 6000 + 1;
        if (op == 1) p[x][y] = rd();
        else if (op == 2) p[x].erase(p[x].find(y));
        else if (op == 3) {
            int k = rd(), w = rd();
            int r = sqrt(k), h = 0;
            rep(xx, max(1, x - r), min(6000, x + r)) {
                int dx = abs(x - xx);
                while (dx * dx + h * h <= k) ++h;
                while (dx * dx + h * h > k) --h;
                if (dx * dx + h * h == k) {
                    int yy = y + h;
                    if (p[xx].find(yy) != p[xx].end()) p[xx][yy] += w;
                    if (h != 0){
                        yy = y - h;
                        if (p[xx].find(yy) != p[xx].end()) p[xx][yy] += w;
                    }
                }
            }
        } else {
            int k = rd();
            ll ans = 0;
            int r = sqrt(k), h = 0;
            rep(xx, max(1, x - r), min(6000, x + r)) {
                int dx = abs(x - xx);
                while (dx * dx + h * h <= k) ++h;
                while (dx * dx + h * h > k) --h;
                if (dx * dx + h * h == k) {
                    int yy = y + h;
                    if (p[xx].find(yy) != p[xx].end()) ans += p[xx][yy];
                    if (h != 0){
                        yy = y - h;
                        if (p[xx].find(yy) != p[xx].end()) ans += p[xx][yy];
                    }
                }
            }
            printf("%lld\n", lstans = ans);
        }
    }
}

int main() {
    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: 4040kb

input:

1
3 6
2999 3000 1
3001 3000 1
3000 2999 1
1 2999 3000 1
4 2999 2999 1
2 2995 2996
3 2995 2995 1 1
4 2995 2995 1
4 3000 3000 1

output:

Case #1:
4
6
0

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 9657ms
memory: 8680kb

input:

1000
10 10
3505 4093 1071
2828 5767 1951
4087 1947 2419
1348 1177 6000
271 3657 1998
4584 132 495
4260 4693 129
5112 3484 1918
5754 3661 3066
1629 1302 1691
1 5838 2560 2113
2 4086 1946
2 4583 131
4 4970 4439 4284065
3 2945 677 1239925 5721
4 1523 2487 2014037
2 876 3815
3 5116 5955 680746 5170
3 79...

output:

Case #1:
2113
1951
Case #2:
33271
30497
30497
Case #3:
29279
47107
Case #4:
852
3353
7244
5176
Case #5:
11088
Case #6:
122515
185005
Case #7:
31427
78290
Case #8:
4549
2091
12806
Case #9:
188803
Case #10:
83837
Case #11:
58111
58111
140591
Case #12:
5457
4290
Case #13:
22748
148509
Case #14:
1674
60...

result:

ok 405746 lines