結果

問題 No.2716 Falcon Method
ユーザー pengin_2000pengin_2000
提出日時 2024-04-05 22:35:45
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 981 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 30,720 KB
実行使用メモリ 8,272 KB
最終ジャッジ日時 2024-04-05 22:35:55
合計ジャッジ時間 4,309 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 RE -
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 82 ms
8,132 KB
testcase_13 AC 67 ms
8,136 KB
testcase_14 AC 97 ms
7,592 KB
testcase_15 AC 71 ms
8,000 KB
testcase_16 AC 81 ms
7,592 KB
testcase_17 AC 89 ms
7,728 KB
testcase_18 AC 111 ms
7,864 KB
testcase_19 AC 78 ms
7,588 KB
testcase_20 AC 65 ms
7,996 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 107 ms
8,272 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 107 ms
8,272 KB
testcase_28 AC 106 ms
8,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
char s[200005];
long long int x[400005], y[400005];
int main()
{
	long long int n, q;
	scanf("%lld %lld", &n, &q);
	scanf("%s", s);
	long long int i;
	x[0] = y[0] = 0;
	for (i = 0; i < n; i++)
	{
		x[i + 1] = x[i];
		y[i + 1] = y[i];
		if (s[i] == 'D')
			x[i + 1]++;
		else
			y[i + 1]++;
	}
	for (i = 0; i < n; i++)
	{
		x[i + 1 + n] = x[i + n];
		y[i + 1 + n] = y[i + n];
		if (s[i] == 'D')
			x[i + 1 + n]++;
		else
			y[i + 1 + n]++;
	}
	long long int min, mid, max;
	long long int h, w, p;
	long long int f;
	for (i = 0; i < q; i++)
	{
		scanf("%lld %lld %lld", &h, &w, &p);
		f = (h - 1) / x[n];
		if (f > (w - 1) / y[n])
			f = (w - 1) / y[n];
		h -= x[n] * f;
		w -= y[n] * f;
		if (h > x[n] && w > y[n])
		{
			h -= x[n];
			w -= y[n];
		}
		min = p;
		max = 2 * n;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (x[mid] - x[p] < h && y[mid] - y[p] < w)
				min = mid;
			else
				max = mid;
		}
		printf("%lld\n", max % n);
	}
	return 0;
}
0