結果

問題 No.238 Mr. K's Another Gift
ユーザー vjudge1
提出日時 2025-08-04 09:55:55
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,172 bytes
コンパイル時間 3,415 ms
コンパイル使用メモリ 279,992 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-04 09:56:06
合計ジャッジ時間 9,684 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <bits/extc++.h>
//#define int long long
//#define endl "\n"
#define debug printf("Running %s on line %d...\n", __FUNCTION__, __LINE__)
#define ll long long
#define ull unsigned long long
#define str string
#define db double
#define ld long double
#define si signed
#define PQ priority_queue
#define elif else if
#define _1 first
#define _2 second
#define fi first
#define se second
#define _E M_E
#define LOG2E M_LOG2E
#define LOG10E M_LOG10E
#define LN2 M_LN2
#define LN10 M_LN10
#define PI M_PI
#define PI_2 M_PI_2
#define PI_4 M_PI_4
#define _1_PI M_1_PI
#define _2_PI M_2_PI
#define _2_SQRTPI M_2_SQRTPI
#define SQRT2 M_SQRT2
#define SQRT1_2 M_SQRT1_2
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) x * y / __gcd(x, y)
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define O cout << -1 << endl
#define E cout << endl
#define IO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define R return 0
using namespace std;
//using namespace __gnu_pbds;

const ll N = 5e5 + 2, LN = __lg(N) * 3 + 2, MN = 1e2 + 2, inf = INT_MAX;
const ll dmax = INT_MAX, dmin = INT_MIN, mmax = 0x7f, minf = 0x7f7f7f7f;
const ll lmax = LLONG_MAX, lmin = LLONG_MIN, ulmax = ULLONG_MAX;
const ll M = 1610612741, P = 131, Mod = 998244353, Mod2 = 1e9 + 7;
const ld eps = 1e-10;

int _, n, m;
string s, t;


bool is_hw(string s) {
	for (int i = 0;i < s.size() / 2;i++) if (s[i] != s[s.size() - 1 - i]) return 0;
	return 1;
}

signed main() {
	for (char i = 33;i <= 126;i++) t += i;
	cout << t << endl;
    cin >> _;
    while (_--) {
    	cin >> s;
    	string temp = s;
    	for (int i = 0;i <= s.size();i++) {
    		for (int j = 0;j < t.size();j++) {
				s.insert(i, t.substr(j, 1));
				if (is_hw(s)) {
					cout << s << endl;
					goto C;
				}
				s = temp;
			}
		}
		cout << "NA" << endl; 
		C:;
	}
    return 0;
}
0