제출 #104483

#제출 시각아이디문제언어결과실행 시간메모리
104483E869120회문 (APIO14_palindrome)C++14
23 / 100
967 ms1996 KiB
#include <iostream> #include <string> #include <map> #include <algorithm> #include <vector> using namespace std; long long L[10009]; string S; pair<long long, int> L1[10009]; int cnt1, cnt2; bool ispalindrome(string V) { for (int i = 0; i < V.size(); i++) { if (V[i] != V[V.size() - 1 - i]) return false; } return true; } int main() { cin >> S; for (int i = 0; i < S.size(); i++) L[i] = (S[i] - 'a') + 1; long long maxn = 0; // 真ん中が決まっている場合 cnt1 = 0; for (int t = 1; t <= 26; t++) { for (int i = 0; i < S.size(); i++) { if (L[i] == t) { L1[cnt1] = make_pair(L[i], i); cnt1++; } } } for (int i = 1; i <= S.size(); i += 2) { int t1 = 0; for (int j = 0; j < cnt1; j++) { t1++; maxn = max(maxn, 1LL * t1 * i); if (L1[j].first != L1[j + 1].first) t1 = 0; } vector<pair<long long, int>>G[28]; for (int j = 0; j < cnt1; j++) { int pos1 = L1[j].second - (i / 2) - 1, pos2 = L1[j].second + (i / 2) + 1; if (pos1 >= 0 && pos2 < S.size() && L[pos1] == L[pos2]) G[L[pos1]].push_back(make_pair(311LL * L1[j].first + L[pos1], L1[j].second)); } cnt1 = 0; for (int j = 1; j <= 26; j++) { for (int k = 0; k < G[j].size(); k++) { L1[cnt1] = G[j][k]; cnt1++; } } } // 真ん中が決まっていない場合 cnt1 = 0; for (int t = 1; t <= 26; t++) { for (int i = 0; i < S.size() - 1; i++) { if (L[i] == L[i + 1] && L[i] == t) { L1[cnt1] = make_pair(L[i], i); cnt1++; } } } for (int i = 2; i <= S.size(); i += 2) { int t1 = 0; for (int j = 0; j < cnt1; j++) { t1++; maxn = max(maxn, 1LL * t1 * i); if (L1[j].first != L1[j + 1].first) t1 = 0; } vector<pair<long long, int>>G[28]; for (int j = 0; j < cnt1; j++) { int pos1 = L1[j].second - (i / 2), pos2 = L1[j].second + (i / 2) + 1; if (pos1 >= 0 && pos2 < S.size() && L[pos1] == L[pos2]) G[L[pos1]].push_back(make_pair(311LL * L1[j].first + L[pos1], L1[j].second)); } cnt1 = 0; for (int j = 1; j <= 26; j++) { for (int k = 0; k < G[j].size(); k++) { L1[cnt1] = G[j][k]; cnt1++; } } } cout << maxn << endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

palindrome.cpp: In function 'bool ispalindrome(std::__cxx11::string)':
palindrome.cpp:12:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < V.size(); i++) {
                  ~~^~~~~~~~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:20:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < S.size(); i++) L[i] = (S[i] - 'a') + 1;
                  ~~^~~~~~~~~~
palindrome.cpp:27:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < S.size(); i++) { if (L[i] == t) { L1[cnt1] = make_pair(L[i], i); cnt1++; } }
                   ~~^~~~~~~~~~
palindrome.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i <= S.size(); i += 2) {
                  ~~^~~~~~~~~~~
palindrome.cpp:40:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (pos1 >= 0 && pos2 < S.size() && L[pos1] == L[pos2]) G[L[pos1]].push_back(make_pair(311LL * L1[j].first + L[pos1], L1[j].second));
                     ~~~~~^~~~~~~~~~
palindrome.cpp:44:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int k = 0; k < G[j].size(); k++) {
                    ~~^~~~~~~~~~~~~
palindrome.cpp:53:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < S.size() - 1; i++) { if (L[i] == L[i + 1] && L[i] == t) { L1[cnt1] = make_pair(L[i], i); cnt1++; } }
                   ~~^~~~~~~~~~~~~~
palindrome.cpp:56:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 2; i <= S.size(); i += 2) {
                  ~~^~~~~~~~~~~
palindrome.cpp:66:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (pos1 >= 0 && pos2 < S.size() && L[pos1] == L[pos2]) G[L[pos1]].push_back(make_pair(311LL * L1[j].first + L[pos1], L1[j].second));
                     ~~~~~^~~~~~~~~~
palindrome.cpp:70:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int k = 0; k < G[j].size(); k++) {
                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...