This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
const int mod = 1e9+7;
int open[maxn], close[maxn];
int main(void)
{
int n, m;
cin >> n >> m;
for (int i = 1; i <= n-1; i++)
{
int a, b;
cin >> a >> b;
}
for (int i = 1; i <= m; i++)
{
int a, b;
cin >> a >> b;
open[a]++, close[b]--;
}
int qtd = 0, x = 0;
for (int i = 1; i < n; i++)
{
qtd -= close[i];
if (!qtd) x++;
qtd += open[i];
}
long long ans = 1;
for (int i = 1; i <= x; i++)
ans = (ans*2LL)%mod;
cout << ans << "\n";
}
# | 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... |