답안 #202588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
202588 2020-02-17T08:09:12 Z detaomega Lampice (COCI19_lampice) C++14
25 / 110
518 ms 632 KB
#include <bits/stdc++.h>
using namespace std;  
#define IOS ios::sync_with_stdio(0);cin.tie(0);  
#define int long long  
#define X first  
#define Y second  
#define rep(i,a,b) for(int i=a;i<=b;i++)  
#define int long long  
#define de(x,y) cout<<#x<<" "<<x<<y;  
#define pray(a,i,n_thing) for(int x=i;x<=(i+n_thing);x++) cout<<#a<<"["<<x<<"] :"<<a[x]<<endl;  
#define mem(aa,x) memset(aa,x,sizeof aa)  
#define pb push_back  
typedef long long ll;  
typedef pair<int,int> ii;  
const int maxn=4e5+5;  
int arr[maxn];  

main() {
	IOS  
	int n;
	cin >> n;
	
   
        string s;  
        cin >> s;  
        int ans = 1 , len = s.size();  
        for(int i=0;i<s.size()-1;i++) {  
            int tmp = 1;  
            for(int j=1;j<=s.size();j++) {  
                if(i-j < 0 || i+j >= len)   
                    break;  
                if(s[i - j] != s[i + j])  
                    break;  
                tmp += 2;  
            }  
            ans = max(ans , tmp);  
            if(s[i] == s[i+1]) {  
                tmp = 2;  
                for(int j=1;j<=s.size();j++) {  
                if(i-j < 0 || i+j+1 >= len)   
                    break;  
                if(s[i - j] != s[i + j+1])  
                    break;  
                tmp += 2;  
                }  
            }  
            ans = max(ans , tmp);  
            if(ans == len)  
                break;  
        }  
        cout << ans << "\n";  
        return 0;
}  

Compilation message

lampice.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
lampice.cpp: In function 'int main()':
lampice.cpp:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<s.size()-1;i++) {  
                     ~^~~~~~~~~~~
lampice.cpp:29:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=1;j<=s.size();j++) {  
                         ~^~~~~~~~~~
lampice.cpp:39:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=1;j<=s.size();j++) {  
                             ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 518 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -