RE求助
  • 板块灌水区
  • 楼主absolute_value
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/11/23 08:40
  • 上次更新2024/11/23 11:15:29
查看原帖
RE求助
1067907
absolute_value楼主2024/11/23 08:40

P10102

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int m=998244353;
class Matrix {
	public:
		int x[3000][3000];
		int width,height;
		Matrix():width(1),height(1){};
		Matrix(int x,int y):width(x),height(y){};
		Matrix operator *(Matrix a) {
			Matrix b(a.width,height);
			for(int i=0;i<a.width;i++){
				for(int j=0;j<height;j++){
					b.x[i][j]=0;
					for(int k=0;k<width;k++){
						b.x[i][j]+=x[i][k]*a.x[k][j];
						b.x[i][j]%=m;
					}
				}
			}
			return b;
		}
};
Matrix a,b,c,d,e;
signed main() {
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		a.width=a.height=b.width=b.height=c.width=c.height=d.height=e.height=n;
		d.width=e.width=1;
		for(int i=0;i<n;i++){
			d.x[0][i]=e.x[0][i]=rand();
			for(int j=0;j<n;j++){
				cin>>a.x[i][j];
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>b.x[i][j];
			}
		}
		b=a*b;
		d=d*b;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>c.x[i][j];
			}
		}
		e=e*c;
		bool flag=true;
		for(int i=0;i<n;i++){
			if(d.x[0][i]!=e.x[0][i]){
				flag=false;
				break;
			}
		}
		cout<<(flag?"Yes\n":"No\n");
	}
	return 0;
}

RT,运行后返回Process exited after 1.813 seconds with return value 3221225725(交洛谷上面是TLE)

2024/11/23 08:40
加载中...