結果
| 問題 |
No.233 めぐるはめぐる (3)
|
| コンテスト | |
| ユーザー |
nanasili
|
| 提出日時 | 2015-07-30 17:35:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,409 bytes |
| コンパイル時間 | 723 ms |
| コンパイル使用メモリ | 91,156 KB |
| 実行使用メモリ | 9,216 KB |
| 最終ジャッジ日時 | 2024-07-17 22:37:49 |
| 合計ジャッジ時間 | 5,237 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 RE * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%s", s);
| ~~~~~^~~~~~~~~
ソースコード
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>
using namespace std;
typedef long long ll;
int main() {
int n;
scanf("%d", &n);
if (n >= 230400) {
puts("NO");
return 0;
}
int memo[12] = {4331, 16048, 21792, 22962, 24977, 2984, 24324, 6723, 1211, 29381, 29059, 9149};
set <int> hash;
for (int i = 0; i < n; i++) {
char s[12];
scanf("%s", s);
int t = 0;
for (int j = 0; j < 12; j++) {
t += s[j]*memo[j];
}
hash.insert(t);
}
int ind1[6], ind2[6];
for (int i = 0; i < 6; i++) {
ind1[i] = i;
ind2[i] = i;
}
char str[12] = "inabameguru";
do {
do {
int temp = 0;
for (int i = 0; i < 6; i++) {
temp += str[ind1[i]*2]*memo[i*2];
}
for (int i = 0; i < 5; i++) {
temp += str[2*ind2[i]+1]*memo[2*i+1];
}
if (hash.find(temp) == hash.end()) {
char ans[12];
for (int i = 0; i < 6; i++) {
ans[i*2] = str[ind1[i]*2];
}
for (int i = 0; i < 5; i++) {
ans[2*i+1] = str[2*ind2[i]+1];
}
ans[11] = '\0';
puts(ans);
return 0;
}
} while(next_permutation(ind2, ind2+5));
} while(next_permutation(ind1, ind1+6));
reverse(ind1, ind1+6);
reverse(ind2, ind2+5);
do {
do {
int temp = 0;
for (int p = 0; p <= 10; p+=2) {
for (int i = 1; i <= 10; i++) {
for (int j = 0; j <= 5; j++) {
if (2*j >= i) {
temp += str[2*ind1[j]+1]*memo[2*j+1];
}else {
temp += str[2*ind1[j]]*memo[2*j];
}
if (2*j+1 >= i) {
temp += str[2*ind2[j]+2]*memo[2*j+2];
}else {
temp += str[2*ind2[j]+1]*memo[2*j+1];
}
}
temp += str[p]*memo[i];
if (hash.find(temp) == hash.end()) {
char ans[12];
for (int j = 0; j <= 5; j++) {
if (2*j >= i) {
ans[2*j+1] = str[2*ind1[j]+1];
}else {
ans[2*j] = str[2*j];
}
if (2*j+1 >= i) {
ans[2*j+2] = str[2*j+2];
}else {
ans[2*j+1] = str[2*j+1];
}
}
ans[i] = str[p];
puts(ans);
return 0;
}
}
}
} while(next_permutation(ind2, ind2+5));
} while(next_permutation(ind1, ind1+5));
}
nanasili