結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
めうめう🎒
|
| 提出日時 | 2017-02-07 18:08:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 984 bytes |
| コンパイル時間 | 535 ms |
| コンパイル使用メモリ | 74,820 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 08:57:47 |
| 合計ジャッジ時間 | 1,249 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 6 WA * 2 |
ソースコード
#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 = true;
for(int i = 0;i < str.size();i++){
if(str[i] == 'W'){
flag = true;
w++;
}else if(str[i] == 'G'){
flag = true;
// if(w < g + 1) return false;
g++;
}else{
flag = false;
if(g < r + 1) return false;
r++;
}
}
if(flag) 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;
}
めうめう🎒