Submission #696324

#TimeUsernameProblemLanguageResultExecution timeMemory
696324Cross_RatioBread First Search (CCO21_day2problem2)C++14
0 / 25
7 ms9936 KiB
#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)

Main.cpp: In function 'int main()':
Main.cpp:11:12: warning: unused variable 'j' [-Wunused-variable]
   11 |     int i, j;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...