답안 #244330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244330 2020-07-03T15:58:09 Z MatesV13 Palinilap (COI16_palinilap) C++11
17 / 100
1000 ms 640 KB
#include <bits/stdc++.h>
using namespace std;
string s; int ans;
int solve(){
	int sol=0;
	for (int i=0; i<s.size(); i++){
		for (int j=0; true; j++){
			if (i<j or i+j>=s.size()) break;
			if (s[i+j]!=s[i-j]) break;
			sol++; 
		}
	}
	for (int i=0; i<s.size(); i++){
		for (int j=0; true; j++){
			if (i<j+1 or i+j>=s.size()) break;
			if (s[i+j]!=s[i-j-1]) break;
			sol++; 
		}
	}
	return sol;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s; ans=0;
for (int i=0; i<s.size(); i++){
	char real=s[i];
	for (char j='a'; j<='z'; j++){
		s[i]=j; ans = max(ans, solve());
	} s[i]=real;
} cout << ans << endl;
return 0;
}

Compilation message

palinilap.cpp: In function 'int solve()':
palinilap.cpp:6:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<s.size(); i++){
                ~^~~~~~~~~
palinilap.cpp:8:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (i<j or i+j>=s.size()) break;
               ~~~^~~~~~~~~~
palinilap.cpp:13:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<s.size(); i++){
                ~^~~~~~~~~
palinilap.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (i<j+1 or i+j>=s.size()) break;
                 ~~~^~~~~~~~~~
palinilap.cpp: In function 'int main()':
palinilap.cpp:26:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for (int i=0; i<s.size(); i++){
               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 16 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -