# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
235443 |
2020-05-28T09:48:30 Z |
VEGAnn |
Usmjeri (COCI17_usmjeri) |
C++14 |
|
371 ms |
41340 KB |
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair
#define ft first
#define sd second
#define PB push_back
#define pli pair<ll,int>
using namespace std;
typedef long long ll;
const int N = 300100;
const int PW = 22;
const int oo = 2e9;
const int md = int(1e9) + 7;
vector<int> ins[N], del[N];
multiset<int> mx;
int n, m, pr[N], ans = 1;
bool mrk[N];
int get(int x) { return (pr[x] == x ? x : pr[x] = get(pr[x])); }
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> m;
for (int i = 1; i < n; i++){
int x, y; cin >> x >> y;
x--; y--;
pr[i] = i;
}
for (int i = 0; i < m; i++){
int l, r; cin >> l >> r;
if (l > r) swap(l, r);
l--; r--;
ins[l + 1].PB(r);
del[r].PB(r);
}
mx.clear();
for (int i = 1; i < n; i++){
for (int cr : ins[i])
mx.insert(cr);
if (sz(mx) > 0)
pr[i] = get(*(--mx.end()));
for (int cr : del[i])
mx.erase(mx.find(cr));
}
for (int i = 1; i < n; i++){
int cur = get(i);
if (mrk[cur]) continue;
mrk[cur] = 1;
ans += ans;
if (ans >= md)
ans -= md;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
190 ms |
27384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
367 ms |
35192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
14464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
14464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
14848 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
14824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
350 ms |
41184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
371 ms |
40824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
369 ms |
41340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
366 ms |
41084 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |