QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#612693#8247. ICPC Team GenerationAmy621WA 0ms3740kbC++141.5kb2024-10-05 12:36:452024-10-05 12:36:46

Judging History

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

  • [2024-10-05 12:36:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2024-10-05 12:36:45]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <numeric>
#include <iomanip>
 
int main() {
    // Number of people
    int n; 
    cin >> n;
    vector<pair<int, int>> ranges; // to store (a, b) pairs

    // Read input ranges
    for (int i = 1; i <= n; i++) {
        int a, b; 
        cin >> a >> b;
        if (b - a < 2) continue; // skip ranges that can't form a team
        ranges.push_back(make_pair(a, b));
    }

    // sort ranges by their starting point
    sort(ranges.begin(), ranges.end());

    int count = 0; 
    int i = 0;


        while (i < ranges.size()) {
       
        if (i + 2 < ranges.size()) {
            int a1 = ranges[i].first;  
            int b1 = ranges[i].second;  
            int a2 = ranges[i + 1].first;
            int b2 = ranges[i + 1].second; 
            int a3 = ranges[i + 2].first; 
            int b3 = ranges[i + 2].second;
            
       
            if (a1 <= a2 && b1 >= a3 &&  
                a2 <= a1 && b2 >= a3 &&  
                a3 <= a1 && b3 >= a2) {  
                
                count++;
                i += 3; 
            } else {
                i++; 
            }
        } else {
            break; 
        }
    }

    cout << count << "\n"; 
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

6
1 2
1 2
2 5
2 6
2 6
5 6

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

3
1 1
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

50
1 2
1 3
2 4
3 5
4 6
5 7
6 8
7 9
8 10
9 11
10 12
11 13
12 14
13 15
14 16
15 17
16 18
17 19
18 20
19 21
20 22
21 23
22 24
23 25
24 26
25 27
26 28
27 29
28 30
29 31
30 32
31 33
32 34
33 35
34 36
35 37
36 38
37 39
38 40
39 41
40 42
41 43
42 44
43 45
44 46
45 47
46 48
47 49
48 50
49 50

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50
1 50

output:

16

result:

ok single line: '16'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3740kb

input:

50
1 11
2 11
3 12
3 14
3 15
3 16
7 17
7 17
7 18
8 19
11 21
11 22
11 22
14 23
15 25
16 25
17 25
18 27
18 27
20 29
21 30
22 30
22 33
23 34
24 34
24 34
25 37
28 37
29 38
29 38
31 41
32 41
33 43
33 43
35 44
35 46
36 47
37 47
38 48
39 49
39 50
41 50
42 50
44 50
45 50
45 50
45 50
47 50
48 50
48 50

output:

4

result:

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