Submission #993442

#TimeUsernameProblemLanguageResultExecution timeMemory
993442kachim2Trampoline (info1cup20_trampoline)C++17
0 / 100
191 ms62976 KiB
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <valarray> #include <variant> using namespace std; struct trampoline { long x, y; vector<trampoline *> jp; bool isjp = 0; friend bool operator<(const trampoline &l, const trampoline &r) { return l.x < r.x; } void genjp(); }; unordered_map<long, vector<trampoline>> trampolines; void trampoline::genjp() { if (isjp) return; isjp = 1; trampoline *next; if (!trampolines.count(y + 1)) return; auto &a = trampolines[y + 1]; auto b = lower_bound(a.begin(), a.end(), *this); if (b == a.end()) { return; } next = &*b; jp.push_back(next); while (true) { (*jp.rbegin())->genjp(); if (this->jp.size() > (*jp.rbegin())->jp.size()) { return; } jp.push_back((*jp.rbegin())->jp[this->jp.size() - 1]); } } int main() { int R, C, N; cin >> R >> C >> N; vector<trampoline *> tramps; for (int i = 0; i < N; i++) { int x, y; cin >> y >> x; trampolines[y].push_back({.x = x, .y = y}); tramps.push_back(&*trampolines[y].rbegin()); } for (auto &[key, i] : trampolines) { sort(i.begin(), i.end()); } for (auto i : tramps) { i->genjp(); } int T; cin >> T; for (int i = 0; i < T; i++){ if(i!=0)cout << '\n'; int x1, x2, y1, y2; cin >> y1 >> x1 >> y2 >> x2; if(y1 == y2 and x1 <= x2){ cout << "Yes"; continue; } trampoline tmptramp; tmptramp.x = x1; auto tc = lower_bound(trampolines[y1].begin(), trampolines[y1].end(), tmptramp); if(tc == trampolines[y1].end()){ cout << "No"; continue; } trampoline *curr = &*tc; int v = y2-y1-1; for(int j = 0; v!=0; j++){ if(v&1){ if(curr->jp.size() <= j) goto no; curr = curr->jp[j]; } v>>=1; } if(curr->x > x2){ goto no; } goto yes; no: cout << "No"; continue; yes: cout << "Yes"; } }

Compilation message (stderr)

trampoline.cpp: In function 'int main()':
trampoline.cpp:82:26: warning: comparison of integer expressions of different signedness: 'std::vector<trampoline*>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   82 |       if(curr->jp.size() <= j) goto no;
      |          ~~~~~~~~~~~~~~~~^~~~
#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...