結果

問題 No.233 めぐるはめぐる (3)
ユーザー nanasilinanasili
提出日時 2015-07-30 17:35:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,409 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 90,872 KB
実行使用メモリ 9,208 KB
最終ジャッジ日時 2023-09-24 22:17:19
合計ジャッジ時間 5,707 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
8,928 KB
testcase_01 AC 38 ms
6,976 KB
testcase_02 AC 18 ms
5,344 KB
testcase_03 AC 41 ms
7,472 KB
testcase_04 AC 84 ms
9,208 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 39 ms
7,240 KB
testcase_13 AC 69 ms
9,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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));
}
0