結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2016-07-10 01:22:14 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 748 bytes |
コンパイル時間 | 490 ms |
コンパイル使用メモリ | 21,760 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 08:37:59 |
合計ジャッジ時間 | 1,093 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 7 WA * 1 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:60:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 60 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:63:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 63 | scanf("%s", s); | ^~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> #include <stdlib.h> #define N_MAX 1000 char s[N_MAX + 1]; char t[N_MAX + 1]; int answer; int i, j, n; int abs(int x){ return (x > 0) ? x : -x; } int min(int x, int y){ return (x > y) ? y : x; } int comp (int *x, int *y) { return *y - *x; } int solve(){ char *p; int w, g, r; w = g = r = 0; for (p = s; *p; p++) { switch (*p) { case 'W': w++; break; case 'G': g++; if (g > w) return 0; break; case 'R': r++; if (r > g) return 0; break; } } if (g == r && g) { return 2; } else { return 0; } } int main(void){ const char imp[] = "impossible"; scanf("%d", &n); for (j = 0; j < n; j++) { scanf("%s", s); puts(imp+solve()); } return 0; }