답안 #921366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921366 2024-02-03T18:08:20 Z Ianis Trampoline (info1cup20_trampoline) C++17
81 / 100
756 ms 57620 KB
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#define endl '\n'

#define fi first
#define se second

#define lsb(x) (x & (-x))

using namespace std;

const int NMAX = 2e5+5;
const int LOGN = 22;

struct Point {
   int x, y;
};

int n;
Point a[NMAX];
map<int, map<int, int>> mp;
int dp[LOGN][NMAX];

void read() {
   int r, c;
   cin >> r >> c >> n;
   for (int i = 1; i <= n; i++) {
      cin >> a[i].x >> a[i].y;
      mp[a[i].x][a[i].y] = i;
   }
}

void precalc() {
   for (int i = 1; i <= n; i++) {
      auto it = mp[a[i].x + 1].lower_bound(a[i].y);
      if (it != mp[a[i].x + 1].end())
         dp[0][i] = it->se;
   }

   for (int j = 1; 1 << j <= n; j++) {
      for (int i = 1; i <= n; i++)
         dp[j][i] = dp[j - 1][dp[j - 1][i]];
   }
}

int jump(int u, int k) {
   if (k == 0) return u;
   return jump(dp[int(log2(lsb(k)))][u], k ^ lsb(k));
}

Point jump(int x, int y, int k) {
   auto it = mp[x].lower_bound(y);
   if (it == mp[x].end()) return { };
   return a[jump(it->se, k)];
}

bool query(int x1, int y1, int x2, int y2) {
   if (x2 < x1 || y2 < y1) return false;
   if (x1 == x2) return true;
   Point p = jump(x1, y1, x2 - x1 - 1);
   if (!p.x) return false;
   return p.y <= y2;
}

signed main() {
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   read();
   precalc();

   int t = 1;
   cin >> t;

   while (t--) {
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      cout << (query(x1, y1, x2, y2) ? "Yes" : "No") << endl;
   }

   return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 13148 KB 200 token(s): yes count is 21, no count is 179
2 Correct 7 ms 13148 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 13156 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 229 ms 26812 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 182 ms 26776 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 200 ms 26452 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 149 ms 26704 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 290 ms 27136 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 267 ms 27196 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 317 ms 27104 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 286 ms 27456 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 327 ms 27444 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 442 ms 33320 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12892 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 12892 KB 5000 token(s): yes count is 3837, no count is 1163
3 Runtime error 18 ms 27740 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 600 ms 35008 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 488 ms 29224 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 311 ms 34944 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 756 ms 57620 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 436 ms 45576 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 338 ms 38992 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 332 ms 38984 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 268 ms 38996 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 561 ms 45132 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 533 ms 45140 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 662 ms 51544 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 240 ms 38864 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 252 ms 38928 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 389 ms 39340 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 269 ms 38992 KB 200000 token(s): yes count is 129674, no count is 70326