結果

問題 No.1328 alligachi-problem
ユーザー tko919tko919
提出日時 2020-12-25 14:40:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 588 ms / 2,000 ms
コード長 1,544 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 186,944 KB
実行使用メモリ 58,808 KB
最終ジャッジ日時 2023-10-22 06:26:24
合計ジャッジ時間 16,104 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 5 ms
4,348 KB
testcase_05 AC 5 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 6 ms
4,408 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 559 ms
57,788 KB
testcase_10 AC 240 ms
32,828 KB
testcase_11 AC 550 ms
57,796 KB
testcase_12 AC 567 ms
57,796 KB
testcase_13 AC 553 ms
57,816 KB
testcase_14 AC 552 ms
57,804 KB
testcase_15 AC 235 ms
32,820 KB
testcase_16 AC 560 ms
57,804 KB
testcase_17 AC 558 ms
57,784 KB
testcase_18 AC 564 ms
57,800 KB
testcase_19 AC 556 ms
57,796 KB
testcase_20 AC 549 ms
57,808 KB
testcase_21 AC 588 ms
57,796 KB
testcase_22 AC 581 ms
57,804 KB
testcase_23 AC 241 ms
32,824 KB
testcase_24 AC 492 ms
58,808 KB
testcase_25 AC 505 ms
58,808 KB
testcase_26 AC 427 ms
54,796 KB
testcase_27 AC 439 ms
54,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

typedef pair<char,pair<char,int>> T;
string col="RB";
void fail(){puts("No"); exit(0);}

int main(){
   int n; cin>>n;
   vector<char> c(n),x(n); vector<int> y(n);
   rep(i,0,n)cin>>c[i]>>x[i]>>y[i];
   map<T,set<int>> cnt;
   rep(i,0,n)cnt[{c[i],{x[i],y[i]}}].insert(i);

   int cur[2]={};
   vector<int> res;
   rep(_,0,n){
      int tar=0,pre[4]={},sum=0;
      rep(i,0,2)rep(j,0,2){
         pre[i+j*2]=cnt[{col[i],{col[j],cur[j]}}].size();
         if(pre[i+j*2])sum++;
      }
      if(sum==0)fail();
      if(sum==1){
         for(tar=0;tar<4;tar++)if(pre[tar]){
            break;
         }
      }
      else{
         if(pre[1] and pre[2])fail();
         if(pre[0] and pre[1])tar=1;
         if(pre[2] and pre[3])tar=2;
         if(pre[0] and pre[2])tar=0;
         if(pre[1] and pre[3])tar=3;
      }
      int idx=*cnt[{col[tar&1],{col[tar>>1],cur[tar>>1]}}].begin();
      cnt[{col[tar&1],{col[tar>>1],cur[tar>>1]}}].erase(idx);

      res.push_back(idx);
      cur[(c[idx]=='R'?0:1)]++;
   }

   puts("Yes");
   rep(i,0,n)cout<<res[i]+1<<(i==n-1?'\n':' ');
   return 0;
}
0