QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#288502#7925. ChayasPhantomThreshold#AC ✓3683ms69092kbC++171.3kb2023-12-22 19:31:292023-12-22 19:31:29

Judging History

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

  • [2023-12-22 19:31:29]
  • 评测
  • 测评结果:AC
  • 用时:3683ms
  • 内存:69092kb
  • [2023-12-22 19:31:29]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int maxn = 30;
const int maxm = 110000;
const int mask = (1<<24)+5;
const int mod  = 998244353;
inline void add(int &a,const int &b){ a+=b;if(a>=mod)a-=mod; }

int n,m,N;
int f[mask];
tuple<int,int,int>r[maxm];

int ac[maxn][maxn],ab[maxn][maxn];
vector< pair<int,int> >Eac[maxn],Eab[maxn];

int main()
{
	ios_base::sync_with_stdio(false);
	
	cin>>n>>m; N=1<<n;
	for(int i=1;i<=m;i++)
	{
		int a,b,c; cin>>a>>b>>c;
		r[i]=make_tuple(a,b,c);
	}
	
	for(int i=1;i<=m;i++)
	{
		auto [a,b,c]=r[i];
		ac[a][c]|=1<<(b-1);
		ac[c][a]|=1<<(b-1);
		ab[a][b]|=1<<(c-1);
		ab[c][b]|=1<<(a-1);
	}
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++)
	{
		if(ac[i][j])
		{
			Eac[i].emplace_back(j,ac[i][j]);
		}
		if(ab[i][j])
		{
			Eab[i].emplace_back(j,ab[i][j]);
		}
	}
	
	f[0]=1;
	for(int s=0;s<N;s++) if(f[s])
	{
		int no=0;
		vector<int>A,B;
		for(int i=1;i<=n;i++)
		{
			if(s>>(i-1)&1) A.push_back(i);
			else B.push_back(i);
		}
		for(auto i:B)
		{
			for(auto [j,tac]:Eac[i]) if( !(s>>(j-1)&1) )
			{
				no|=tac;
			}
		}
		for(auto i:A)
		{
			for(auto [j,tab]:Eab[i]) if( !(s>>(j-1)&1) )
			{
				no|=tab;
			}
		}
		for(auto i:B) if(!(no>>(i-1)&1))
		{
			add( f[s|1<<(i-1)], f[s] );
		}
	}
	cout<<f[N-1]<<endl;
		
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5648kb

input:

5 4
1 2 4
2 3 5
3 2 4
1 3 2

output:

4

result:

ok single line: '4'

Test #2:

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

input:

4 2
3 1 4
1 4 3

output:

0

result:

ok single line: '0'

Test #3:

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

input:

5 5
3 1 2
2 5 4
5 4 3
3 1 5
1 4 5

output:

2

result:

ok single line: '2'

Test #4:

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

input:

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

output:

6

result:

ok single line: '6'

Test #5:

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

input:

7 10
5 1 6
2 4 7
3 1 2
4 5 7
5 2 6
7 3 6
7 4 6
2 5 7
4 3 7
6 2 3

output:

8

result:

ok single line: '8'

Test #6:

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

input:

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

output:

28

result:

ok single line: '28'

Test #7:

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

input:

12 15
10 8 7
2 10 9
4 9 3
5 2 6
7 12 10
10 3 5
4 6 10
9 11 1
12 4 6
8 1 3
6 11 2
3 2 11
4 6 1
4 6 11
7 4 5

output:

128

result:

ok single line: '128'

Test #8:

score: 0
Accepted
time: 4ms
memory: 5408kb

input:

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

output:

115058708

result:

ok single line: '115058708'

Test #9:

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

input:

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

output:

131696

result:

ok single line: '131696'

Test #10:

score: 0
Accepted
time: 6ms
memory: 7104kb

input:

22 25
2 6 17
19 16 10
6 20 4
4 1 16
17 21 11
16 8 5
14 3 12
17 9 4
7 19 17
14 2 18
22 12 19
10 13 19
4 18 12
16 11 20
4 15 13
7 22 12
17 11 2
20 7 19
17 21 2
4 14 5
14 5 6
13 18 20
18 3 11
2 10 3
14 19 17

output:

188168263

result:

ok single line: '188168263'

Test #11:

score: 0
Accepted
time: 5ms
memory: 6664kb

input:

23 30
9 11 1
18 4 16
22 7 1
8 14 17
6 2 21
22 3 23
23 21 22
23 3 8
2 18 13
13 16 4
8 12 2
21 19 5
13 23 18
5 1 21
16 13 9
5 22 4
9 11 3
11 4 12
20 2 15
21 23 11
23 21 8
13 17 19
13 12 14
12 6 13
9 16 4
9 10 17
8 1 17
20 8 17
12 15 21
1 5 8

output:

131547430

result:

ok single line: '131547430'

Test #12:

score: 0
Accepted
time: 6ms
memory: 4076kb

input:

24 50
11 8 18
10 18 8
24 15 17
19 7 3
8 16 6
14 5 21
9 18 5
4 19 22
3 5 13
24 3 1
24 4 21
13 1 3
3 21 16
15 21 19
8 1 19
1 13 14
14 23 10
16 10 7
17 10 7
2 23 14
4 3 23
15 14 4
5 1 24
11 19 24
11 6 24
20 4 24
13 6 9
22 20 3
4 20 18
5 17 11
13 5 10
11 22 18
7 23 16
5 14 12
7 20 2
18 16 8
19 9 12
20 1...

output:

128488

result:

ok single line: '128488'

Test #13:

score: 0
Accepted
time: 3683ms
memory: 69092kb

input:

24 1
3 14 15

output:

256287771

result:

ok single line: '256287771'

Test #14:

score: 0
Accepted
time: 9ms
memory: 3648kb

input:

24 6072
1 2 3
1 2 4
5 2 1
6 2 1
7 2 1
8 2 1
1 2 9
1 2 10
1 2 11
12 2 1
1 2 13
14 2 1
15 2 1
16 2 1
17 2 1
1 2 18
1 2 19
1 2 20
1 2 21
1 2 22
23 2 1
24 2 1
2 3 1
4 3 1
5 3 1
1 3 6
1 3 7
1 3 8
9 3 1
1 3 10
1 3 11
1 3 12
1 3 13
1 3 14
1 3 15
1 3 16
17 3 1
18 3 1
19 3 1
20 3 1
21 3 1
1 3 22
1 3 23
24 3 ...

output:

0

result:

ok single line: '0'

Test #15:

score: 0
Accepted
time: 6ms
memory: 3944kb

input:

24 2024
1 3 4
1 3 6
1 3 10
1 3 11
1 3 13
1 3 15
1 3 22
1 3 23
1 3 24
1 4 23
1 4 24
1 5 2
1 5 12
1 6 4
1 6 13
1 6 15
1 6 23
1 6 24
1 7 2
1 7 5
1 7 12
1 8 3
1 8 4
1 8 6
1 8 10
1 8 11
1 8 13
1 8 14
1 8 15
1 8 16
1 8 18
1 8 21
1 8 22
1 8 23
1 8 24
1 9 3
1 9 4
1 9 6
1 9 8
1 9 10
1 9 11
1 9 13
1 9 14
1 9 ...

output:

2

result:

ok single line: '2'

Test #16:

score: 0
Accepted
time: 14ms
memory: 8700kb

input:

24 132
2 1 3
2 1 5
2 1 7
2 1 9
2 1 11
2 1 13
2 1 15
2 1 17
2 1 19
2 1 21
2 1 23
3 1 4
3 1 6
3 1 8
3 1 10
3 1 12
3 1 14
3 1 16
3 1 18
3 1 20
3 1 22
3 1 24
4 1 5
4 1 7
4 1 9
4 1 11
4 1 13
4 1 15
4 1 17
4 1 19
4 1 21
4 1 23
5 1 6
5 1 8
5 1 10
5 1 12
5 1 14
5 1 16
5 1 18
5 1 20
5 1 22
5 1 24
6 1 7
6 1 9...

output:

890206372

result:

ok single line: '890206372'

Test #17:

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

input:

3 1
3 1 2

output:

2

result:

ok single line: '2'

Test #18:

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

input:

4 2
1 3 2
4 3 1

output:

4

result:

ok single line: '4'

Test #19:

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

input:

5 10
3 5 2
5 4 3
1 5 3
3 4 2
3 4 1
5 1 2
4 5 2
4 5 1
2 1 3
4 1 2

output:

2

result:

ok single line: '2'

Test #20:

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

input:

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

output:

2

result:

ok single line: '2'

Test #21:

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

input:

10 20
4 5 1
4 3 7
10 6 1
4 8 7
1 5 8
3 2 8
3 4 6
4 3 9
10 8 7
5 9 10
9 4 1
6 2 7
8 4 1
3 6 5
5 8 7
7 8 1
4 9 8
1 4 10
2 4 1
7 9 5

output:

6

result:

ok single line: '6'

Test #22:

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

input:

21 30
15 17 16
10 5 7
13 8 11
20 8 10
14 17 7
6 19 12
14 17 5
4 10 5
4 6 14
6 16 5
20 12 1
17 19 4
11 8 10
4 16 12
12 9 21
19 10 20
17 10 6
7 21 8
20 17 1
17 12 8
19 1 8
1 18 21
5 8 1
18 14 16
6 16 20
13 14 9
20 19 6
16 1 21
8 14 13
21 13 4

output:

182365567

result:

ok single line: '182365567'

Test #23:

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

input:

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

output:

102840

result:

ok single line: '102840'

Test #24:

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

input:

13 75
4 1 3
6 1 11
3 7 9
2 10 4
10 9 11
11 1 10
2 6 1
4 13 6
3 9 13
10 13 7
5 4 2
8 13 10
12 6 13
3 8 13
8 5 2
3 11 8
11 1 4
3 11 5
9 13 2
12 4 2
10 4 6
2 4 1
2 8 3
13 5 1
7 5 10
12 11 3
2 10 9
3 12 2
8 9 2
6 7 13
12 1 2
11 6 4
13 10 2
4 9 12
12 5 4
11 7 9
8 9 10
11 6 5
1 8 12
4 7 3
10 13 11
5 7 3
1...

output:

2

result:

ok single line: '2'

Test #25:

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

input:

17 120
7 15 5
6 15 11
5 15 2
17 10 16
3 5 13
12 11 17
14 15 16
12 2 11
17 15 13
8 6 7
9 13 10
4 17 6
16 10 3
12 6 8
7 17 15
9 17 4
12 2 8
8 17 2
5 2 14
15 10 1
6 13 9
2 16 5
5 2 7
4 10 8
1 2 11
2 6 9
5 10 14
16 17 7
5 16 3
9 10 3
8 11 7
2 11 17
16 15 11
16 15 4
13 16 12
3 6 8
4 12 7
1 17 13
5 3 1
1 ...

output:

2

result:

ok single line: '2'

Test #26:

score: 0
Accepted
time: 6ms
memory: 5912kb

input:

24 300
14 18 7
13 22 1
7 10 1
19 1 13
5 19 7
7 14 15
17 23 22
4 1 16
11 21 9
15 13 1
22 5 17
4 2 22
12 2 7
8 19 3
24 23 13
15 20 3
8 13 1
16 1 19
3 18 21
8 21 18
14 23 24
13 21 4
10 5 8
6 16 5
14 13 10
4 1 13
11 10 19
16 20 7
19 15 17
24 6 17
5 2 7
4 18 6
3 20 18
14 1 3
22 5 12
13 23 7
5 12 8
13 2 3...

output:

4

result:

ok single line: '4'

Test #27:

score: 0
Accepted
time: 12ms
memory: 12336kb

input:

24 30
8 12 7
4 23 22
20 2 23
23 3 7
20 15 10
17 24 2
20 6 9
9 12 7
8 18 20
15 23 9
10 23 12
16 11 14
14 1 17
24 2 12
17 1 24
15 8 16
11 14 3
22 5 6
5 8 22
2 8 17
6 11 13
9 4 21
7 3 8
14 13 2
22 6 1
21 23 1
20 14 11
15 16 4
1 16 13
7 14 11

output:

34034054

result:

ok single line: '34034054'

Test #28:

score: 0
Accepted
time: 6ms
memory: 4284kb

input:

24 50
16 9 5
8 5 1
19 18 7
7 18 10
13 5 12
17 3 18
8 7 21
22 9 1
22 2 18
13 22 17
14 7 21
12 19 15
18 15 13
8 23 10
4 23 22
7 18 23
4 7 9
5 14 2
11 2 17
7 24 17
12 9 4
5 12 15
20 16 10
16 17 1
4 3 17
9 24 8
15 3 24
5 15 22
1 22 18
13 12 21
21 18 15
20 4 16
1 19 16
21 6 19
3 15 6
14 23 7
7 3 15
18 10...

output:

1517760

result:

ok single line: '1517760'

Test #29:

score: 0
Accepted
time: 6ms
memory: 5712kb

input:

24 100
23 4 11
2 20 18
5 2 10
10 20 24
2 20 16
9 11 13
12 4 15
22 23 11
14 17 22
15 18 19
12 21 16
18 13 1
22 6 11
15 4 6
4 23 1
20 7 4
22 8 21
19 21 24
22 20 14
12 10 6
3 15 9
12 13 9
20 4 16
15 17 22
8 2 3
24 21 18
10 21 14
3 14 15
5 12 7
5 18 9
12 17 13
19 7 20
23 17 11
9 10 5
18 7 8
11 6 5
19 21...

output:

3320

result:

ok single line: '3320'

Test #30:

score: 0
Accepted
time: 6ms
memory: 6052kb

input:

24 100
7 17 19
5 20 9
16 24 15
11 9 2
4 2 20
7 24 20
3 8 13
23 8 17
15 10 13
1 22 17
4 13 20
18 11 5
5 7 16
7 14 3
4 5 1
4 8 13
10 18 16
7 12 8
20 17 16
17 9 19
3 14 19
4 2 23
10 17 16
22 5 1
7 8 20
14 22 11
5 13 18
22 24 3
5 11 14
17 19 1
3 14 18
13 2 7
2 7 4
2 6 11
16 7 19
14 6 13
20 11 18
12 17 4...

output:

9648

result:

ok single line: '9648'

Test #31:

score: 0
Accepted
time: 3ms
memory: 5768kb

input:

24 300
14 9 1
11 12 17
6 24 1
20 5 14
24 4 10
23 19 22
21 20 1
14 6 17
22 24 14
21 5 13
12 19 22
21 7 6
23 3 19
1 8 23
14 6 11
7 19 8
3 15 20
7 15 22
20 24 16
13 24 1
3 11 20
21 20 17
10 18 21
1 19 6
8 12 7
2 21 18
19 15 6
20 12 11
24 12 17
8 21 4
15 21 14
15 19 17
12 10 3
8 19 11
20 15 9
5 18 7
18 ...

output:

2

result:

ok single line: '2'

Test #32:

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

input:

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

output:

4

result:

ok single line: '4'

Test #33:

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

input:

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

output:

2

result:

ok single line: '2'

Test #34:

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

input:

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

output:

2

result:

ok single line: '2'

Test #35:

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

input:

23 300
10 22 7
23 5 10
7 8 16
12 16 15
9 21 16
18 10 2
4 2 22
19 21 11
3 1 23
11 12 2
13 10 14
15 7 8
18 4 17
20 21 17
20 12 4
5 2 22
19 5 20
8 5 9
12 21 4
15 6 9
19 2 11
20 12 10
7 22 19
15 16 18
5 10 2
11 5 17
12 21 3
15 22 2
7 1 21
7 12 11
19 2 13
15 3 5
2 5 20
18 1 16
13 10 3
10 19 8
14 4 11
15 ...

output:

8

result:

ok single line: '8'

Test #36:

score: 0
Accepted
time: 6ms
memory: 3640kb

input:

24 500
24 23 9
14 5 13
13 19 10
10 14 11
3 9 10
22 23 10
9 5 18
12 11 21
13 8 9
3 8 7
24 13 4
5 7 10
1 21 8
12 13 16
22 14 5
15 18 13
9 7 3
3 16 22
12 16 22
1 7 8
12 5 14
11 7 10
24 14 7
19 10 1
2 23 17
12 15 19
19 23 7
10 21 23
20 19 16
4 8 11
7 16 17
15 8 22
11 3 10
12 3 8
14 8 22
15 13 19
12 15 1...

output:

2

result:

ok single line: '2'

Test #37:

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

input:

3 3
1 2 3
3 1 2
1 3 2

output:

0

result:

ok single line: '0'

Test #38:

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

input:

10 24
9 7 8
7 2 4
8 10 2
7 10 4
3 4 6
7 6 4
7 8 4
5 2 7
4 3 2
9 4 10
5 7 9
9 4 3
2 3 10
4 7 8
2 6 4
8 10 3
6 2 8
6 9 1
3 1 4
6 7 9
2 5 10
5 2 8
5 9 8
6 4 1

output:

0

result:

ok single line: '0'

Test #39:

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

input:

12 35
6 11 10
11 12 1
9 10 8
9 2 5
2 4 9
1 10 8
2 9 7
10 11 3
7 9 1
8 1 10
11 10 1
6 1 8
9 8 7
5 11 9
7 8 3
3 12 9
3 4 10
5 9 6
3 11 5
8 1 2
7 10 4
9 3 1
5 11 1
3 5 11
2 12 7
1 5 7
9 4 6
3 8 12
8 9 12
12 1 6
7 2 10
11 12 3
8 7 4
3 5 1
2 10 11

output:

0

result:

ok single line: '0'

Test #40:

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

input:

15 50
10 8 14
9 8 4
1 8 15
2 13 1
6 12 14
3 4 8
15 4 9
2 12 15
7 5 11
8 5 12
12 11 3
15 14 3
7 1 5
9 3 14
6 9 15
4 15 2
14 12 15
10 9 1
11 15 8
13 9 1
9 4 3
9 4 10
9 2 1
11 3 6
2 4 15
12 7 10
7 4 11
15 7 2
8 3 12
1 9 11
1 5 13
11 12 13
4 1 10
14 6 5
10 12 9
13 6 15
10 14 7
7 1 12
3 7 8
1 4 11
8 4 11...

output:

0

result:

ok single line: '0'

Test #41:

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

input:

17 120
11 1 2
2 14 10
1 3 10
17 8 4
17 12 14
3 6 8
13 6 4
4 9 6
11 13 3
8 7 4
10 1 12
11 7 12
6 10 2
2 14 9
4 2 1
8 6 13
5 11 17
15 3 6
12 14 6
6 13 10
3 5 7
12 11 17
12 10 14
16 14 5
7 4 16
9 10 14
14 4 13
12 17 9
8 10 3
14 4 9
14 12 3
6 9 5
16 17 2
16 13 17
5 13 7
5 14 11
4 9 15
5 16 15
9 1 17
6 1...

output:

0

result:

ok single line: '0'

Test #42:

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

input:

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

output:

0

result:

ok single line: '0'

Test #43:

score: 0
Accepted
time: 3ms
memory: 5884kb

input:

23 300
20 1 13
2 17 6
21 17 9
11 6 2
15 13 7
20 5 6
20 2 17
20 14 18
10 18 14
17 10 11
15 22 2
1 14 13
20 6 1
16 6 13
2 14 1
7 19 14
2 23 12
10 14 13
13 7 9
10 21 3
14 17 9
15 16 10
10 9 2
12 13 9
8 1 14
14 21 17
2 5 17
15 17 1
8 16 19
8 22 4
10 5 2
3 21 11
22 2 7
19 7 10
2 23 15
22 11 7
10 8 9
10 2...

output:

0

result:

ok single line: '0'

Test #44:

score: 0
Accepted
time: 6ms
memory: 3592kb

input:

24 1600
7 16 18
10 1 19
24 3 1
14 15 5
24 20 23
24 13 3
2 8 5
14 24 12
18 11 10
13 15 3
17 22 3
17 1 18
4 21 2
11 17 24
19 20 15
22 21 13
17 5 20
23 3 14
13 22 17
2 24 4
3 21 23
12 13 7
15 7 17
18 7 10
11 7 4
14 4 17
3 19 24
3 15 8
1 11 2
2 1 17
6 17 10
18 12 15
16 2 22
2 21 5
5 14 13
16 1 6
16 24 1...

output:

0

result:

ok single line: '0'

Test #45:

score: 0
Accepted
time: 3ms
memory: 3540kb

input:

24 1200
18 11 14
19 18 17
10 21 1
20 24 3
11 15 13
16 22 9
3 11 17
8 20 24
5 15 7
11 5 2
21 5 15
8 13 19
19 22 10
22 4 8
8 23 10
9 20 5
15 9 24
12 20 10
2 12 15
9 18 10
19 23 15
23 14 20
7 22 21
12 7 18
14 24 6
8 19 20
12 7 15
21 3 9
10 6 7
21 5 4
19 23 4
7 6 5
6 3 18
15 21 12
10 3 22
10 18 24
18 21...

output:

0

result:

ok single line: '0'

Test #46:

score: 0
Accepted
time: 7ms
memory: 3712kb

input:

24 5000
20 2 3
12 6 9
2 17 18
12 23 14
12 8 21
18 15 4
8 15 20
11 19 10
3 2 19
7 19 10
5 16 6
15 17 20
24 11 14
18 22 23
22 2 11
20 18 17
7 14 18
20 12 14
24 2 11
21 18 7
3 19 20
10 7 16
24 15 2
7 11 6
21 4 20
8 2 6
10 23 12
2 21 22
18 8 9
6 12 20
21 11 17
16 12 3
14 19 17
1 4 9
18 24 12
10 7 12
1 2...

output:

0

result:

ok single line: '0'

Test #47:

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

input:

5 4
1 2 4
2 3 5
3 2 4
1 3 2

output:

4

result:

ok single line: '4'

Test #48:

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

input:

4 2
3 1 4
1 4 3

output:

0

result:

ok single line: '0'

Test #49:

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

input:

16 100
3 12 5
4 9 16
6 11 8
4 11 8
2 9 4
6 14 3
5 1 3
8 12 4
4 11 2
6 14 16
8 15 4
4 11 3
6 11 10
8 1 5
4 1 10
5 14 2
13 14 5
4 7 2
4 12 16
10 14 5
8 7 4
10 9 6
3 7 5
4 15 10
5 7 10
10 7 6
6 9 2
8 9 4
6 14 13
2 12 5
2 12 6
6 1 16
13 9 6
2 7 6
6 7 13
5 9 16
6 14 8
6 11 3
2 11 5
4 14 8
4 11 10
4 1 3
6...

output:

43545600

result:

ok single line: '43545600'

Test #50:

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

input:

18 150
3 2 5
13 1 9
12 8 3
3 16 15
18 8 5
9 11 12
3 16 10
3 1 10
18 16 6
9 1 5
18 8 10
15 11 18
5 11 3
15 11 9
13 17 18
3 7 10
18 1 13
5 7 18
14 2 3
3 17 5
10 4 18
3 1 12
12 17 3
13 8 18
13 8 9
9 16 6
3 2 13
10 7 9
5 8 3
12 8 18
3 11 6
10 1 9
9 2 5
3 7 6
18 17 10
14 4 18
10 8 3
12 16 9
15 17 18
13 1...

output:

442064894

result:

ok single line: '442064894'

Test #51:

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

input:

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

output:

894107272

result:

ok single line: '894107272'

Test #52:

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

input:

23 425
12 14 21
9 19 4
2 14 17
20 7 2
17 6 23
22 7 23
17 18 4
1 19 2
12 5 13
2 14 20
4 5 13
23 18 9
21 15 23
4 15 1
21 14 8
12 18 17
12 11 10
13 18 2
13 18 12
13 7 2
23 19 16
16 14 23
9 6 12
12 18 21
22 18 4
20 6 8
16 6 12
21 5 3
23 19 17
12 18 16
21 19 2
4 14 20
21 5 12
8 18 16
2 14 1
2 15 17
22 5 ...

output:

157789582

result:

ok single line: '157789582'

Test #53:

score: 0
Accepted
time: 4ms
memory: 6376kb

input:

24 512
3 20 17
4 9 14
7 24 14
23 16 7
3 21 14
23 6 22
4 9 11
3 9 17
8 15 1
2 20 14
18 16 14
1 16 10
18 21 10
11 15 4
2 16 14
7 20 14
5 9 19
4 13 5
10 9 2
18 15 12
4 24 11
22 13 14
19 21 14
1 15 17
7 21 5
3 24 10
18 13 8
12 21 1
19 24 23
10 20 1
5 15 2
3 15 5
19 24 5
18 9 5
1 15 12
1 13 14
10 20 18
1...

output:

205389569

result:

ok single line: '205389569'

Test #54:

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

input:

16 100
16 15 11
3 12 15
3 8 16
3 14 16
15 14 7
9 14 15
15 11 8
15 11 1
16 11 3
1 3 8
7 9 16
10 6 5
14 12 3
5 6 13
2 5 10
12 11 9
15 12 11
15 9 3
3 9 16
6 4 2
15 12 7
3 8 11
8 11 14
3 9 11
14 7 1
15 3 1
7 11 15
8 11 16
4 5 10
7 9 14
16 15 12
12 9 8
13 6 4
2 5 6
11 7 3
14 12 11
13 10 4
3 8 12
3 9 14
1...

output:

32032

result:

ok single line: '32032'

Test #55:

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

input:

18 150
3 9 11
3 4 18
16 14 11
14 11 1
2 5 6
2 7 13
7 6 2
7 6 5
18 16 11
10 15 17
3 9 16
10 6 5
13 8 7
15 7 2
15 10 8
1 3 16
6 12 15
8 6 2
17 10 5
17 12 2
14 9 4
5 8 15
13 12 8
15 13 6
10 7 5
2 10 17
1 4 11
2 5 17
11 4 3
13 6 2
17 6 2
17 8 2
14 4 1
7 8 10
17 10 8
2 5 8
17 13 7
8 12 15
18 11 1
13 10 6...

output:

175032

result:

ok single line: '175032'

Test #56:

score: 0
Accepted
time: 3ms
memory: 6120kb

input:

22 350
21 8 6
10 8 4
21 3 2
9 14 17
10 5 3
21 4 2
5 10 21
18 8 2
4 6 21
3 6 8
18 10 1
21 6 1
6 7 18
16 4 3
1 3 7
6 11 18
1 2 4
18 10 2
1 10 16
8 6 5
16 6 2
10 7 6
11 4 3
7 11 16
18 10 6
18 7 3
3 4 5
21 5 1
18 7 1
4 11 16
3 4 18
18 16 5
18 6 3
11 10 5
16 3 1
17 15 14
19 20 22
1 2 5
7 10 18
9 12 17
2 ...

output:

1989680

result:

ok single line: '1989680'

Test #57:

score: 0
Accepted
time: 4ms
memory: 6064kb

input:

23 420
3 4 15
23 18 2
23 22 5
18 22 23
6 20 22
22 20 19
5 18 20
2 4 21
1 10 12
15 3 2
19 4 3
15 20 22
21 20 11
20 14 6
17 18 21
17 15 2
14 6 2
2 6 19
20 17 15
21 6 3
3 4 18
20 18 6
16 10 8
4 17 19
6 18 23
2 18 22
5 6 15
22 21 17
2 6 18
17 3 2
5 17 18
4 14 22
2 5 6
2 3 18
17 19 21
4 20 21
6 15 21
20 ...

output:

1961256

result:

ok single line: '1961256'

Test #58:

score: 0
Accepted
time: 8ms
memory: 4620kb

input:

24 512
5 17 19
3 6 10
2 5 13
2 14 18
23 10 1
18 16 2
4 14 18
7 11 12
19 13 7
24 9 3
20 16 14
7 17 18
17 7 5
17 14 8
11 12 16
20 19 17
11 12 20
23 10 9
13 11 5
19 16 2
21 14 13
16 7 4
13 11 7
24 10 1
17 18 19
2 18 20
21 18 5
2 4 13
5 16 20
16 18 20
19 16 14
21 19 7
13 16 18
18 13 12
21 18 8
17 8 7
1 ...

output:

5230016

result:

ok single line: '5230016'