結果

問題 No.2268 NGワード回避
ユーザー zezero
提出日時 2023-04-14 22:21:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 3,661 ms
コンパイル使用メモリ 166,504 KB
最終ジャッジ日時 2025-02-12 07:04:57
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  string ans;
  if (n == 1 && a[0][0] == 'a') ans = 'b';
  else if (n == 1 && a[0][0] == 'b') ans = 'a';

  for (int i = 0; i < n-1;i++){
    string ns = a[i];
    ns[n-1]++;
    for (int j = n-1; j >= 1;j--){
      if (ns[j] == 'c'){
        ns[j+1]++;
        ns[j]='a';
      }
    }
    if (ns[0] == 'c') continue;
    ans = ns;
  }
  cout << ans << endl;


  return 0;
}
0