QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#481656#5501. Ctrl+C Ctrl+VUESTC_DECAYALI#Compile Error//C++17825b2024-07-17 12:27:562024-07-17 12:27:57

Judging History

你现在查看的是最新测评结果

  • [2024-07-17 12:27:57]
  • 评测
  • [2024-07-17 12:27:56]
  • 提交

answer

#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=1e6+5,INF=1e9;
int t,f[N][1<<4]; char s[N];
int main()
{
	for (scanf("%d",&t);t;--t)
	{
		RI i,j,k; scanf("%s",s+1); int n=strlen(s+1);
		if (n<=3) { puts("0"); continue; }
		for (i=1;i<=n;++i) for (j=0;j<16;++j) f[i][j]=INF;
		for (j=0;j<16;++j) f[4][j]=__builtin_popcount(j);
		if (s[1]=='a'&&s[2]=='n'&&s[3]=='i'&&s[4]=='a') f[4][0]=INF;
		for (i=4;i<n;++i) for (j=0;j<16;++j) if (f[i][j]!=INF)
		{
			for (k=0;k<2;++k)
			{
				int mask=((j<<1)&15)|k;
				if (mask==0&&s[i-2]=='a'&&s[i-1]=='n'&&s[i]=='i'&&s[i+1]=='a') continue;
				f[i+1][mask]=min(f[i+1][mask],f[i][j]+k);
			}
		}
		int ans=INF; for (j=0;j<16;++j) ans=min(ans,f[n][j]);
		printf("%d\n",ans);
	}
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:12:20: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 |                 RI i,j,k; scanf("%s",s+1); int n=strlen(s+1);
      |                    ^
answer.code:12:22: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 |                 RI i,j,k; scanf("%s",s+1); int n=strlen(s+1);
      |                      ^
answer.code:12:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 |                 RI i,j,k; scanf("%s",s+1); int n=strlen(s+1);
      |                        ^
answer.code:12:50: error: ‘strlen’ was not declared in this scope
   12 |                 RI i,j,k; scanf("%s",s+1); int n=strlen(s+1);
      |                                                  ^~~~~~
answer.code:3:1: note: ‘strlen’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    2 | #include<iostream>
  +++ |+#include <cstring>
    3 | #define RI register int
answer.code:10:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         for (scanf("%d",&t);t;--t)
      |              ~~~~~^~~~~~~~~
answer.code:12:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 RI i,j,k; scanf("%s",s+1); int n=strlen(s+1);
      |                           ~~~~~^~~~~~~~~~