結果

問題 No.2716 Falcon Method
ユーザー AerenAeren
提出日時 2024-04-05 22:04:09
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 3,820 ms
コンパイル使用メモリ 253,736 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 22:04:16
合計ジャッジ時間 6,402 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 118 ms
6,676 KB
testcase_12 AC 89 ms
6,676 KB
testcase_13 AC 70 ms
6,676 KB
testcase_14 AC 109 ms
6,676 KB
testcase_15 AC 77 ms
6,676 KB
testcase_16 AC 90 ms
6,676 KB
testcase_17 AC 105 ms
6,676 KB
testcase_18 AC 127 ms
6,676 KB
testcase_19 AC 92 ms
6,676 KB
testcase_20 AC 74 ms
6,676 KB
testcase_21 AC 97 ms
6,676 KB
testcase_22 AC 94 ms
6,676 KB
testcase_23 AC 97 ms
6,676 KB
testcase_24 AC 94 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 92 ms
6,676 KB
testcase_28 AC 94 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #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;
}

/*

*/
0