Submission #394713

#TimeUsernameProblemLanguageResultExecution timeMemory
394713AnandPalindromes (APIO14_palindrome)C++14
0 / 100
1085 ms8312 KiB
#include <bits/stdc++.h> using namespace std; void expand(string str, int low, int high, auto& set) { while (low >= 0 && high < str.length() && str[low] == str[high]) { set.insert(str.substr(low, high - low + 1)); low--, high++; } } size_t countSubstring(string& str, string& sub) { if (sub.length() == 0) return 0; size_t count = 0, l = sub.length(); for (size_t offset = str.find(sub); offset != std::string::npos; offset = str.find(sub, offset + l)) { ++count; } return count; } int main() { string str; cin >> str; unordered_set<string> set; vector<int> res; for (int i = 0; i < str.length(); i++) { expand(str, i, i, set); expand(str, i, i + 1, set); } for(auto l = set.begin(); l != set.end(); l++) { string p = *l; int small = p.size(); int count = countSubstring(str , p); res.push_back(count*small); } sort(res.begin() , res.end()); int sz = res.size(); cout << res[sz-1]; return 0; }

Compilation message (stderr)

palindrome.cpp:5:44: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
    5 | void expand(string str, int low, int high, auto& set)
      |                                            ^~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i = 0; i < str.length(); i++)
      |                     ~~^~~~~~~~~~~~~~
palindrome.cpp: In instantiation of 'void expand(std::string, int, int, auto:1&) [with auto:1 = std::unordered_set<std::__cxx11::basic_string<char> >; std::string = std::__cxx11::basic_string<char>]':
palindrome.cpp:36:30:   required from here
palindrome.cpp:7:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     while (low >= 0 && high < str.length() && str[low] == str[high])
      |                        ~~~~~^~~~~~~~~~~~~~
#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...