結果

問題 No.154 市バス
ユーザー harsaka_puyoharsaka_puyo
提出日時 2018-12-25 02:31:16
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 993 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 164,272 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-01 09:21:33
合計ジャッジ時間 2,515 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n;
  cin >> n;
  string s[n];
  REP(i, n) cin >> s[i];
  vector<ll> p, q;
  ll flg;
  REP(i, n){
    flg = 0;
    p.clear();
    q.clear();
    REP(j, s[i].size()){
      if(s[i][j] == 'G') p.pb(j);
      if(s[i][j] == 'R') q.pb(j);
    }
    if(p.size() != q.size() || p.size() == 0){
      cout << "impossible" << endl;
      continue;
    }
    REP(j, p.size()){
      if(p[j] > q[j]){
        cout << "impossible" << endl;
        flg = 1;
        break;
      }
    }
    if(flg) continue;
    cout << "possible" << endl;
  }
  return 0;
}
0