Submission #990724

# Submission time Handle Problem Language Result Execution time Memory
990724 2024-05-31T06:03:50 Z vjudge1 Palinilap (COI16_palinilap) C++17
17 / 100
1000 ms 856 KB
#include<bits/stdc++.h>

using namespace std;

int w(string s)
{
  int ans = 0, n = s.size();
  for(int i = 0; i < n; i ++)
    {
      int cnt = 1;
      int l = i - 1, r = i + 1;
      while(l >= 0 && r < n)
	{
	  if(s[l] == s[r])
	    cnt++, l--, r++;
	  else
	    break;
	}
      ans += cnt;
    }

  for(int i = 0; i + 1 < n; i ++)
    {
      if(s[i] != s[i + 1]) continue;
      int cnt = 1;
      int l = i - 1, r = i + 2;
      while(l >= 0 && r < n)
	{
	  if(s[l] == s[r])
	    cnt++, l--, r++;
	  else
	    break;
	}
      ans += cnt;
    }
  return ans;
  
}

int main()
{
  int ans = 0, n;
  string s;
  cin >> s;
  n = s.size();
  ans = w(s);
  for(int i = 0; i < n; i ++)
    {
      char c = s[i];
      for(char nc = 'a'; nc <= 'z'; nc ++)
	{
	  if(c == nc) continue;
	  s[i] = nc;
	  ans = max(ans, w(s));
	}
      s[i] = c;
    }
  cout << ans << endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 6 ms 436 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1024 ms 856 KB Time limit exceeded
2 Halted 0 ms 0 KB -