QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#125180#4967. Square Fishing NetlianWA 1ms3420kbC++141.1kb2023-07-16 04:11:372023-07-16 04:11:40

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-16 04:11:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3420kb
  • [2023-07-16 04:11:37]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'