結果

問題 No.3056 Disconnected Coloring
ユーザー umezo
提出日時 2025-03-15 03:09:23
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 3,809 ms
コンパイル使用メモリ 277,152 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-15 03:09:33
合計ジャッジ時間 9,887 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;

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

  int n,m;
  cin>>n>>m;
  V<int> U(m),v(m);
  rep(i,m){
    cin>>U[i]>>v[i];
    U[i]--,v[i]--;
    if(U[i]==0 && v[i]==n-1){
      cout<<-1<<endl;
      return 0;
    }
  }
  if(m%2){
    cout<<-1<<endl;
    return 0;
  }
  V<char> ANS(m,'$');
  int r=m/2,b=m/2;
  rep(i,m){
    if(U[i]==0){
      ANS[i]='R';
      r--;
    }
    else if(v[i]==n-1){
      ANS[i]='B';
      b--;
    }
  }
  rep(i,m){
    if(ANS[i]=='$' && r){
      r--;
      ANS[i]='R';
    }
    else if(ANS[i]=='$' && b){
      b--;
      ANS[i]='B';
    }
  }
  rep(i,m) cout<<ANS[i];
  cout<<endl;
  
  return 0;
}
0