結果
| 問題 |
No.154 市バス
|
| ユーザー |
bal4u
|
| 提出日時 | 2019-05-10 06:20:33 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,152 bytes |
| コンパイル時間 | 137 ms |
| コンパイル使用メモリ | 30,464 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-02 00:54:56 |
| 合計ジャッジ時間 | 1,000 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 6 WA * 2 |
コンパイルメッセージ
main.c: In function 'in':
main.c:7:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
7 | #define gc() getchar_unlocked()
| ^~~~~~~~~~~~~~~~
main.c:15:24: note: in expansion of macro 'gc'
15 | int n = 0, c = gc();
| ^~
main.c: In function 'outs':
main.c:8:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
8 | #define pc(c) putchar_unlocked(c)
| ^~~~~~~~~~~~~~~~
main.c:30:33: note: in expansion of macro 'pc'
30 | void outs(char *s) { while (*s) pc(*s++); }
| ^~
ソースコード
// yukicoder: No.154 市バス
// 2019.5.10 bal4u
#include <stdio.h>
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in() // 非負整数の入力
{
int n = 0, c = gc();
// while (isspace(c)) c = gc();
do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
return n;
}
int ins(char *s) // 文字列の入力 スペース以下の文字で入力終了
{
char *p = s;
do *s = gc();
while (*s++ > ' ');
*--s = 0;
return s - p;
}
void outs(char *s) { while (*s) pc(*s++); }
char S[1005];
int q[3][1005], sz[3];
int id[128];
int main()
{
int i, j, k, si, T, len;
id['W'] = 0, id['G'] = 1, id['R'] = 2;
T = in(); while (T--) {
sz[0] = sz[1] = sz[2] = 0;
len = ins(S);
if (*(S+len-1) != 'R') goto NG;
for (i = 0; i < len; i++)
j = id[S[i]], q[j][sz[j]++] = i;
if (sz[0] < sz[1] || sz[1] != sz[2]) goto NG;
i = k = si = 0; for (j = 0; j < sz[1]; j++) {
while (q[0][i] < q[1][j]) i++, si++;
while (q[2][k] < q[1][j]) k++;
if (k > j) goto NG;
}
outs("possible\n");
continue;
NG: outs("impossible\n");
}
return 0;
}
bal4u