QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#248919#1347. Universal and Existential QuantifiersAnwar_Gehad_Maghraby#RE 1ms3464kbC++201.6kb2023-11-11 22:48:142023-11-11 22:48:14

Judging History

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

  • [2023-11-11 22:48:14]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3464kb
  • [2023-11-11 22:48:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 3002 , MOD =  998244353 ; //1e9 + 7;

vector< pair<int ,int > > v;
int n ;

int32_t main() {

    cin.tie(0);cin.sync_with_stdio(0);
    cout.tie(0);cout.sync_with_stdio(0);

    ll l ;

    cin >> n >> l ;

    vector<ll> all ;
    pair<ll ,ll > a[n] ;
    v.resize(n) ;

    int y =0 ;

    int my =0 ,  my2 =0 ;

    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second ;

        a[i].second-- ;

        all.push_back(a[i].first) , all.push_back( a[i].second ) ;
        all.push_back(a[i].second + 1) ;

        if( a[i].second + 1 != l && a[i].first  ) y++ ;

        if( a[i].first == 0 && a[i].second + 1 != l ) my++ ;

        if(a[i].first && a[i].second + 1 == l) my2++ ;
    }

    sort(all.begin() , all.end() ) ;
    all.erase(unique(all.begin() , all.end()) , all.end()) ;

    for (int i = 0; i < n; ++i) {
        v[i].first = lower_bound( all.begin() , all.end() , a[i].first ) - all.begin() ;
        v[i].second = lower_bound( all.begin() , all.end() , a[i].second ) - all.begin() ;
    }

    sort( v.begin() , v.end() ) ;

    int sz = (int)all.size() ;

    priority_queue<int> q ;

    vector<int> st[sz];
    for (int i = 0; i < n; ++i) {
        st[a[i].first].push_back(a[i].second) ;
    }

    int x =0  ,lst_c = -1 ;
    for(int i=0 ; i < sz-1 ; i++)
    {
        for(int e : st[i] ) q.push(e) ;

        if( lst_c < i )
        {
            lst_c = q.top() ;
            x++ ;
        }
    }

    cout << x << " " << y + max( my , my2 ) + 1 ;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
0 2
1 3
1 2

output:

2 3

result:

ok 2 number(s): "2 3"

Test #2:

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

input:

2 4
0 4
0 4

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3428kb

input:

5 4
0 2
2 4
0 3
1 3
3 4

output:

2 4

result:

ok 2 number(s): "2 4"

Test #4:

score: -100
Runtime Error

input:

72 6951
1279 5415
5774 5967
352 2975
4106 6269
565 3393
4119 5218
3154 4517
1323 4249
5468 6430
4356 6171
6461 6777
5997 6190
2895 6933
2072 5554
975 2873
3436 5916
6078 6377
6068 6569
4419 4775
4637 6656
1821 6617
2430 4645
4251 5125
2873 6894
5102 5914
785 2327
2853 6333
6091 6302
1477 6365
2015 4...

output:


result: