Submission #919522

# Submission time Handle Problem Language Result Execution time Memory
919522 2024-02-01T04:22:29 Z jpfr12 Palindromes (APIO14_palindrome) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <fstream>
#include <bitset>
#include <iomanip>
 
typedef long long ll;
using namespace std;
int MOD = (int)1e9;
int MAXN = 1e6;
 
//classes

 
 
//global
string s;
int n;
unordered_map<string, ll> Map;

void sol(int left, int right){
  while(left >= 0 && right < n){
    if(s[left] != s[right]) return;
    string temp = s.substr(left, right-left+1);
    Map[temp]++;
    left--;
    right++;
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //ifstream fin("input.txt");
  //ofstream fout("output.txt");
  //stop
  cin >> s;
  n = s.length();
  for(int i = 0; i < n; i++){
    sol(i, i);
    sol(i, i+1);
  }
  ll ans = 0;
  for(auto& i: Map){
    ans = max(ans, i.second * i.first.length());
  }
  cout << ans << '\n';
  return 0;
}

Compilation message

palindrome.cpp: In function 'int main()':
palindrome.cpp:58:47: error: no matching function for call to 'max(ll&, long long unsigned int)'
   58 |     ans = max(ans, i.second * i.first.length());
      |                                               ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from palindrome.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
palindrome.cpp:58:47: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   58 |     ans = max(ans, i.second * i.first.length());
      |                                               ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from palindrome.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
palindrome.cpp:58:47: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   58 |     ans = max(ans, i.second * i.first.length());
      |                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from palindrome.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
palindrome.cpp:58:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   58 |     ans = max(ans, i.second * i.first.length());
      |                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from palindrome.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
palindrome.cpp:58:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   58 |     ans = max(ans, i.second * i.first.length());
      |                                               ^