結果
| 問題 | 
                            No.1328 alligachi-problem
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tnakao0123
                         | 
                    
| 提出日時 | 2020-12-25 19:12:17 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,741 bytes | 
| コンパイル時間 | 1,026 ms | 
| コンパイル使用メモリ | 101,256 KB | 
| 実行使用メモリ | 542,212 KB | 
| 最終ジャッジ日時 | 2024-09-22 12:35:40 | 
| 合計ジャッジ時間 | 21,908 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | MLE * 3 | 
| other | MLE * 25 | 
ソースコード
/* -*- coding: utf-8 -*-
 *
 * 1328.cc:  No.1328 alligachi-problem - yukicoder
 */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
/* constant */
const int MAX_N = 200000;
const char ccs[] = "RB";
enum { R = 0, B = 1 };
/* typedef */
typedef queue<int> qi;
/* global variables */
qi wcs[2][2][MAX_N];
int as[MAX_N];
/* subroutines */
inline int c2i(char c) {
  return (c == 'R') ? R : (c == 'B') ? B : -1;
}
/* main */
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char s[8], t[8];
    int y;
    scanf("%s%s%d", s, t, &y);
    int c = c2i(s[0]), x = c2i(t[0]);
    wcs[c][x][y].push(i);
  }
  for (int i = 0, rn = 0, bn = 0; i < n; i++) {
    if (wcs[R][R][rn].size() == 1 && wcs[B][R][rn].empty())
      as[i] = wcs[R][R][rn].front(), wcs[R][R][rn].pop(), rn++;
    else if (wcs[B][B][bn].size() == 1 && wcs[R][B][bn].empty())
      as[i] = wcs[B][B][bn].front(), wcs[B][B][bn].pop(), bn++;
    else if (! wcs[R][B][bn].empty() &&
	     wcs[R][R][rn].empty() && wcs[B][R][rn].empty())
      as[i] = wcs[R][B][bn].front(), wcs[R][B][bn].pop(), rn++;
    else if (! wcs[B][R][rn].empty() &&
	     wcs[R][B][bn].empty() && wcs[B][B][bn].empty())
      as[i] = wcs[B][R][rn].front(), wcs[B][R][rn].pop(), bn++;
    else {
      puts("No"); return 0;
    }
    //printf("as[%d]=%d\n", i, as[i]);
  }
  puts("Yes");
  for (int i = 0; i < n; i++)
    printf("%d%c", as[i] + 1, (i + 1 < n) ? ' ' : '\n');
  return 0;
}
            
            
            
        
            
tnakao0123