제출 #1322736

#제출 시각아이디문제언어결과실행 시간메모리
1322736lucas110550장애물 (IOI25_obstacles)C++20
24 / 100
110 ms22252 KiB
#include <vector> #include <algorithm> #include <cmath> #include <climits> using namespace std; const int MAXM = 200005; const int LOGM = 19; int st[MAXM][LOGM]; int logs[MAXM]; int global_max_reachable_T = -1; void initialize(std::vector<int> T, std::vector<int> H) { int N = T.size(); int M = H.size(); logs[1] = 0; for (int i = 2; i <= M; i++) { logs[i] = logs[i / 2] + 1; } for (int i = 0; i < M; i++) { st[i][0] = H[i]; } for (int j = 1; j < LOGM; j++) { for (int i = 0; i + (1 << j) <= M; i++) { st[i][j] = max(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]); } } int min_H = INT_MAX; for (int x : H) { if (x < min_H) min_H = x; } global_max_reachable_T = -1; for (int i = 0; i < N; i++) { if (T[i] <= min_H) { break; } if (T[i] > global_max_reachable_T) { global_max_reachable_T = T[i]; } } } // --------------------------------------------------------- // can_reach 函数 // --------------------------------------------------------- bool can_reach(int L, int R, int S, int D) { int left = S, right = D; if (left > right) swap(left, right); int len = right - left + 1; int k = logs[len]; int max_obstacle_H = max(st[left][k], st[right - (1 << k) + 1][k]); if (global_max_reachable_T > max_obstacle_H) { return true; } else { return false; } }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...