結果

問題 No.154 市バス
ユーザー naimonon77naimonon77
提出日時 2016-01-09 13:07:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 61,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 09:01:55
合計ジャッジ時間 1,434 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
5,248 KB
testcase_01 AC 25 ms
5,376 KB
testcase_02 AC 25 ms
5,376 KB
testcase_03 AC 24 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 22 ms
5,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int test = 0;
/* ここからが本編 */
int main(void)
{
  int i,j,k,l;
  int T;
  char S[1005] = "";

  cin >> T;
  while(cin >> S) {
    int n = strlen(S);
    int cnt = 0;
    bool possible = true;
    rep(i,n) {
      if(S[i] == 'G') cnt++;
      else if(S[i] == 'R') cnt--;
      if(cnt < 0) {
        possible = false;
        break;
      }
    }
    /* for(i=n-1;i>-1;i--) {

    }*/
    if(cnt != 0) possible = false;
    if(possible) puts("possible");
    else puts("impossible");
  }
  return 0;
}
0