QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#69125#4900. 数列重排skin_toCompile Error//C++142.6kb2022-12-24 09:56:112022-12-24 09:56:14

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-24 09:56:14]
  • 评测
  • [2022-12-24 09:56:11]
  • 提交

answer

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#include "immintrin.h"
#include "emmintrin.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int _=1e7+7,mod=998244353;
int m,l,r,X,n,pw[_],ans[_],res,Sum[_];
char s[_];
namespace sub4{
	void solve(){
		res=((ll)n*(n+1)/2-((2ll*n-m+2)*(m-1)/2))%mod;
		printf("%lld\n",(ll)res*pw[m]%mod);
		exit(0);
	}
}
namespace sub5{
	void solve(){
		int s0=X+s[0]-'0',s1=X+s[1]-'0';
		ans[0]=(ll)(n+1)*n/2%mod;ans[1]=(ans[0]-s1%mod+mod)%mod;ans[2]=(ans[0]-n%mod+mod)%mod;
		for(int i=l;i<=r;i++)res=(res^((ll)pw[i]*ans[i]%mod));
		printf("%d\n",res);
		exit(0);
	}
}
namespace sub6{
	void solve(){
		for(int i=l;i<=r;i++){
			if(i==0){res^=((ll)(n+1)*n/2)%mod;continue;}
			int N=m-i,mid=N/2;
			res^=((ll)(mid+1)*(N-mid+1)%mod*pw[i]%mod);
		}
		printf("%d\n",res);
		exit(0);
	}
}
namespace sub1{
	ll calc(int i,int j,int s0,int s1){
		int mid=j/2,P=s1-j;ll S=0,SS=0;
		S+=(ll)mid*(s0-i+1)+(ll)(j-mid)*(s0-i+1);
		SS+=(ll)mid*(s1-mid)+(ll)(j-mid)*(s1-(j-mid));
		mid=P/(s0/i-1);int sb=P-(s0/i-1)*mid,sa=(s0/i-1)-sb;
		S+=(ll)sa*mid*(s0-2*i+2)+(ll)sb*(mid+1)*(s0-2*i+2);
		SS+=(ll)sa*mid*(s1-mid)+(ll)sb*(mid+1)*(s1-(mid+1));
		return S+SS/2;
	}
	void solve(){
		for(int i=l;i<=r;i++){
			if(i==0){res^=((ll)(n+1)*n/2)%mod;continue;}
			int s0=Sum[i-1],s1,sum=0;
			s1=n-s0;sum=((ll)s0*(s0+1)/2-((2ll*s0-i+2)*(i-1)/2))%mod;
			ll Max=0;
			if(s0/i>1){
				int l=0,r=s1;
				while(l+2<r){
					int mid1=(l+r)>>1,mid2=((l+r)>>1)+1;
					if(calc(i,mid1,s0,s1)<calc(i,mid2,s0,s1))l=mid1;
					else r=mid2;
				}
				for(int j=l;j<=r;j++)
					Max=max(Max,calc(i,j,s0,s1));
			}else {
				int mid=s1/2;ll S=0,SS=0;
				S+=(ll)mid*(s0-i+1);
				SS+=(ll)mid*(s1-mid);
				S+=(ll)(s1-mid)*(s0-i+1);
				SS+=(ll)(s1-mid)*(s1-(s1-mid));
				Max=S+SS/2;
			}
			sum=(sum+Max%mod)%mod;
			res^=((ll)pw[i]*sum%mod);
		}
		printf("%d\n",res);
		exit(0);
	}
}
namespace sub0{
	void solve(){
		int s=(ll)(n+1)*n/2%mod;
		for(int i=l;i<=r;i++)
			res^=((ll)pw[i]*s%mod);
		printf("%d\n",res);
		exit(0);
	}
}
int main(){
	scanf("%d%d%d%d",&m,&l,&r,&X);
	scanf("%s",s);pw[0]=1;
	for(int i=1;i<=m;i++)
		pw[i]=(ll)pw[i-1]*233%mod;
	Sum[0]=X+s[0]-'0';
	for(int i=1;i<m;i++)
		Sum[i]=Sum[i-1]+X+s[i]-'0';
	n=X*m;
	for(int i=0;i<m;i++)n+=s[i]-'0';
	if(m==1)sub0::solve();
	if(X==1&&n==m)sub6::solve();
	if(l==m)sub4::solve();
	if(m<=2)sub5::solve();
	sub1::solve();
	return 0;
}

详细

In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/gthr.h:148,
                 from /usr/include/c++/11/ext/atomicity.h:35,
                 from /usr/include/c++/11/bits/ios_base.h:39,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:5:
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  102 | __gthrw(pthread_once)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  103 | __gthrw(pthread_getspecific)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  104 | __gthrw(pthread_setspecific)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  106 | __gthrw(pthread_create)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  107 | __gthrw(pthread_join)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  108 | __gthrw(pthread_equal)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  109 | __gthrw(pthread_self)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  110 | __gthrw(pthread_detach)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  112 | __gthrw(pthread_cancel)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  114 | __gthrw(sched_yield)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  116 | __gthrw(pthread_mutex_lock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  117 | __gthrw(pthread_mutex_trylock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  119 | __gthrw(pthread_mutex_timedlock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/...