結果
問題 |
No.238 Mr. K's Another Gift
|
ユーザー |
|
提出日時 | 2015-07-05 22:55:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 964 bytes |
コンパイル時間 | 1,459 ms |
コンパイル使用メモリ | 161,020 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 23:35:27 |
合計ジャッジ時間 | 4,521 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 WA * 10 |
ソースコード
#include <bits/stdc++.h> #define rep(i, a) for (int i = 0; i < (a); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) using namespace std; typedef long long ll; const ll inf = 1e9; const ll mod = 1e9 + 7; int main() { string s; cin >> s; string t = s; reverse(t.begin(), t.end()); vector<int> diff(s.length() + 1); rep (i, s.length()) { diff[i] = s[i] - t[i]; } int pos = 0; rep (i, s.length()) { if (diff[i] != 0) { pos = i; break; } } t += "~"; for (int i = t.length(); i > pos; i--) { t[i] = t[i - 1]; } rep (i, s.length()) { diff[i] = s[i] - t[i]; } t[pos] = t[t.length() - pos - 1]; bool all = true; rep (i, t.length()) { if (t[i] != t[t.length() - i - 1]) { all = false; } } if (all) { cout << t << endl; } else { cout << "NA" << endl; } }