Submission #670217

#TimeUsernameProblemLanguageResultExecution timeMemory
670217NothingXDPalindromes (APIO14_palindrome)C++14
8 / 100
1105 ms131072 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; /*typedef __uint128_t L; struct FastMod { ull b, m; FastMod(ull b) : b(b), m(ull((L(1) << 64) / b)) {} ull reduce(ull a) { ull q = (ull)((L(m) * a) >> 64); ull r = a - q * b; // can be proven that 0 <= r < 2*b return r >= b ? r - b : r; } }; FastMod FM(2);*/ typedef pair<int,int> pii; typedef pair<ll,ll> pll; void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); } #define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__) #define all(x) x.begin(), x.end() #define MP(x, y) make_pair(x, y) #define F first #define S second //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); map<string,int> mp; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; for (int i = 0; i < s.size(); i++){ for (int j = i; j < s.size(); j++){ string t = s.substr(i, j-i+1); mp[t]++; } } int ans = 0; for (auto [x, y]: mp){ string t = x; reverse(all(t)); if (t == x) ans = max(ans, y * (int)t.size()); } cout << ans << '\n'; return 0; }

Compilation message (stderr)

palindrome.cpp: In function 'int main()':
palindrome.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for (int i = 0; i < s.size(); i++){
      |                  ~~^~~~~~~~~~
palindrome.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for (int j = i; j < s.size(); j++){
      |                   ~~^~~~~~~~~~
palindrome.cpp:53:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   53 |  for (auto [x, y]: mp){
      |            ^
#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...