QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#258244#7583. Farawayddl_VS_pigeon#WA 13ms3620kbC++172.0kb2023-11-19 16:19:532023-11-19 16:19:53

Judging History

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

  • [2023-11-19 16:19:53]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:3620kb
  • [2023-11-19 16:19:53]
  • 提交

answer

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

struct Point{
    int x, y;
};
struct Rec{
    Point lu, rd;
    void insert(Rec& o) {
        lu.x = max(lu.x, o.lu.x);
        lu.y = max(lu.y, o.lu.y);
        rd.x = min(rd.x, o.rd.x);
        rd.y = min(rd.y, o.rd.y);
    }
    int val(int delta) {
        return 1 + (delta-1)/60;
    }
    long long calc(int x, int y) {
        return 1ll*val(x - lu.x)*val(y - lu.y);
    }
};

struct note{
    int x, y, k, t;
};

int dis(Point p1, Point p2) {
    return abs(p1.x-p2.x) + abs(p1.y-p2.y);
}
long long calc(vector<note> &s, Rec rec) {
    long long ans = 0;
    for (int i=max(rec.rd.x-60+1, rec.lu.x); i<=rec.rd.x; i++) {
        for (int j=max(rec.rd.y-60+1, rec.lu.y); j<=rec.rd.y; j++) {
            bool isValid = true;
            for (auto item : s) {
                if (dis({item.x, item.y}, {i, j})%item.k == item.t) {
                    continue;
                }else{
                    isValid=false;
                    break;
                }
            }
            if (isValid) {
                ans += rec.calc(i, j);
            }
        }
    }
    return ans;
}

void solve() {
    int n, m;
    cin>>n>>m;
    vector<note> s(n);
    vector<int> xline = {0, m+1}, yline = {0, m+1};
    for (int i=0;i<n;i++) {
        cin>>s[i].x>>s[i].y>>s[i].k>>s[i].t;
        xline.push_back(s[i].x);
        yline.push_back(s[i].y);
    }
    sort(xline.begin(), xline.end());
    sort(yline.begin(), yline.end());

    long long ans = 0;
    for (int i=1;i<(int)xline.size();i++) {
        for (int j=1;j<(int)yline.size();j++) {
            Rec rec = {
                {xline[i-1], yline[j-1]}, 
                {xline[i]-1, yline[j]-1}
            };
            ans += calc(s, rec);
        }
    }
    
    printf("%lld\n", ans);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T;
    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: 3620kb

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: -100
Wrong Answer
time: 13ms
memory: 3620kb

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
116250820
43298567273
1839945977784
820599537801896
19922821360412667
50544303509071
64150013596994

result:

wrong answer 4th numbers differ - expected: '116256265', found: '116250820'