結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2016-12-03 20:02:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 853 bytes |
コンパイル時間 | 1,676 ms |
コンパイル使用メモリ | 166,764 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:48:05 |
合計ジャッジ時間 | 2,323 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h>//#include <iostream>//#include <cstdio>#define FOR(i, a, b) for(int i = a; i < b; i++)#define REP(i, n) FOR(i, 0, n)#define MOD 1000000007#define INF 2000000000typedef long long ll;typedef unsigned long long ull;//typedef Pair<int,int> P;using namespace std;int main(void){int T;cin >> T;REP(i,T){string S;cin >> S;int numWG = 0;int numGR = 0;bool flag = false;int numG = 0;REP(j, S.length()){if(S[j]=='W'){numG=0;numWG++;}else if(S[j]=='G'){numWG--;numGR++;numG++;}else{numGR--;}//cout<<numGR<<endl;if(numWG<0||numGR<0){cout<<"impossible"<<endl;flag=true;break;}}if(flag){continue;}if(numGR!=0 || numG==0){cout<<"impossible"<<endl;continue;}cout<<"possible"<<endl;}return 0;}