結果
| 問題 | 
                            No.1328 alligachi-problem
                             | 
                    
| コンテスト | |
| ユーザー | 
                             umezo
                         | 
                    
| 提出日時 | 2020-12-25 00:53:59 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,462 bytes | 
| コンパイル時間 | 2,294 ms | 
| コンパイル使用メモリ | 209,340 KB | 
| 最終ジャッジ日時 | 2025-01-17 06:51:35 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 2 | 
| other | AC * 9 WA * 16 | 
ソースコード
#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;
int main(){
  int n;
  cin>>n;
  
  vector<char> C(n+1),X(n+1);
  vector<int> Y(n+1);
  rep(i,n) cin>>C[i+1]>>X[i+1]>>Y[i+1];
  
  vector<pair<int,int>> RR,BB,RB,BR;
  for(int i=1;i<=n;i++){
    if(C[i]=='R' && X[i]=='R') RR.push_back({Y[i],i});
    if(C[i]=='R' && X[i]=='B') RB.push_back({Y[i],i});
    if(C[i]=='B' && X[i]=='R') BR.push_back({Y[i],i});
    if(C[i]=='B' && X[i]=='B') BB.push_back({Y[i],i});
  }
  sort(ALL(RR));
  sort(ALL(RB));
  sort(ALL(BR));
  sort(ALL(BB));
  
  queue<pair<int,int>> qrr,qrb,qbr,qbb;
  for(auto x:RR) qrr.push(x);
  for(auto x:RB) qrb.push(x);
  for(auto x:BR) qbr.push(x);
  for(auto x:BB) qbb.push(x);
  
  bool flag=true;
  int tmp=-1;
  for(auto x:RR){
    if(x.first==tmp) flag=false;
    tmp=x.first;
  }
  tmp=-1;
  for(auto x:BB){
    if(x.first==tmp) flag=false;
    tmp=x.first;
  }
  if(flag==false){
    cout<<"No"<<endl;
    return 0;
  }
  int r=0,b=0;
  vector<int> B;
  while(!qrr.empty() || !qbb.empty() || !qrb.empty() || !qbr.empty()){
    if(!qrr.empty() && qrr.front().first==r){
      if(qbr.empty() || qbr.front().first>=r+1){
        auto x=qrr.front();
        qrr.pop();
        B.push_back(x.second);
        r++;
        continue;
      }
    }
    
    if(!qbb.empty() || qbb.front().first==b){
      if(qrb.empty() || qrb.front().first>=b+1){
        auto x=qbb.front();
        qbb.pop();
        B.push_back(x.second);
        b++;
        continue;
      }
    }
    
    if(!qrb.empty() || qrb.front().first==b){
      if((qrr.empty() && qbr.empty()) || (qrr.empty() && qbr.front().first>=r+1) ||
        (qbr.empty() && qrr.front().first>=r+1) || (qbr.front().first>=r+1 && qrr.front().first>=r+1)){
        auto x=qrb.front();
        qrb.pop();
        B.push_back(x.second);
        r++;
        continue;
      }
    }
    
    if(!qbr.empty() || qbr.front().first==r){
      if((qbb.empty() && qrb.empty()) || (qbb.empty() && qrb.front().first>=b+1) ||
        (qrb.empty() && qbb.front().first>=b+1) || (qrb.front().first>=b+1 && qbb.front().first>=b+1)){
        auto x=qbr.front();
        qbr.pop();
        B.push_back(x.second);
        b++;
        continue;
      }
    }
    
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  rep(i,n){
    if(i) cout<<" ";
    cout<<B[i];
  }
  cout<<endl;
    
  return 0;
}
            
            
            
        
            
umezo