結果
| 問題 |
No.233 めぐるはめぐる (3)
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-03-29 01:21:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,810 bytes |
| コンパイル時間 | 945 ms |
| コンパイル使用メモリ | 96,932 KB |
| 実行使用メモリ | 23,636 KB |
| 最終ジャッジ日時 | 2024-10-02 07:00:01 |
| 合計ジャッジ時間 | 6,484 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 2 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 233.cc: No.233 めぐるはめぐる (3) - 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 */
// inabameguru
const char sos[6] = { '-', 'g', 'n', 'b', 'm', 'r' };
const char bos[6] = { 'a', 'a', 'i', 'u', 'u', 'e' };
typedef long long ll;
const ll P0 = 4561, P1 = 5347;
const ll MOD0 = 1000000007, MOD1 = 1000000009;
/* typedef */
typedef vector<string> vs;
typedef map<ll,int> mli;
/* global variables */
int sis[6], bis[6];
mli rhm0, rhm1;
/* subroutines */
void rhash(string &s, ll &rh0, ll &rh1) {
rh0 = rh1 = 0;
for (int i = 0; i < s.size(); i++) {
rh0 = (rh0 * P0 % MOD0 + s[i]) % MOD0;
rh1 = (rh1 * P1 % MOD1 + s[i]) % MOD1;
}
}
/* main */
int main() {
int n;
cin >> n;
vs sns;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sns.push_back(s);
ll rh0, rh1;
rhash(s, rh0, rh1);
rhm0[rh0] = i;
rhm1[rh1] = i;
}
for (int i = 0; i < 6; i++) sis[i] = bis[i] = i;
do {
do {
string s;
for (int i = 0; i < 6; i++) {
if (sos[sis[i]] != '-') s += sos[sis[i]];
s += bos[bis[i]];
}
ll rh0, rh1;
rhash(s, rh0, rh1);
mli::iterator mit0 = rhm0.find(rh0);
if (mit0 == rhm0.end() || sns[mit0->second] != s) {
mli::iterator mit1 = rhm1.find(rh1);
if (mit1 == rhm1.end() || sns[mit1->second] != s) {
cout << s << endl;
return 0;
}
}
} while (next_permutation(bis, bis + 6));
} while (next_permutation(sis, sis + 6));
return 0;
}
tnakao0123