結果
問題 |
No.599 回文かい
|
ユーザー |
![]() |
提出日時 | 2017-11-25 00:21:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,290 bytes |
コンパイル時間 | 1,644 ms |
コンパイル使用メモリ | 76,704 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-27 08:50:26 |
合計ジャッジ時間 | 2,587 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 17 |
ソースコード
#include <iostream> #include <math.h> #include <string> #include <algorithm> #include <vector> #include <iomanip> #define REP(i,n) for(int i=0;i<n;i++) typedef long long ll; using namespace std; int kaijo(int n){ int ans = 1; if (n != 0){ for (int i = 0; i < n; i++){ ans *= (n - i); } } else{ ans = 1; } return ans; } int main(){ string s; string a[10000]; string d1, d2; int size; int flag; ll cnt = 0; cin >> s; size = s.size(); int x = 0; int n = 0; //cout << size << endl; while (1){ x++; d1 = s.substr(0, x); d2 = s.substr(size-x, x); if (d1 == d2){ //cout << "TRUE"<< endl; a[n] = d1; s.erase(0, x); REP(i, x){ s.pop_back(); } //cout << s << endl; size = s.size(); x = 0; n++; } if (size == 0){ flag = 0; break; }else if (x == size / 2){ a[n] = s; n++; flag = 1; break; } } //cout << n << endl; d1 = ""; d2 = ""; /* REP(i, n){ cout << a[i] << endl; }*/ if (flag == 1){ cnt = n; for (int j = 2; j < n; j++){ REP(i, n - j+1){ REP(k, j){ d1 = d1 + a[i+k]; d2 = a[i+k] + d2; //cout << d1 << " " << d2 << endl; } if (d1 == d2){ cnt += n - i - j; } d1 = ""; d2 = ""; } } } cout << cnt % 1000000007 << endl; return 0; }