結果

問題 No.2715 Unique Chimatagram
ユーザー tobbietobbie
提出日時 2024-05-02 23:32:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,164 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 178,284 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-02 23:32:25
合計ジャッジ時間 5,688 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, j, n) for (int i = (int)j; i < (int)n; i++)
using pii = pair<int, int>;

bool comp(pii a, pii b) {
  if (a.first != b.first)
    return a.first > b.first;
  else
    return a.second < b.second;
}

int main() {
  int N;
  cin >> N;
  vector<vector<int>> S(N, vector<int> (26, 0));
  vector<pii> sv(N);
  rep(i, N) {
    string Si;
    cin >> Si;
    for (char c : Si)
      S[i][c - 'a']++;
    sv.push_back({(int)Si.size(), i});
  }
  sort(sv.begin(), sv.end(), comp);
  if (sv[0].first != sv[1].first) {
    int a = 0;
    rep(i, 26) {
      if (S[sv[0].second][i] == 0)
	a = i;
      rep(j, S[sv[0].second][i])
	cout << char(int('a')+i);
    }
    cout << char(int('a')+a) << endl;
  } else {
    int a = 0;
    int dif = 0;
    rep(i, 26) {
      if (S[sv[0].second][i] != S[sv[1].second][i])
	dif++;
      if (S[sv[1].second][i] == 0)
	a = i;
    }
    if (dif == 0) cout << -1 << endl;
    else {
      rep(i, 26) {
	rep(j, S[sv[0].second][i])
	  cout << char(int('a')+i);
      }
      cout << char(int('a')+a) << endl;
    }
  }
  return 0;
}
0