QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#183795#61. Cut Cut Cut!maoyitingWA 64ms9324kbC++141.0kb2023-09-19 20:59:052023-09-19 20:59:07

Judging History

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

  • [2023-09-19 20:59:07]
  • 评测
  • 测评结果:WA
  • 用时:64ms
  • 内存:9324kb
  • [2023-09-19 20:59:05]
  • 提交

answer

#include<bits/stdc++.h>
#define vec array<int,10>
using namespace std;
const int N=1e5+5,mod=998244353;
int n,m,d=10,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[15];
	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: 6544kb

input:

3 3
1 2
1 3
2 3

output:

1 2 

result:

ok 2 number(s): "1 2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 7068kb

input:

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

output:

1 1 1 2 1 0 0 

result:

ok 7 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 8120kb

input:

20 70
3 18
14 16
8 10
5 7
2 14
10 18
14 15
17 19
18 20
4 6
3 20
16 17
6 7
6 17
6 19
5 19
12 16
18 19
13 19
13 19
8 9
15 17
8 9
1 7
5 18
6 14
2 17
4 20
12 16
9 20
2 7
6 19
12 13
6 7
1 5
19 20
9 14
13 14
16 17
17 20
9 16
1 6
12 15
2 8
1 3
4 19
1 4
9 13
14 15
15 20
17 18
14 19
13 14
2 5
7 14
7 18
10 16...

output:

0 1 1 1 2 4 0 1 0 0 1 2 5 3 3 4 6 6 6 

result:

ok 19 numbers

Test #4:

score: 0
Accepted
time: 2ms
memory: 8132kb

input:

100 1000
26 51
88 93
96 97
55 92
49 60
89 92
81 84
87 95
80 96
33 81
48 73
12 91
71 86
89 90
33 78
13 100
60 89
45 48
98 100
10 43
40 50
13 29
96 99
83 92
84 85
20 39
97 100
41 76
51 71
28 61
2 80
57 89
58 83
10 30
21 85
1 21
86 95
1 65
66 78
57 91
30 41
46 72
59 64
59 79
17 33
68 79
45 78
8 91
12 7...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 1 1 1 1 1 1 2 3 0 1 3 3 0 2 4 1 4 3 2 1 3 1 4 4 3 2 3 4 4 3 4 4 4 5 2 5 3 7 7 5 6 4 7 7 6 7 6 4 5 7 7 7 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 

result:

ok 99 numbers

Test #5:

score: 0
Accepted
time: 46ms
memory: 9136kb

input:

2000 50000
74 1663
975 1279
632 1796
1137 1386
121 1557
627 678
482 1961
1554 1654
1 388
1940 1971
512 1665
675 1279
946 1834
1473 1645
732 1620
169 552
1996 1997
1549 1982
1678 1788
1282 1831
1084 1455
1166 1566
380 854
1087 1263
763 1569
234 864
1166 1475
47 1680
194 350
1939 1949
8 1028
357 1234
...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 1999 numbers

Test #6:

score: 0
Accepted
time: 45ms
memory: 9324kb

input:

2000 50000
1078 1288
298 1803
1715 1954
547 1412
1060 1730
1077 1855
1685 1947
1416 1804
1469 1737
1637 1888
1048 1462
162 237
1655 1885
492 963
1 811
1598 1948
261 1353
441 1531
1829 1838
170 1189
1848 1996
705 1909
931 1724
493 574
1146 1412
1062 1730
102 206
49 615
1777 1931
106 1808
1545 1789
11...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 1999 numbers

Test #7:

score: 0
Accepted
time: 43ms
memory: 7472kb

input:

2000 50000
347 505
1265 1885
1170 1773
1126 1942
375 1060
1463 1622
1661 1972
321 1956
69 1968
518 1896
1348 1654
166 1060
1 907
1520 1733
3 1085
1886 1954
1532 1603
821 1248
654 1899
1477 1595
792 1504
410 496
1421 1955
77 1201
1410 1442
1974 1981
1081 1470
718 904
687 1275
1693 1977
2 526
398 585
...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 1999 numbers

Test #8:

score: -100
Wrong Answer
time: 64ms
memory: 9152kb

input:

2000 50000
1097 1906
350 533
1144 1809
49 1971
1498 1655
261 808
716 834
40 60
692 1664
292 602
1383 1728
1127 1395
1441 1602
761 1213
1671 1875
978 1683
505 646
798 1663
1359 1542
1960 1961
1258 1800
121 554
1 742
1403 1566
769 1397
475 1576
625 806
1468 1611
1943 1972
181 769
1816 1913
1 1846
290 ...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

wrong answer 1091st numbers differ - expected: '12', found: '10'