結果
| 問題 |
No.878 Range High-Element Query
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-28 01:31:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 919 bytes |
| コンパイル時間 | 867 ms |
| コンパイル使用メモリ | 91,004 KB |
| 最終ジャッジ日時 | 2024-11-15 03:38:54 |
| 合計ジャッジ時間 | 2,063 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:8:10: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
8 | ios::sync_with_stdio(false);
| ^~~~~~~~~~~~~~~
main.cpp:9:5: error: 'cin' was not declared in this scope
9 | cin.tie(0);
| ^~~
main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
1 | #include <atcoder/all>
+++ |+#include <iostream>
2 | using namespace std;
main.cpp:36:9: error: 'cout' was not declared in this scope
36 | cout << ++ans << '\n';
| ^~~~
main.cpp:36:9: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ソースコード
#include <atcoder/all>
using namespace std;
int op(int l, int r){return min(l, r);}
int e(){return 1 << 30;}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int N, Q, M = 100005, l, r, g;
cin >> N >> Q;
vector<int> a(N);
g = __lg(N);
vector<vector<int>> dp(g + 1, vector<int>(N + 1, N));
for(auto &&v : a) cin >> v;
atcoder::segtree<int, op, e> seg(vector<int>(M, N));
for(int i = N - 1; i >= 0; i--){
dp[0][i] = seg.prod(a[i] + 1, M);
seg.set(a[i], i);
}
for(int i = 0; i < g; i++){
for(int j = 0; j < N; j++){
dp[i + 1][j] = dp[i][dp[i][j]];
}
}
while(Q--){
cin >> l >> l >> r;
l--;
int ans = 0;
for(int i = g; i >= 0; i--){
if(dp[i][l] < r){
l = dp[i][l];
ans |= 1 << i;
}
}
cout << ++ans << '\n';
}
}