# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
696324 | Cross_Ratio | Bread First Search (CCO21_day2problem2) | C++14 | 7 ms | 9936 KiB |
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;
int B[200005];
vector<int> adj[200005];
signed main() {
cin.sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int N, M;
cin >> N >> M;
int i, j;
for(i=1;i<=N;i++) B[i] = i;
for(i=0;i<M;i++) {
int a, b;
cin >> a >> b;
if(a > b) swap(a, b);
B[a] = max(B[a], b);
adj[b].push_back(a);
}
int ans = 0;
int l = 1, r = 2;
while(r != N+1) {
int mi = 1e9;
for(i=l;i<r;i++) {
mi = min(mi, B[i]);
}
if(mi == r - 1) mi++;
int r2 = mi + 1;
for(i=r;i<r2;i++) {
if(adj[i].size()==0) ans++;
}
l = r, r = r2;
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |