結果
| 問題 |
No.2716 Falcon Method
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-04-30 14:22:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,062 bytes |
| コンパイル時間 | 344 ms |
| コンパイル使用メモリ | 41,472 KB |
| 最終ジャッジ日時 | 2025-02-21 09:53:32 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 WA * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d%d%s", &n, &qn, s);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d%d%d", &h, &w, &p);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 2716.cc: No.2716 Falcon Method - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
const int INF = 1 << 30;
/* typedef */
/* global variables */
char s[MAX_N + 4];
int xss[MAX_N * 2 + 1], yss[MAX_N * 2 + 1];
/* subroutines */
/* main */
int main() {
int n, qn;
scanf("%d%d%s", &n, &qn, s);
int n2 = n * 2;
for (int i = 0; i < n2; i++) {
xss[i + 1] = xss[i] + (s[i % n] == 'D' ? 1 : 0);
yss[i + 1] = yss[i] + (s[i % n] == 'R' ? 1 : 0);
}
while (qn--) {
int h, w, p;
scanf("%d%d%d", &h, &w, &p);
int ex = (xss[n] == 0) ? INF : (h - 1) / xss[n];
int ey = (yss[n] == 0) ? INF : (w - 1) / yss[n];
int e = min(ex, ey);
h -= e * xss[n], w -= e * yss[n];
//printf(" h=%d, w=%d\n", h, w);
int k0 = p, k1 = p + n + 1;
while (k0 + 1 < k1) {
int k = (k0 + k1) / 2;
if (xss[k] - xss[p] <= h && yss[k] - yss[p] <= w) k0 = k;
else k1 = k;
}
printf("%d\n", k0 % n);
}
return 0;
}
tnakao0123