Submission #249402

# Submission time Handle Problem Language Result Execution time Memory
249402 2020-07-14T21:49:11 Z uacoder123 Palindromic Partitions (CEOI17_palindromic) C++14
Compilation error
0 ms 0 KB
v #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;
        if(l==r)
          c++;
      }
      else
      {
        r--;
        l++;
        if(l>=r)
          c++;
      }
      if(l>=r)
      {
        break;
      }
    }
    cout<<c<<endl;
  }
  return(0);
}

Compilation message

palindromic.cpp:1:3: error: stray '#' in program
 v #include <bits/stdc++.h>
   ^
palindromic.cpp:1:1: error: 'v' does not name a type
 v #include <bits/stdc++.h>
 ^
palindromic.cpp:14:9: error: 'pair' does not name a type
 typedef pair <lli,lli> ii;
         ^~~~
palindromic.cpp:15:9: error: 'pair' does not name a type
 typedef pair <lli,ii> iii;
         ^~~~
palindromic.cpp:16:9: error: 'vector' does not name a type
 typedef vector <lli> vi;
         ^~~~~~
palindromic.cpp: In function 'int main()':
palindromic.cpp:32:3: error: 'ios_base' has not been declared
   ios_base::sync_with_stdio(false);
   ^~~~~~~~
palindromic.cpp:33:3: error: 'cin' was not declared in this scope
   cin.tie(NULL);
   ^~~
palindromic.cpp:33:3: note: suggested alternative: 'main'
   cin.tie(NULL);
   ^~~
   main
palindromic.cpp:33:11: error: 'NULL' was not declared in this scope
   cin.tie(NULL);
           ^~~~
palindromic.cpp:39:5: error: 'string' was not declared in this scope
     string s;
     ^~~~~~
palindromic.cpp:39:5: note: suggested alternative: 'struct'
     string s;
     ^~~~~~
     struct
palindromic.cpp:40:10: error: 's' was not declared in this scope
     cin>>s;
          ^
palindromic.cpp:40:10: note: suggested alternative: 'rs'
     cin>>s;
          ^
          rs
palindromic.cpp:70:5: error: 'cout' was not declared in this scope
     cout<<c<<endl;
     ^~~~
palindromic.cpp:70:14: error: 'endl' was not declared in this scope
     cout<<c<<endl;
              ^~~~
palindromic.cpp:70:14: note: suggested alternative: 'enum'
     cout<<c<<endl;
              ^~~~
              enum