Submission #246283

# Submission time Handle Problem Language Result Execution time Memory
246283 2020-07-08T14:35:09 Z vanic Palinilap (COI16_palinilap) C++14
0 / 100
283 ms 2176 KB
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>


using namespace std;

const int maxn=5005;

string s;
int jos[maxn][30];
int br;

void rijesi(int x, bool p1){
	int l, d;
	if(p1){
		l=x;
		d=x;
	}
	else{
		l=x;
		d=x+1;
	}
	bool p=1;
	int l1, d1;
	while(l>-1 && d<s.size()){
		if(s[l]==s[d]){
			if(p){
				if(l!=d){
					for(int i=0; i<26; i++){
						jos[l][i]--;
						jos[d][i]--;
					}
				}
				br++;
			}
			else{
				jos[l1][s[d1]-'a']++;
				jos[d1][s[l1]-'a']++;
			}
		}
		else{
			if(p){
				l1=l;
				d1=d;
				jos[l1][s[d1]-'a']++;
				jos[d1][s[l1]-'a']++;
				p=0;
			}
			else{
				break;
			}
		}
		l--;
		d++;
	}
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	for(int i=0; i<s.size(); i++){
		rijesi(i, 1);
		rijesi(i, 0);
	}
	int maksi=0;
	for(int i=0; i<s.size(); i++){
		for(int j=0; j<26; j++){
			maksi=max(maksi, jos[i][j]);
		}
	}
	cout << br+maksi << '\n';
	return 0;
}

Compilation message

palinilap.cpp: In function 'void rijesi(int, bool)':
palinilap.cpp:27:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(l>-1 && d<s.size()){
                ~^~~~~~~~~
palinilap.cpp: In function 'int main()':
palinilap.cpp:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<s.size(); i++){
               ~^~~~~~~~~
palinilap.cpp:71:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<s.size(); i++){
               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 283 ms 1064 KB Output is correct
2 Incorrect 259 ms 1092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 2176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -