제출 #431840

#제출 시각아이디문제언어결과실행 시간메모리
431840sikamax2019회문 (APIO14_palindrome)C++14
0 / 100
1073 ms1236 KiB
#include <bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define mp make_pair #define pb push_back #define ll long long #define ld long double #define debug(x) cout << '[' << #x << " is: " << x << "] " << endl; #define rsor(v) sort(v.rbegin() , v.rend()); #define rev(v) reverse(v.begin() , v.end()); #define sz(x) (int)(x).size() #define all(x) x.begin(), x.end() #define _cout(v) for(auto f : v ) cout << f << " " ; #define _cin(v) for(auto &it : v)cin >> it ; #define _fo(v) for(int i=0;i<(n);i++) #define vi vector<int> #define fs first #define sc second int32_t main() { IOS; string s;cin>>s; if(s.length() <= 1) return 1; int max_len = 1; int n = s.length(); int st = 0, end = 0; // Odd length for(int i = 0; i < n-1; ++i){ int l = i, r = i; while(l >= 0 && r < n){ if(s[l] == s[r]){ l--; r++; }else break; } int len = r-l-1; if(len > max_len){ max_len = len; st = l+1; end = r-1; } } // Even length for(int i = 0; i < n-1; ++i){ int l = i, r = i+1; while(l >= 0 && r < n){ if(s[l] == s[r]){ l--; r++; }else break; } int len = r-l-1; if(len > max_len){ max_len = len; st = l+1; end = r-1; } } cout<<max_len; }

컴파일 시 표준 에러 (stderr) 메시지

palindrome.cpp: In function 'int32_t main()':
palindrome.cpp:26:13: warning: variable 'st' set but not used [-Wunused-but-set-variable]
   26 |         int st = 0, end = 0;
      |             ^~
palindrome.cpp:26:21: warning: variable 'end' set but not used [-Wunused-but-set-variable]
   26 |         int st = 0, end = 0;
      |                     ^~~
#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...