Submission #842214

#TimeUsernameProblemLanguageResultExecution timeMemory
842214serifefedartarOsumnjičeni (COCI21_osumnjiceni)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0); typedef long long ll; #define f first #define s second #define MOD 1000000007 #define LOGN 20 #define MAXN 200005 int sg[4*MAXN], lazy[4*MAXN]; int up[LOGN][MAXN], depth[MAXN]; vector<vector<int>> graph; pair<int,int> segments[MAXN]; vector<int> cc; void dfs(int node, int parent) { for (auto u : graph[node]) { if (u == parent) continue; depth[u] = depth[node] + 1; dfs(u, node); } } void update(int k, int a, int b, int q_l, int q_r, int val) { if (lazy[k]) { sg[k] += lazy[k]; if (a != b) { lazy[2*k] += lazy[k]; lazy[2*k+1] += lazy[k]; } lazy[k] = 0; } if (b < q_l || a > q_r) return ; if (q_l <= a && b <= q_r) { sg[k] += val; if (a != b) { lazy[2*k] += val; lazy[2*k+1] += val; } return ; } update(2*k, a, (a+b)/2, q_l, q_r, val); update(2*k+1, (a+b)/2+1, b, q_l, q_r, val); sg[k] = max(sg[2*k], sg[2*k+1]); } int index(int k) { return upper_bound(cc.begin(), cc.end(), k) - cc.begin(); } int main() { fast int N; cin >> N; graph = vector<vector<int>>(N+2, vector<int>()); for (int i = 1; i <= N; i++) { cin >> segments[i].f >> segments[i].s; cc.push_back(segments[i].f); cc.push_back(segments[i].s); } sort(cc.begin(), cc.end()); cc.erase(unique(cc.begin(), cc.end()), cc.end()); int n = cc.size(); int L = 1; for (int R = 1; R <= N; R++) { update(1, 1, n, index(segments[R].f), index(segments[R].s, 1)); while (sg[1] > 1) { up[0][L] = R; graph[R].push_back(L); update(1, 1, n, index(segments[L].f), index(segments[L].s, -1)); L++; } } for (int i = 1; i <= N; i++) { if (up[0][i] == 0) { up[0][i] = N+1; graph[N+1].push_back(i); } } dfs(N+1, N+1); for (int i = 0; i < LOGN; i++) up[i][N+1] = N+1; for (int i = 1; i < LOGN; i++) { for (int j = 1; j <= N; j++) { up[i][j] = up[i-1][up[i-1][j]]; } } int Q; cin >> Q; while (Q--) { int a, b; cin >> a >> b; b = up[0][b]; int cnt = 0; int now = a; for (int i = LOGN-1; i >= 0; i--) { if (depth[up[i][now]] > depth[b]) { now = up[i][now]; cnt += (1<<i); } } cout << cnt + 1 << "\n"; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:72:69: error: no matching function for call to 'index(int&, int)'
   72 |         update(1, 1, n, index(segments[R].f), index(segments[R].s, 1));
      |                                                                     ^
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Main.cpp:1:
/usr/include/strings.h:55:1: note: candidate: 'char* index(char*, int)' (near match)
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:   conversion of argument 1 would be ill-formed:
Main.cpp:7:11: error: invalid conversion from 'int' to 'char*' [-fpermissive]
    7 | #define s second
      |           ^
      |           |
      |           int
Main.cpp:72:65: note: in expansion of macro 's'
   72 |         update(1, 1, n, index(segments[R].f), index(segments[R].s, 1));
      |                                                                 ^
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Main.cpp:1:
/usr/include/strings.h:61:1: note: candidate: 'const char* index(const char*, int)' (near match)
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:61:1: note:   conversion of argument 1 would be ill-formed:
Main.cpp:7:11: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
    7 | #define s second
      |           ^
      |           |
      |           int
Main.cpp:72:65: note: in expansion of macro 's'
   72 |         update(1, 1, n, index(segments[R].f), index(segments[R].s, 1));
      |                                                                 ^
Main.cpp:76:74: error: no matching function for call to 'index(int&, int)'
   76 |             update(1, 1, n, index(segments[L].f), index(segments[L].s, -1));
      |                                                                          ^
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Main.cpp:1:
/usr/include/strings.h:55:1: note: candidate: 'char* index(char*, int)' (near match)
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:   conversion of argument 1 would be ill-formed:
Main.cpp:7:11: error: invalid conversion from 'int' to 'char*' [-fpermissive]
    7 | #define s second
      |           ^
      |           |
      |           int
Main.cpp:76:69: note: in expansion of macro 's'
   76 |             update(1, 1, n, index(segments[L].f), index(segments[L].s, -1));
      |                                                                     ^
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Main.cpp:1:
/usr/include/strings.h:61:1: note: candidate: 'const char* index(const char*, int)' (near match)
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:61:1: note:   conversion of argument 1 would be ill-formed:
Main.cpp:7:11: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
    7 | #define s second
      |           ^
      |           |
      |           int
Main.cpp:76:69: note: in expansion of macro 's'
   76 |             update(1, 1, n, index(segments[L].f), index(segments[L].s, -1));
      |                                                                     ^