QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#612983#6703. Tokens on the Segmentszqx#WA 83ms5124kbC++231.1kb2024-10-05 13:23:342024-10-05 13:23:52

Judging History

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

  • [2024-10-05 13:23:52]
  • 评测
  • 测评结果:WA
  • 用时:83ms
  • 内存:5124kb
  • [2024-10-05 13:23:34]
  • 提交

answer

#include<bits/stdc++.h>
#define AC return 0;
#define int long long 
#define pii pair<int,int>
#define all(tar) tar.begian(),tar.end()
const int maxx=2e5+5;
const int mod=998244353; 
using namespace std;
int n,m,t;

struct Line {
    int l, r;

    bool operator < (const Line &other) const {
        if (r != other.r)
            return r < other.r;
        return l < other.l;
    }
};

void Solve()
{
    int n;
    cin >> n;
    vector < Line > a(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i].l >> a[i].r;
    sort (a.begin() + 1, a.end());
    int x = -1;
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        if (x < a[i].l)
        {
            x = a[i].l + 1;
            res++;
        }
        else if(x >= a[i].l && x <= a[i].r)
        {
            x++;
            res++;
        }
    }
    cout << res << "\n";
}

signed main(){
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);

    int T = 1;
    cin >> T;

    while (T--)
    {
        Solve();
    }

   AC
}   

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3556kb

input:

2
3
1 2
1 1
2 3
3
1 2
1 1
2 2

output:

3
2

result:

ok 2 number(s): "3 2"

Test #2:

score: -100
Wrong Answer
time: 83ms
memory: 5124kb

input:

10000
6
5 19
7 12
10 10
4 14
1 12
5 11
7
3 5
1 10
12 15
2 13
8 11
5 20
11 14
18
6 17
6 9
6 20
2 7
1 11
16 19
2 5
1 14
5 8
14 19
4 7
11 19
11 13
2 9
3 12
12 13
19 19
13 16
11
11 13
1 2
14 17
15 16
12 17
15 17
6 7
8 11
12 19
3 8
10 19
18
6 9
16 18
13 15
14 15
9 13
2 8
12 18
8 16
16 18
3 18
1 12
4 13
1...

output:

5
7
18
10
14
12
8
15
14
3
4
5
9
15
14
16
15
12
8
15
14
15
11
14
11
11
4
13
13
3
5
13
9
3
15
8
8
15
7
15
4
11
18
17
6
12
12
12
18
10
6
6
11
7
12
12
15
3
15
12
12
14
7
6
6
11
13
13
3
5
3
4
10
6
3
7
13
14
11
4
9
8
15
15
10
10
10
8
4
11
17
8
15
10
14
15
13
11
6
12
14
15
10
6
8
8
9
13
8
12
13
15
12
15
12...

result:

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