結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2016-06-19 23:24:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 1,025 bytes |
| コンパイル時間 | 645 ms |
| コンパイル使用メモリ | 79,388 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 08:32:51 |
| 合計ジャッジ時間 | 1,272 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
62 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:65:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
65 | scanf("%s",s);
| ~~~~~^~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>
typedef long long ll;
using namespace std;
#define debug(x) cerr << #x << " = " << x << endl;
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000
bool calc(char *s){
int R=0,G=0,W=0;
int l = strlen(s);
reverse(s,s+l);
for(int i=0;i<l;i++){
if(s[i]=='R') R++;
if(s[i]=='G'){
if(R==0) return false;
R--;
G++;
}
if(s[i]=='W'){
if(G>0){
G--;
W++;
}else if(W==0){
return false;
}
}
}
if(R==0 && G==0) return true;
return false;
}
int main(){
int n;
char s[SIZE];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%s",s);
puts(calc(s) ? "possible" : "impossible");
}
return 0;
}
goodbaton