結果

問題 No.2716 Falcon Method
ユーザー pengin_2000pengin_2000
提出日時 2024-04-05 22:34:52
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 909 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 30,848 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-05 22:34:56
合計ジャッジ時間 3,940 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 RE -
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 1 ms
6,548 KB
testcase_04 AC 1 ms
6,548 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 1 ms
6,548 KB
testcase_08 AC 1 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 61 ms
6,548 KB
testcase_13 AC 45 ms
6,548 KB
testcase_14 AC 69 ms
6,548 KB
testcase_15 AC 51 ms
6,548 KB
testcase_16 AC 60 ms
6,548 KB
testcase_17 AC 67 ms
6,548 KB
testcase_18 AC 80 ms
6,548 KB
testcase_19 AC 56 ms
6,548 KB
testcase_20 AC 47 ms
6,548 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 82 ms
6,548 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 87 ms
6,548 KB
testcase_28 AC 82 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
char s[200005];
int x[400005], y[400005];
int main()
{
	int n, q;
	scanf("%d %d", &n, &q);
	scanf("%s", s);
	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]++;
	}
	int min, mid, max;
	int h, w, p;
	int f;
	for (i = 0; i < q; i++)
	{
		scanf("%d %d %d", &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("%d\n", max % n);
	}
	return 0;
}
0