답안 #394718

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394718 2021-04-27T08:25:14 Z Anand 회문 (APIO14_palindrome) C++14
23 / 100
1000 ms 8292 KB
#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++;
    }
}
int occ(string s , string f)
{
    int count = 0;
    size_t nPos = s.find(f, 0);
    while(nPos != string::npos)
    {
        count++;
        nPos = s.find(f, nPos + 1);
    }
    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 = occ(str , p);
        res.push_back(count*small);
    }

    sort(res.begin() , res.end());
    int sz = res.size();
    cout << res[sz-1];

    return 0;
}

Compilation message

palindrome.cpp:3:44: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
    3 | void expand(string str, int low, int high, auto& set)
      |                                            ^~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     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:32:30:   required from here
palindrome.cpp:5:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |     while (low >= 0 && high < str.length() && str[low] == str[high])
      |                        ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 292 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 896 KB Output is correct
2 Correct 24 ms 588 KB Output is correct
3 Correct 122 ms 856 KB Output is correct
4 Correct 6 ms 424 KB Output is correct
5 Correct 121 ms 844 KB Output is correct
6 Correct 123 ms 916 KB Output is correct
7 Correct 6 ms 772 KB Output is correct
8 Correct 64 ms 884 KB Output is correct
9 Correct 5 ms 416 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 7 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 7936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 8292 KB Time limit exceeded
2 Halted 0 ms 0 KB -