Submission #530503

#TimeUsernameProblemLanguageResultExecution timeMemory
530503Killer2501Trampoline (info1cup20_trampoline)C++14
100 / 100
369 ms41072 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pll pair<ll, ll> #define pii pair<int, int> #define fi first #define se second using namespace std; const int N = 2e5+5; const int M = 1e2+2; const int mod = 1e9+7; const ll base = 75; const int inf = 1e9; int m, n, t, b[N], d[N], lab[N], q; int k, a[N], dp[N], P[N][20]; ll ans, tong; vector<int> adj[N]; vector<int> vi; string s[N]; bool vis[N]; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n&1)total = total * k % mod; k = k * k % mod; } return total; } void add(int &x, int y) { x += y; if(x >= mod)x -= mod; } int findp(int u) { return lab[u] < 0 ? u : lab[u] = findp(lab[u]); } void hop(int u, int v) { u = findp(u); v = findp(v); if(u == v)return; if(lab[u] > lab[v])swap(u, v); lab[u] += lab[v]; lab[v] = u; } int C(int u, int v) { if(u > v)return 0; return 1ll * a[v] * b[u] % mod * b[v-u] % mod; } pii p[N]; void sol() { cin >> n >> m >> k; for(int i = 1; i <= k; i ++)cin >> p[i].fi >> p[i].se; sort(p+1, p+1+k); for(int i = 1; i <= k; i ++) { int j = lower_bound(p+1, p+1+k, make_pair(p[i].fi+1, p[i].se)) - p; if(j <= k && p[j].fi == p[i].fi+1)P[i][0] = j; //cout << i <<" "<<j<<'\n'; } for(int j = 1; j <= 18; j ++) { for(int i = 1; i <= k; i ++)P[i][j] = P[P[i][j-1]][j-1]; } cin >> q; while(q -- > 0) { pii l, r; cin >> l.fi >> l.se >> r.fi >> r.se; if(l.fi > r.fi || l.se > r.se)cout << "No" << '\n'; else if(l.fi == r.fi)cout << "Yes" << '\n'; else { int i = lower_bound(p+1, p+1+k, l) - p; if(i > k || l.fi != p[i].fi)cout << "No" << '\n'; else { for(int j = 18; j >= 0; j --) { if(P[i][j] && p[P[i][j]].fi < r.fi-1)i = P[i][j]; } if(p[i].fi < r.fi-1 && P[i][0])i = P[i][0]; if(p[i].fi == r.fi-1 && p[i].se <= r.se)cout << "Yes" << '\n'; else cout << "No" << '\n'; } } } } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define task "test" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; //cin >> test; while(test -- > 0)sol(); return 0; }

Compilation message (stderr)

trampoline.cpp: In function 'int main()':
trampoline.cpp:105:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:106:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...