이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++){
cin >> pr[i].first >> pr[i].second ;
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 ;
for(int i = 1 ; i <= m ;i++){
if(pr[i].first >= r){
r = pr[i].second ;
ans = ((ans % mod) * (2 % mod)) % mod ;
}
}
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |