QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#183796#61. Cut Cut Cut!maoyitingWA 1ms6256kbC++141.0kb2023-09-19 21:00:092023-09-19 21:00:09

Judging History

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

  • [2023-09-19 21:00:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6256kb
  • [2023-09-19 21:00:09]
  • 提交

answer

#include<bits/stdc++.h>
#define vec array<int,10>
using namespace std;
const int N=1e5+5,mod=998244353;
int n,m,d=20,x,y;
vector<int>v[N];
vec w;
mt19937 rnd(time(0));
vec operator+(vec a,vec b){
	for(int i=0;i<d;i++) a[i]=(a[i]+b[i])%mod;
	return a;
}
vec operator*(vec a,int b){
	for(int i=0;i<d;i++) a[i]=1ll*a[i]*b%mod;
	return a;
}
int qpow(int x,int n){
	int ans=1;
	for(;n;n>>=1,x=1ll*x*x%mod) if(n&1) ans=1ll*ans*x%mod;
	return ans;
}
struct B{
	int cnt;
	vec b[25];
	void insert(vec x){
		for(int i=d-1;i>=0;i--) if(x[i]){
			if(!b[i][i]){b[i]=x,cnt++;break;}
			else x=x+b[i]*(mod-1ll*x[i]*qpow(b[i][i],mod-2)%mod);
		}
	}
}in[N];
signed main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x,&y),v[x].push_back(y);
	for(int y:v[1]){
		for(int i=0;i<d;i++) w[i]=rnd();
		in[y].insert(w);
	}
	for(int x=2;x<=n;x++){
		printf("%d ",in[x].cnt);
		for(int y:v[x]){
			for(int i=0;i<d;i++) w[i]=0;
			for(int i=0;i<d;i++) w=w+in[x].b[i]*rnd();
			in[y].insert(w);
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6256kb

input:

3 3
1 2
1 3
2 3

output:

1 2 

result:

ok 2 number(s): "1 2"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 6112kb

input:

8 8
1 2
1 3
1 5
2 4
2 5
3 6
4 5
7 8

output:

1 1 1 3 1 0 1 

result:

wrong answer 4th numbers differ - expected: '2', found: '3'