Submission #768942

#TimeUsernameProblemLanguageResultExecution timeMemory
768942aykhnTrampoline (info1cup20_trampoline)C++14
43 / 100
477 ms61620 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // author: aykhn using namespace std; using namespace __gnu_pbds; typedef long long ll; #define TC int t; cin >> t; while (t--) _(); #define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define ordered_setp tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> #define all(v) v.begin(), v.end() #define pii pair<int, int> #define mpr make_pair #define eb emplace_back #define new int32_t #define pb push_back #define ts to_string #define int ll #define fi first #define se second #define ins insert #define inf 0x3F3F3F3F #define infll 0x3F3F3F3F3F3F3F3FLL #define bpc __builtin_popcount int n, R, C; vector<int> adj[200001]; pii a[200001]; int used[200001]; int par[20][200001]; void dfs(int a) { used[a] = 1; for (int i = 0; i < adj[a].size(); i++) { if (!used[adj[a][i]]) { par[0][adj[a][i]] = a; dfs(adj[a][i]); } } } new main() { OPT; cin >> R >> C >> n; for (int i = 0; i < n; i++) { cin >> a[i].fi >> a[i].se; } int cnt = 0; sort(a, a + n); for (int i = 0; i < n; i++) { int x = lower_bound(a, a + n, mpr(a[i].fi + 1, a[i].se)) - a; if (x == n || a[x].fi != a[i].fi + 1) continue; adj[x].pb(i); } for (int i = n - 1; i >= 0; i--) { if (!used[i]) dfs(i); } for (int i = 1; i < 20; i++) { for (int j = 1; j <= n; j++) { par[i][j] = par[i - 1][par[i - 1][j]]; } } int t; cin >> t; while (t--) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 == x2 && y1 <= y2) { cout << "Yes" << endl; continue; } if (x1 > x2 || y1 > y2) { cout << "No" << endl; continue; } int node = lower_bound(a, a + n, mpr(x1, y1)) - a; if (node == n || a[node].fi != x1) { cout << "No" << endl; continue; } int dif = x2 - x1 - 1; for (int i = 19; i >= 0; i--) { if ((1 << i) <= dif) { node = par[i][node]; dif -= (1 << i); } } if (!node || a[node].fi + 1 != x2 || a[node].se > y2) cout << "No" << endl; else cout << "Yes" << endl; } }

Compilation message (stderr)

trampoline.cpp: In function 'void dfs(ll)':
trampoline.cpp:40:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < adj[a].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
trampoline.cpp: In function 'int32_t main()':
trampoline.cpp:61:9: warning: unused variable 'cnt' [-Wunused-variable]
   61 |     int cnt = 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...