Submission #82600

#TimeUsernameProblemLanguageResultExecution timeMemory
82600thiago4532Usmjeri (COCI17_usmjeri)C++17
0 / 140
173 ms5336 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define int long long using namespace std; typedef pair<int, int> pii; const int maxn = 3e5 + 10; int n, m; pii v_[maxn], v[maxn]; bool mark[maxn]; int32_t main(){ ios::sync_with_stdio(false), cin.tie(0); cin >> n >> m; for(int i=1;i<n;i++){ int a, b; cin >> a >> b; } for(int i=1;i<=m;i++) cin >> v_[i].ff >> v_[i].ss; sort(v_+1, v_+m+1); int k=1; v[k] = v_[k]; for(int i=2;i<=m;i++){ if(v[i].ff <= v[k].ss && v_[i].ss <= v[k].ss) continue; else if(v[i].ff <= v[k].ss) v[k].ss = v_[i].ss; else v[++k] = v_[i]; } m = k; int ans=(n-1-m)*2*m; cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...