Submission #1008848

# Submission time Handle Problem Language Result Execution time Memory
1008848 2024-06-27T02:19:02 Z PenguinsAreCute Trampoline (info1cup20_trampoline) C++17
62 / 100
2000 ms 73872 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 420690;
const int INF = 1210201069;
// id rather discretise than code a recursive seg
vector<pair<int,int>> seg[MAXN<<1];
int f(int i, int x) {
  return (*lower_bound(seg[i].begin(),seg[i].end(),make_pair(x,0LL))).second;
}
void build() {
  for(int i=MAXN;i--;)
    for(auto [j, k]: seg[i<<1])
      seg[i].push_back({j,f(i<<1|1,k)});
}
int qry(int l, int r, int x) {
  stack<int> st;
  for(l+=MAXN,r+=MAXN;l<r;l>>=1,r>>=1) {
    if(l&1) x=f(l++,x);
    if(r&1) st.push(--r);
  }
  while(st.size()) {
    x=f(st.top(),x);
    st.pop();
  }
  return x;
}
main() {
  int r, c, n; cin >> r >> c >> n;
  vector<int> v; int x[n], y[n];
  for(int i=0;i<n;i++) {
    cin >> x[i] >> y[i];
    v.push_back(x[i]);
    v.push_back(x[i]+1);
  }

  sort(v.begin(),v.end());
  v.resize(unique(v.begin(),v.end())-v.begin());
  for(int i=0;i<n;i++)
    x[i]=lower_bound(v.begin(),v.end(),x[i])-v.begin();
  for(int i=0;i<n;i++)
    seg[x[i]+MAXN].push_back({y[i],y[i]});
  for(int i=0;i<n;i++)
    sort(seg[x[i]+MAXN].begin(),seg[x[i]+MAXN].end());
  for(int i=0;i<MAXN;i++)
    seg[i+MAXN].push_back({INF,INF});
  build();

  int t; cin >> t;
  while(t--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1==x2) {
      cout << (y1<=y2?"Yes\n":"No\n");
      continue;
    }
    if(x1>x2) {
      cout << "No\n";
      continue;
    }
    auto it1 = lower_bound(v.begin(),v.end(),x1);
    auto it2 = lower_bound(v.begin(),v.end(),x2);
    if(it1==v.end()||it2==v.end()||(*it1)!=x1||(*it2)!=x2) {
      cout << "No\n";
      continue;
    }
    cout << (qry(it1-v.begin(),it2-v.begin(),y1)<=y2?"Yes\n":"No\n");
  }
} // noice line number

Compilation message

trampoline.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 56 ms 47256 KB 200 token(s): yes count is 21, no count is 179
2 Correct 57 ms 47312 KB 200 token(s): yes count is 70, no count is 130
3 Correct 54 ms 46940 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 278 ms 64448 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 268 ms 64440 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 694 ms 62312 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 262 ms 64444 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Execution timed out 2072 ms 35768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 74 ms 47184 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 66 ms 47184 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 63 ms 47052 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 114 ms 47188 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 83 ms 47048 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 169 ms 47076 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 827 ms 73400 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 815 ms 73872 KB 200000 token(s): yes count is 161254, no count is 38746
3 Execution timed out 2039 ms 34744 KB Time limit exceeded
4 Halted 0 ms 0 KB -