結果
問題 | No.154 市バス |
ユーザー | bal4u |
提出日時 | 2019-05-10 06:20:33 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,152 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 29,076 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-14 17:49:52 |
合計ジャッジ時間 | 967 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
4,380 KB |
testcase_01 | AC | 8 ms
4,376 KB |
testcase_02 | AC | 8 ms
4,380 KB |
testcase_03 | AC | 6 ms
4,380 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 0 ms
4,376 KB |
testcase_07 | AC | 7 ms
4,380 KB |
testcase_08 | WA | - |
コンパイルメッセージ
main.c: 関数 ‘in’ 内: main.c:7:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration] 7 | #define gc() getchar_unlocked() | ^~~~~~~~~~~~~~~~ main.c:15:24: 備考: in expansion of macro ‘gc’ 15 | int n = 0, c = gc(); | ^~ main.c: 関数 ‘outs’ 内: main.c:8:15: 警告: 関数 ‘putchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration] 8 | #define pc(c) putchar_unlocked(c) | ^~~~~~~~~~~~~~~~ main.c:30:33: 備考: 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; }