Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- ///Problem C
- for (int l = 0; l < n; l++) {
- int cur_sum = 0;
- for (int r = l; r < n; r++) {
- cur_sum += a[r];
- if (cur_sum == 0) {
- cout << l << ' ' << r << endl;
- }
- }
- }
- ///Problem D
- ///pref[i] = a[0] + a[1] + ... + a[i]
- ///pref[i] = pref[i - 1] + a[i]
- ///a[l] + a[l + 1] + ... + a[r] = pref[r] - pref[l - 1] = 0
- ///for r = 0..n
- /// if there is such l <= r so that pref[l - 1] = pref[r] ??
- map<int, bool> was;
- was[0] = 0;
- int cur_sum = 0;
- for (int r = 0; i < n; i++) {
- cur_sum += a[r];
- if (was[cur_sum]) {
- cout << was[cur_sum] << ' ' << r << endl;
- return 0;
- }
- was[cur_sum] = r;
- }
- ///Problems E-F
- ///1. calculate number of L's = x
- ///2. calculate number of R's among first x elements = y
- ///3. y is the answer
- ///[] [] [R] [] [R] [] ... [] [] []
- ///problem H
- ///Dijkstra
- ///problem I
- ///1. If the size of the clique (n / 2) => approx. (n/2)^2 edges
- ///2.1. DSU
- ///2.2. clique 2 (v1, v2, v3) => add c2, connect it with v1, v2, v3
- /// v1 with v2, v1 with v3
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement