QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226031#7583. Farawayucup-team004#AC ✓86ms3644kbC++202.1kb2023-10-25 14:51:582023-10-25 14:51:58

Judging History

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

  • [2023-10-25 14:51:58]
  • 评测
  • 测评结果:AC
  • 用时:86ms
  • 内存:3644kb
  • [2023-10-25 14:51:58]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n, m;
    std::cin >> n >> m;
    m += 1;

    std::vector<int> x(n), y(n), k(n), t(n);
    std::vector<int> vx{0, m}, vy{0, m};
    for (int i = 0; i < n; i++) {
        std::cin >> x[i] >> y[i] >> k[i] >> t[i];
        vx.push_back(x[i]);
        vy.push_back(y[i]);
    }
    std::sort(vx.begin(), vx.end());
    std::sort(vy.begin(), vy.end());
    vx.erase(std::unique(vx.begin(), vx.end()), vx.end());
    vy.erase(std::unique(vy.begin(), vy.end()), vy.end());

    i64 ans = 0;
    for (int i = 0; i < vx.size() - 1; i++) {
        for (int j = 0; j < vy.size() - 1; j++) {
            for (int mx = 0; mx < 60; mx++) {
                for (int my = 0; my < 60; my++) {
                    bool ok = true;
                    for (int l = 0; l < n; l++) {
                        int a = 0;
                        if (vx[i] < x[l]) {
                            a += x[l] - mx;
                        } else {
                            a += mx - x[l];
                        }
                        if (vy[j] < y[l]) {
                            a += y[l] - my;
                        } else {
                            a += my - y[l];
                        }
                        a %= k[l];
                        if (a < 0) {
                            a += k[l];
                        }
                        if (a != t[l]) {
                            ok = false;
                        }
                    }
                    if (ok) {
                        i64 nx = (vx[i + 1] - mx + 59) / 60 - (vx[i] - mx + 59) / 60;
                        i64 ny = (vy[j + 1] - my + 59) / 60 - (vy[j] - my + 59) / 60;
                        ans += nx * ny;
                    }
                }
            }
        }
    }

    std::cout << ans << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 5
1 2 4 2
3 1 2 1
2 5
1 2 4 2
1 2 4 3

output:

10
0

result:

ok 2 number(s): "10 0"

Test #2:

score: 0
Accepted
time: 86ms
memory: 3644kb

input:

10
10 950006
879210 618398 2 0
413993 805537 5 0
614389 782151 5 4
616385 454674 4 2
6020 332147 5 0
77932 43110 4 1
143614 196643 4 0
937161 934707 4 1
318567 789911 4 0
194658 555381 5 3
10 967857178
8983267 44864625 3 2
141087113 359274718 2 1
909006720 262061158 3 0
840340929 715591525 3 2
76531...

output:

0
0
0
116256265
43298776834
1839945977784
820599567890959
19922821864719464
50544306663055
64150016306836

result:

ok 10 numbers