답안 #249400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
249400 2020-07-14T21:37:29 Z uacoder123 Palindromic Partitions (CEOI17_palindromic) C++14
컴파일 오류
0 ms 0 KB
 #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
 
typedef int lli;a #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
 
typedef int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
int m=1000000007;
lli cal(lli p,lli n)
{
  lli b=0,ans=1,a=n;
  while((1LL<<b)<=p)
  {
    if(bit(p,b))
      ans=(ans*a)%m;
    a=(a*a)%m;
    b++;
  }
  return(ans);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test=1;
  cin>>test;
  for(;test>0;--test)
  {
    lli n,p=131,c=0,l=0,la=0,r,ls=0,rs=0;
    string s;
    cin>>s;
    n=s.size();
    r=n-1;
    while(l<=r)
    {
      ls=(ls+((s[l]-'a')*cal(l-la+1,p))%m)%m;
      rs=(rs*p+((s[n-1-la-(l-la)]-'a')*p)%m)%m;
      if(l!=r&&rs==ls)
      {
        r=n-1-la-(l-la)-1;
        rs=0;
        ls=0;
        c+=2;
        la=l+1;
        l=la;
      }
      else
      {
        r--;
        l++;
      }
      if(l>=r)
      {
        if(l==r)
          c++;
        break;
      }
    }
    cout<<c<<endl;
  }
  return(0);
}
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
int m=1000000007;
lli cal(lli p,lli n)
{
  lli b=0,ans=1,a=n;
  while((1LL<<b)<=p)
  {
    if(bit(p,b))
      ans=(ans*a)%m;
    a=(a*a)%m;
    b++;
  }
  return(ans);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test=1;
  cin>>test;
  for(;test>0;--test)
  {
    lli n,p=131,c=0,l=0,la=0,r,ls=0,rs=0;
    string s;
    cin>>s;
    n=s.size();
    r=n-1;
    while(l<=r)
    {
      ls=(ls+((s[l]-'a')*cal(l-la+1,p))%m)%m;
      rs=(rs*p+((s[n-1-la-(l-la)]-'a')*p)%m)%m;
      if(l!=r&&rs==ls)
      {
        rs=0;
        ls=0;
        c+=2;
        la=l+1;
        l=la;
        r=n-1-la-(l-la)-1;
      }
      else
      {
        r--;
        l++;
      }
      if(l>=r)
      {
        c++;
        break;
      }
    }
    cout<<c<<endl;
  }
  return(0);
}

Compilation message

palindromic.cpp:13:19: error: stray '#' in program
 typedef int lli;a #include <bits/stdc++.h>
                   ^
palindromic.cpp:13:17: error: 'a' does not name a type
 typedef int lli;a #include <bits/stdc++.h>
                 ^
palindromic.cpp:87:5: error: redefinition of 'int m'
 int m=1000000007;
     ^
palindromic.cpp:29:5: note: 'int m' previously defined here
 int m=1000000007;
     ^
palindromic.cpp: In function 'lli cal(lli, lli)':
palindromic.cpp:88:5: error: redefinition of 'lli cal(lli, lli)'
 lli cal(lli p,lli n)
     ^~~
palindromic.cpp:30:5: note: 'lli cal(lli, lli)' previously defined here
 lli cal(lli p,lli n)
     ^~~
palindromic.cpp: In function 'int main()':
palindromic.cpp:100:5: error: redefinition of 'int main()'
 int main()
     ^~~~
palindromic.cpp:42:5: note: 'int main()' previously defined here
 int main()
     ^~~~