QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#258205 | #7583. Faraway | ddl_VS_pigeon# | TL | 1ms | 3616kb | C++17 | 2.2kb | 2023-11-19 16:00:27 | 2023-11-19 16:00:27 |
Judging History
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;
vector<Rec> dir;
void work(int m) {
dir.push_back({{0, 0}, {x, y}});
dir.push_back({{0, y+1}, {x, m}});
dir.push_back({{x+1, y+1}, {m, m}});
dir.push_back({{x+1, 0}, {m, y}});
}
Rec cur;
void set(int i) {
cur = dir[i];
}
};
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 = s[0].cur;
for (int i=1;i<(int)s.size();i++) {
rec.insert(s[i].cur);
}
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);
for (int i=0;i<n;i++) {
cin>>s[i].x>>s[i].y>>s[i].k>>s[i].t;
s[i].work(m);
}
long long ans = 0;
for (int state=0;state<(1<<(n*2));state++) {
for (int i=0;i<2*n;i++) {
int v1 = (state&i)!=0;
int v2 = (state&(i+1))!=0;
s[i/2].set((v1<<1)+v2);
}
ans += calc(s);
}
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;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
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
Time Limit Exceeded
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...