結果
問題 | No.154 市バス |
ユーザー | yuppe19 😺 |
提出日時 | 2015-04-26 08:43:24 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 685 bytes |
コンパイル時間 | 1,535 ms |
コンパイル使用メモリ | 157,400 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-21 08:30:05 |
合計ジャッジ時間 | 1,896 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
6,816 KB |
testcase_01 | AC | 10 ms
6,944 KB |
testcase_02 | AC | 10 ms
6,940 KB |
testcase_03 | AC | 9 ms
6,940 KB |
testcase_04 | AC | 9 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 7 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | int t; scanf("%d", &t); | ~~~~~^~~~~~~~~~ main.cpp:27:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | char s[1024]; scanf("%s", s); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> int check(char *s) { int sz = strlen(s); int w = 0, g = 0, r = 0; bool experience = false; for(int i=0; i<sz; i++) { switch(s[i]) { case 'W': experience = false, w++; break; case 'G': if(w < ++g) { return 0; } experience = true; break; case 'R': if(g < ++r) { return 0; } break; } } return experience && g == r; } int main(void) { int t; scanf("%d", &t); for(int i=0; i<t; i++) { char s[1024]; scanf("%s", s); printf("%s\n", check(s) ? "possible" : "impossible"); } return 0; }