結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2017-02-07 18:22:13 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 1,097 bytes |
コンパイル時間 | 630 ms |
コンパイル使用メモリ | 75,080 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:57:51 |
合計ジャッジ時間 | 1,328 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
5,248 KB |
testcase_01 | AC | 25 ms
5,248 KB |
testcase_02 | AC | 25 ms
5,248 KB |
testcase_03 | AC | 25 ms
5,248 KB |
testcase_04 | AC | 25 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 22 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
ソースコード
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <string.h> #include <vector> using namespace std; #define ll long long #define INF (1 << 30) #define INFLL (1LL << 60) #define FOR(i,a,b) for(ll i = (a);i<(b);i++) #define REP(i,a) FOR(i,0,(a)) #define MP make_pair bool check(string str){ int w = 0, g = 0, r = 0; bool flag = false; int flag2 = 0; for(int i = 0;i < str.size();i++){ if(str[i] == 'W'){ flag = true; w++; flag2 = 0; }else if(str[i] == 'G'){ flag = true; if(w < g + 1) return false; g++; if(flag2 == 0) flag2 = 1; }else{ flag = false; if(w < r + 1 || g < r + 1) return false; r++; if(flag2 == 1) flag2 = 2; } } if(flag || flag2 != 2) return false; if(g != r) return false; return true; } int main() { int n; string str; cin >> n; for(int i = 0;i < n;i++){ cin >> str; bool ans = check(str); if(ans) cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }