Submission #3609

#TimeUsernameProblemLanguageResultExecution timeMemory
3609Apple_CplusMake superpalindrome! (kriii1_M)C++98
0 / 1
0 ms1912 KiB
#include <stdio.h> #include <iostream> #include <vector> #include <queue> #include <algorithm> #include <sstream> #include <set> #include <map> #include <stack> #include <cmath> #include <cstdlib> #include <cstring> #include <string> using namespace std; #define ll long long #define pi pair<int,int> #define pll pair<ll,ll> #define pii pair<int,pi> #define X first #define Y second #define pb push_back #define ab(x) ((x)<0?(-(x)):(x)) #define xx(x) ((x)*(x)) #define mp make_pair #define vi vector<int> #define vll vector<ll> #define vs vector<string> #define vpi vector<pi> #define vpll vector<pll> #define ALL(x) (x).begin(),(x).end() #define Max (1<<30) #define LLMax (1ll<<60) template<class T>string ToString(T t){stringstream s;s<<t;return s.str();} template<class T>void ToOther(T&t,string a){stringstream s(a);s>>t;} char a[100005]; string A; void UP(string &A){ int n=A.size(); int s,e; s=n/2;e=n/2; if(A.size()%2==0)e++; A[s]++; for(s;s>=0;s--,e++){ if(A[s]>'z'){ A[s]='a'; A[e]='a'; A[s-1]++; A[e+1]++; }else break; } } string Get(int x){ string t=A.substr(0,x); string r=A.substr(0,x); int n=r.size(); int s,e; s=n/2;e=n/2; if(r.size()%2==0)e++; for(s;s>=0;s--,e++){ r[e]=r[s]; } while(r<t)UP(r); return r; } int main(){ scanf("%s",&a); A=a; int n=A.size(); string L=Get(n/2); string L1=A.substr(0,n/2); string mid=""; string R2=""; if(A.size()%2){ R2=A.substr(n/2+1); mid+=A[n/2]; }else{ R2=A.substr(n/2); } bool up=1; if(L==L1)up=0; if(up){ if(mid.size())mid="a"; cout<<L<<mid<<L<<endl; }else{ if(R2<=L){ cout<<L<<mid<<L; }else{ UP(L); if(mid.size())mid="a"; cout<<L<<mid<<L; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...