Submission #993483

# Submission time Handle Problem Language Result Execution time Memory
993483 2024-06-05T18:33:25 Z kachim2 Trampoline (info1cup20_trampoline) C++17
11 / 100
986 ms 56380 KB
#include <algorithm>
#include<vector>
#include<iostream>
#include<unordered_map>
//#include <bits/stdc++.h>
#include <cstdio>
#include <valarray>
#include <variant>
#include <assert.h>
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].emplace_back();
    (*trampolines[y].rbegin()).x = x;
    (*trampolines[y].rbegin()).y = y;
    assert((*trampolines[y].rbegin()).jp.capacity() >= 0);
    tramps.push_back(&*trampolines[y].rbegin());
  }
  for (auto &[key, i] : trampolines) {
    sort(i.begin(), i.end());
  }
  for (auto [key, j] : trampolines){
  for (auto i : j) {
    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

trampoline.cpp: In function 'int main()':
trampoline.cpp:92:26: warning: comparison of integer expressions of different signedness: 'std::vector<trampoline*>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   92 |       if(curr->jp.size() <= j) goto no;
      |          ~~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1372 KB expected YES, found NO [42nd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 152 ms 25956 KB expected YES, found NO [38th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 662 ms 30516 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 633 ms 35752 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 629 ms 31168 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 667 ms 43956 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 768 ms 43964 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 808 ms 47904 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 1140 KB expected YES, found NO [4th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 986 ms 56380 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -