結果

問題 No.154 市バス
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-02-17 23:41:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,505 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 87,672 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 07:37:41
合計ジャッジ時間 1,521 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))

#define MOD 1000000007

int main(){
    int n;
    cin>>n;
    rep(i,0,n){
        string s;
        cin>>s;
        string s1;
        rep(j,0,s.sz){
            if(s[j]!='W'){
                s1+=s[j];
            }
        }
        int c = 0;
        int index1 = 0;
        int index2 = 0;
        for(;;){
          if(index1==s1.sz||index2==s1.sz){
            cout << "impossible" << endl;
            break;
          }
          if(index1>index2){
            cout << "impossible" << endl;
            break;
          }
          if(s1[index1]=='G'&&s1[index2]=='R'){
            c++;
            if(c*2==s1.sz){
                cout << "possible" << endl;
                break;
            }
            index1++;
            index2++;
          }
          else if(s1[index2]!='R'){
            index2++;
          }
          else{
            index1++;
          }
        }
    }
	return 0;
}
0