Submission #1221927

#TimeUsernameProblemLanguageResultExecution timeMemory
1221927Nika533Palindromic Partitions (CEOI17_palindromic)C++20
Compilation error
0 ms0 KiB
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #define int long long #define A 912938523528553253 #define B 983525235265326669 #define pb push_back #define f first #define s second #define MOD 1000000007 #define flush fflush(stdout) #define all(x) (x).begin(),(x).end() #define allr(x) (x).rbegin(), (x).rend() #define pii pair<int,int> using namespace std; const int N=1000005; int n,m,T,k,p[N],h[N]; string s; void build_hash() { p[0]=1; for (int i=1; i<n; i++) { __int128 a=A,b=B,P=p[i-1],val; val=(P*a)%b; p[i]=val; } h[0]=s[0]; for (int i=1; i<n; i++) { __int128 a=A,b=B,H=h[i-1],val; val=(H*a+s[i])%b; h[i]=val; } } int f(int l, int r) { if (l==0) return h[r]; __int128 a=A,b=B,P=p[r-l+1],H_L=h[l-1],H_R=h[r],val; val=(H_R-(H_L*P)%b+b)%b; int ans=val; return ans; } void test_case() { cin>>s; n=s.size(); build(); int last=-1,cnt=0; for (int i=0; i<n/2; i++) { int l=last+1,r=i; int l1=n-r-1,r1=n-l+1; if (f(l,r)==f(l1,r1)) { last=i; cnt+=2; } } if (n%2==0 && last==n/2-1) cout<<cnt<<endl; else cout<<cnt+1<<endl; } main () { ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); T=1; cin>>T; while (T--) test_case(); }

Compilation message (stderr)

palindromic.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
palindromic.cpp: In function 'void test_case()':
palindromic.cpp:39:9: error: 'build' was not declared in this scope
   39 |         build();
      |         ^~~~~
palindromic.cpp: At global scope:
palindromic.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main () {
      | ^~~~