QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#420422#2824. 找树300_205_205#Compile Error//C++203.2kb2024-05-24 18:02:342024-05-24 18:02:34

Judging History

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

  • [2024-05-24 18:02:34]
  • 评测
  • [2024-05-24 18:02:34]
  • 提交

answer

//#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define N 200005
#define mod 998244353
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define ls (rt<<1)
#define rs ((rt<<1)|1)
#define fi first
#define se second
#define INF 1e9
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
int qpow(int a,int b){
	int res=1;
	for(;b;b>>=1){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
	}
	return res;
}
/*int fac[N],ifac[N];
int C(int n,int m){
	if(m>n||m<0||n<0) return 0;
	return fac[n]*ifac[n-m]%mod*ifac[m]%mod;
}
void init(){
	fac[0]=1;
	for(int i=1;i<N;i++) fac[i]=fac[i-1]*i%mod;
	ifac[N-1]=qpow(fac[N-1],mod-2);
	for(int i=N-2;i>=0;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
}*/
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int x=0,t=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch-'0');
		ch=getchar();
	}
	return x*t;
}
inline void write(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
#define djq 998244353
int T,n,m,w,b[71][71],res[1<<12];
int op[12],v[71][71][1<<12];
const int inv2=(djq+1)/2;
inline int add(const int a,const int b){ return a+b>=djq?a+b-djq:a+b; }
inline int inc(const int a,const int b){ return a<b?a-b+djq:a-b; }
void FWT(int* a,int n,int opt){
	for(int i=1,lw=0;i<n;i<<=1,++lw){
		const int len=(i<<1);
		for(int j=0;j<n;j+=len){
			for(int k=0;k<i;++k){
				const int x=a[j+k],y=a[j+k+i];
				if(op[lw]==0){
					if(opt) a[j+k]=add(x,y);
					else a[j+k]=inc(x,y);
				}else if(op[lw]==1){
					if(opt) a[j+k+i]=add(x,y);
					else a[j+k+i]=inc(y,x);
				}else{
					a[j+k]=add(x,y),a[j+k+i]=inc(x,y);
					if(!opt) a[j+k]=1ll*a[j+k]*inv2%djq,a[j+k+i]=1ll*a[j+k+i]*inv2%djq;
				}
			}
		}
	}
}
int det(){
	int ans=1;
	for(int i=1;i<n;i++){
		int pos=0;
		for(int j=i;j<n;j++)
			if(b[j][i]){
				pos=j;
				break;
			}
		if(!pos){
			cout<<i<<"X"<<endl;
			return 0;
		}
		if(i!=pos){
			for(int j=i;j<n;j++) swap(b[i][j],b[pos][j]);
			ans=mod-ans;
		}
		ans=ans*b[i][i]%mod;int tmp=qpow(b[i][i],mod-2);
		for(int j=i;j<n;j++) b[i][j]=b[i][j]*tmp%mod;
		for(int j=i+1;j<n;j++){
			int tmp=b[j][i];
			for(int k=i;k<=n;k++) b[j][k]=(b[j][k]-tmp*b[i][k]%mod+mod)%mod;
		}
	}
	for(int i=1;i<n;i++) ans=ans*b[i][i]%mod;
	return ans;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;string s;cin>>s;w=s.size();
	for(int i=0;i<w;i++){
		if(s[i]=='&') op[i]=0;
		else if(s[i]=='|') op[i]=1;
		else op[i]=2;
	}
	for(int i=1;i<=m;i++){
		int x,y,u;cin>>x>>y>>u;
		(v[x][y][u]+=mod-1)%=mod;
		(v[y][x][u]+=mod-1)%=mod;
		v[x][x][u]++;v[y][y][u]++;
	}
	for(int j=1;j<=n;j++)
		for(int k=1;k<=n;k++)
			FWT(v[j][k],(1<<w),1);
	for(int i=0;i<(1<<w);i++){
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				b[j][k]=v[j][k][i];
		res[i]=det();
	}
	FWT(res,(1<<w),0);
	int ans=-1;
	for(int i=0;i<(1<<w);i++)
		if(res[i]) ans=i;
	cout<<ans<<endl;
	return 0;
}

詳細信息

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:5:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~