結果

問題 No.154 市バス
ユーザー airuaiairuai
提出日時 2017-02-05 21:20:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 59,848 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 10:10:01
合計ジャッジ時間 1,364 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:33: warning: ‘s’ is used uninitialized [-Wuninitialized]
    5 | #define rep(n) for(int i = 0; i < n; ++i)
      |                                 ^
main.cpp:8:16: note: ‘s’ was declared here
    8 |         int t, s;
      |                ^

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#define rep(n) for(int i = 0; i < n; ++i)
using namespace std;
int main(void) {
	int t, s;
	cin >> t;
	rep(s) {
		int c = 0;
		bool flag = true;
		string str;
		cin >> str;
		rep(str.size()) {
			if (str[i] == 'G') {
				++c;
			}
			else if (str[i] == 'R') {
				--c;
			}
			if (c < 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			if (c == 0) {
				cout << "possible" << endl;
			}
			else {
				cout << "impossible" << endl;
			}
		}
		else {
			cout << "impossible" << endl;
		}
	}
}
0