結果
| 問題 |
No.233 めぐるはめぐる (3)
|
| コンテスト | |
| ユーザー |
nanasili
|
| 提出日時 | 2015-07-31 09:41:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 295 ms / 1,000 ms |
| コード長 | 1,694 bytes |
| コンパイル時間 | 787 ms |
| コンパイル使用メモリ | 90,184 KB |
| 実行使用メモリ | 9,600 KB |
| 最終ジャッジ日時 | 2024-07-17 22:53:20 |
| 合計ジャッジ時間 | 3,971 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 |
コンパイルメッセージ
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:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | 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);
int memo[12] = {50965598, 138640614, 86894790, 22969011, 137866584, 12805388, 102696496, 169269628, 196679944, 213985204, 79308356};
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);
}
if (hash.size() >= 129599) {
puts("NO");
return 0;
}
int ind1[6], ind2[6];
for (int i = 0; i < 6; i++) {
ind1[i] = i;
ind2[i] = i;
}
char str[12] = "inabameguru";
do {
do {
char ans[12];
int temp = 0;
for (int i = 0; i < 6; i++) {
temp += str[ind1[i]<<1]*memo[i<<1];
ans[i<<1] = str[ind1[i]<<1];
}
for (int i = 0; i < 5; i++) {
temp += str[(ind2[i]<<1)+1]*memo[(i<<1)+1];
ans[(i<<1)+1] = str[(ind2[i]<<1)+1];
}
ans[11] = '\0';
if (hash.find(temp) == hash.end()) {
puts(ans);
return 0;
}
for (int i = 0; i < 10; i++) {
temp += ans[i]*memo[i+1]-ans[i]*memo[i];
temp += ans[i+1]*memo[i]-ans[i+1]*memo[i+1];
swap(ans[i], ans[i+1]);
if (hash.find(temp) == hash.end()) {
puts(ans);
return 0;
}
}
} while(next_permutation(ind2, ind2+5));
} while(next_permutation(ind1, ind1+6));
}
nanasili