結果
| 問題 |
No.2716 Falcon Method
|
| コンテスト | |
| ユーザー |
kokosei
|
| 提出日時 | 2024-04-05 22:02:09 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 109 ms / 2,000 ms |
| コード長 | 751 bytes |
| コンパイル時間 | 759 ms |
| コンパイル使用メモリ | 85,048 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-10-01 02:18:00 |
| 合計ジャッジ時間 | 3,567 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int N, Q;
string S;
int X[202020], Y[202020];
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> Q >> S;
for(int i = 0;i < N;i++){
X[i + 1] = X[i] + (S[i] == 'D');
Y[i + 1] = Y[i] + (S[i] == 'R');
}
while(Q--){
int h, w, p; cin >> h >> w >> p;
h += X[p], w += Y[p];
ll l = -1, r = 4e9;
while(r - l > 1){
ll m = (l + r) / 2;
bool f = false;
f |= m / N * X[N] + X[m % N] >= h;
f |= m / N * Y[N] + Y[m % N] >= w;
if(f)r = m;
else l = m;
}
cout << r % N << "\n";
}
return 0;
}
kokosei