QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#125180 | #4967. Square Fishing Net | lian | WA | 1ms | 3420kb | C++14 | 1.1kb | 2023-07-16 04:11:37 | 2023-07-16 04:11:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct Point {
int x;
int y;
};
bool comparePoints(const Point& p1, const Point& p2) {
return (p1.x < p2.x) || (p1.x == p2.x && p1.y < p2.y);
}
int main() {
int s, n;
cin >> s >> n;
vector<Point> fish(n);
for (int i = 0; i < n; i++) {
cin >> fish[i].x >> fish[i].y;
}
sort(fish.begin(), fish.end(), comparePoints);
int maxFish = 0;
for (int i = 0; i < n; i++) {
int fishCount = 1;
for (int j = i + 1; j < n; j++) {
if (fish[j].x - fish[i].x > s) {
break;
}
if (fish[j].y >= fish[i].y && fish[j].y <= fish[i].y + s) {
fishCount++;
}
}
for (int j = i - 1; j >= 0; j--) {
if (fish[i].x - fish[j].x > s) {
break;
}
if (fish[j].y >= fish[i].y && fish[j].y <= fish[i].y + s) {
fishCount++;
}
}
maxFish = max(maxFish, fishCount);
}
cout << maxFish << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3420kb
input:
3 8 2 1 2 3 5 1 5 2 3 2 4 2 10 5 11 5
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3376kb
input:
50 2 10 5 11 5
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3364kb
input:
2 9 100 100 99 99 98 98 98 99 99 98 98 100 100 98 99 100 100 99
output:
9
result:
ok single line: '9'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3376kb
input:
1 9 100 100 99 99 98 98 98 99 99 98 98 100 100 98 99 100 100 99
output:
6
result:
wrong answer 1st lines differ - expected: '4', found: '6'