QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323184#62. Examinationan22inkle0 44ms4920kbC++171.7kb2024-02-08 19:48:402024-02-08 19:48:42

Judging History

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

  • [2024-02-08 19:48:42]
  • 评测
  • 测评结果:0
  • 用时:44ms
  • 内存:4920kb
  • [2024-02-08 19:48:40]
  • 提交

answer

#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using pair = std::array<int, 2>;
using pairll = std::array<ll, 2>;
using tri = std::array<int, 3>;
using trill = std::array<ll, 3>;

constexpr long long MOD = 998244353;

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

    int N, Q;
    std::cin >> N >> Q;

    std::vector<tri> points;

    for (int i = 0; i < N; i++) {
    	int a, b;
    	std::cin >> a >> b;
    	tri score = {a, b, 1};
    	points.push_back(score);
    }


    std::sort(points.begin(), points.end(), [](tri a, tri b) {
    	if (a[0] != b[0]) {
    		return a[0] > b[0];
    	} else {
    		return a[1] > b[1];
    	}
    });

    // unique
    for (int i = points.size() - 1; i >= 0; i--) {
    	if (points[i][0] == points[i+1][0] && points[i][1] == points[i+1][1]) {
    		points[i][2] += points[i+1][2];
    	}
    }
    points.erase(std::unique(points.begin(), points.end(), [](tri a, tri b){return a[0] == b[0] && a[1] == b[1];}), points.end());


    for (auto point : points) {
    	// std::cout << point[0] << ' ' << point[1] << ' ' << point[2] << '\n';
    }

    for (int i = 1; i < points.size(); i++) {
    	points[i][2] += points[i-1][2];
    }

    // std::cout << points[points.size() - 1][2] << '\n';
    while (Q--) {
    	int x, y ,z;
    	std::cin >> x >> y >> z;

        tri search  = {x, y, 0};
        std::vector<tri>::iterator target = std::upper_bound(points.begin(), points.end(), search, [](tri val, tri el) {return val[0] >= el[0];});
    	if (target == points.end()) {
            std::cout << "0\n";
            continue;
        }
        std::cout << (*target)[2] << '\n';

    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3568kb

input:

10 10
28 2
78 81
39 79
61 31
36 99
90 5
20 55
91 4
48 19
80 7
52 43 78
64 65 171
34 68 124
37 80 161
53 19 123
49 58 109
95 46 30
45 48 60
47 13 54
64 30 144

output:

6
5
9
8
6
6
1
7
7
5

result:

wrong answer 1st lines differ - expected: '1', found: '6'

Subtask #2:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 44ms
memory: 4920kb

input:

100000 100000
26753 11234
32815 62591
34318 93262
77179 57605
88208 33327
48449 99060
42403 58561
85715 7001
2418 90938
77409 6957
546 83283
53957 8374
49470 1483
65866 64950
4269 8745
19041 85833
22344 90706
92926 35603
54697 75311
72601 66401
77598 8193
3751 54202
32710 5877
23835 38264
34381 3338...

output:

14136
32481
29345
31353
29235
95918
4222
77779
35140
54215
66382
64319
60068
23055
57232
9855
78981
27045
39518
65237
99825
48080
18178
16302
86477
1147
33629
26234
51233
93974
32556
93695
60293
89780
559
63911
6178
2708
17950
38318
74969
95293
39125
15799
40507
65341
78713
52577
87083
85891
14559
6...

result:

wrong answer 1st lines differ - expected: '3392', found: '14136'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%