Submission #521511

# Submission time Handle Problem Language Result Execution time Memory
521511 2022-02-02T09:50:09 Z Rasoul006 Usmjeri (COCI17_usmjeri) C++17
28 / 140
153 ms 7368 KB
#include <bits/stdc++.h>

#define endl "\n"

typedef long long ll;

using namespace std;

const int N = 1e6+5;
const int mod = 1e9+7;
ll n , m , is[300009] ;
pair < ll , ll > pr[300009] ;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m ;
    for(int i = 0 ; i < n - 1 ; i++){
        ll a , b ;
        cin >> a >> b ;
    }
    for(int i =1 ; i <= m ; i++){
        ll a , b ;
        cin >> a >> b ;
        pr[i].first = min(a ,b) ;
        pr[i].second = max(a , b) ;
        is[pr[i].first] += 1 ;
        is[pr[i].second] += -1 ;
    }
    for(int i = 1 ; i < n  ;i++){
        is[i] += is[i-1] ;
    }
    ll ans = 1 ;
    ll r = -1 ;
    sort(pr , pr + n) ;
    for(int i = 1 ; i <= m  ;i++){
        if(pr[i].first >= r){
            ans = ((ans % mod) * (2 % mod)) % mod ;
        }
        r = max(r , pr[i].second) ;
    }
    for(int i = 1 ; i < n ; i++){
        if(is[i] == 0){
            ans = ((ans % mod) * (2 % mod)) % mod ;
        }
    }
    cout << ans << endl ;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 44 ms 4136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 109 ms 7368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 123 ms 7340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 153 ms 7344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 7272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 116 ms 7312 KB Output isn't correct
2 Halted 0 ms 0 KB -