結果
| 問題 |
No.2716 Falcon Method
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-05 22:04:09 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 113 ms / 2,000 ms |
| コード長 | 1,057 bytes |
| コンパイル時間 | 3,087 ms |
| コンパイル使用メモリ | 252,256 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 02:20:32 |
| 合計ジャッジ時間 | 6,161 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(ios::badbit | ios::failbit);
int n, qn;
string s;
cin >> n >> qn >> s;
vector<array<int, 2>> delta(n + 1);
for(auto i = 0; i < n; ++ i){
delta[i + 1] = delta[i];
++ delta[i + 1][s[i] == 'R'];
}
for(auto qi = 0; qi < qn; ++ qi){
int h, w, init;
cin >> h >> w >> init;
int move = *ranges::partition_point(ranges::iota_view(0, h + w), [&](int move){
auto [q, r] = div(move, n);
long long x = 1LL * delta[n][0] * q, y = 1LL * delta[n][1] * q;
if(init + r <= n){
x += delta[init + r][0] - delta[init][0];
y += delta[init + r][1] - delta[init][1];
}
else{
x += delta[n][0] - delta[init][0] + delta[init + r - n][0];
y += delta[n][1] - delta[init][1] + delta[init + r - n][1];
}
return x < h && y < w;
}) % n;
cout << (init + move) % n << "\n";
}
return 0;
}
/*
*/