제출 #338029

#제출 시각아이디문제언어결과실행 시간메모리
338029rrrr10000Palindromic Partitions (CEOI17_palindromic)C++14
60 / 100
10054 ms6444 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> PP; typedef vector<ll> vi; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<PP> vpp; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++) #define all(v) v.begin(),v.end() #define dupli(v) {sort(all(v));v.erase(unique(all(v)),v.end());} #define rsort(a) {sort(all(a));reverse(all(a));} #define pb emplace_back #define fi first #define se second #define lb(v,k) (lower_bound(all(v),k)-v.begin()) template<class T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} template<class T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;} template<class T>void out(T a){cout<<a<<endl;} template<class T>void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;} template<class T>void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;} template<class T>void outvp(T v){for(auto a:v)cout<<'('<<a.fi<<','<<a.se<<')';cout<<endl;} template<class T>void outvv(T v){for(auto x:v)outv(x);} template<class T>void outvvp(T v){for(auto x:v)outvp(x);} const ll inf=1001001001001001001; vi z_algo(string &s){ int i=1,j=0; vi res(s.size()); res[0]=s.size(); while(i<s.size()){ while(i+j<s.size()&&s[j]==s[i+j])j++; res[i]=j; if(j==0){ i++;continue; } int k=1; while(k<j&&k+res[k]<j){ res[i+k]=res[k]; k++; } i+=k;j-=k; } return res; } int main(){ ll t;cin>>t; rep(tt,t){ ll ans=1; string s;cin>>s; ll l=0,r=s.size()-1,k=1; while(l<r){ bool same=true; rep(i,k)if(s[l-k+1+i]!=s[r+i])same=false; if(same){ ans+=2;k=0; } l++;r--;k++; } if(k==1&&s.size()%2==0)ans--; out(ans); } }

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

palindromic.cpp: In function 'vi z_algo(std::string&)':
palindromic.cpp:36:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     while(i<s.size()){
      |           ~^~~~~~~~~
palindromic.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         while(i+j<s.size()&&s[j]==s[i+j])j++;
      |               ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...