QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#422313#7303. City Unitedrzh123WA 221ms248396kbC++171.3kb2024-05-27 11:25:572024-05-27 11:25:58

Judging History

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

  • [2024-05-27 11:25:58]
  • 评测
  • 测评结果:WA
  • 用时:221ms
  • 内存:248396kb
  • [2024-05-27 11:25:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
class Graph{
private:
	static constexpr int N=55,P{4},D{13};
	int n,m,g[N],f[2][1<<D][1<<D],p3[N];
	inline void add(int &a,int b){
		if((a+=b)>=P) a-=P;
	}
public:
	int count(int N,vector<int> U,vector<int> V){
		n=N,m=U.size();
		for(int i{0};i<m;++i){
			int u{U[i]},v{V[i]};
			if(u>v) swap(u,v);
			g[v]|=1<<(v-u-1);
		}
		f[1][0][0]=f[1][1][0]=f[1][1][1]=1;
		int all{(1<<D)-1},ans{0};
		for(int i{1};i<=N;++i){
			for(int j{0};j<=all&&j<(1<<i);++j){
				for(int k{j};;k=(k-1)&j){
					int &me{f[i&1][j][k]};
					if(me){
						// printf("f[%d][%d][%d]=%d\n",i,j,k,me);
						if(i==N) add(ans,me);
						else{
							add(f[!(i&1)][(j<<1)&all][(k<<1)&all],me);
							if(!(g[i+1]&k)) add(f[!(i&1)][(j<<1|1)&all][(k<<1)&all],me);
							if(!(g[i+1]&(j^k))) add(f[!(i&1)][(j<<1|1)&all][(k<<1|1)&all],me);
						}
						me=0;
					}
					if(!k) break;
				}
			}
		}
		assert(ans&1);
		// cerr<<"ans="<<ans<<'\n';
		return (ans-1)/2;
	}
}sol;
int main(){
	cin.tie(0)->sync_with_stdio(0);
	// fstream cin("graph.in",cin.in),cout("graph.out",cout.out);
	int N,M;
	cin>>N>>M;
	vector<int> U(M),V(M);
	for(int i{0};i<M;++i) cin>>U[i]>>V[i];
	cout<<sol.count(N,U,V)<<'\n';
	return 0;
}

/*
RRR

RRG
RRB
RGR
RBR
GRR
BRR

RGG
RBB
GGR
BBR

GRG
BRG
GRB
BRB

GGG
BBB
*/

详细

Test #1:

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

input:

3 2
1 2
2 3

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

3 3
1 2
2 3
3 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 15ms
memory: 128240kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 20ms
memory: 129056kb

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 24ms
memory: 135404kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 24ms
memory: 143120kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #8:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: 0
Accepted
time: 27ms
memory: 128316kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 28ms
memory: 128280kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 20ms
memory: 128168kb

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #12:

score: 0
Accepted
time: 15ms
memory: 128292kb

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #13:

score: 0
Accepted
time: 221ms
memory: 248396kb

input:

50 30
12 11
47 46
29 28
40 41
29 30
27 28
15 14
1 2
46 45
8 9
16 15
34 33
50 49
45 44
13 14
42 41
35 34
20 19
18 17
48 49
48 47
2 3
23 24
11 10
31 30
40 39
36 35
7 6
23 22
4 3

output:

1

result:

ok 1 number(s): "1"

Test #14:

score: -100
Wrong Answer
time: 163ms
memory: 233896kb

input:

50 42
24 23
31 30
44 43
9 8
4 5
33 32
41 42
28 27
3 4
18 17
15 14
28 29
2 1
42 43
39 38
6 5
20 21
49 48
25 26
22 23
50 49
9 10
34 35
44 45
31 32
18 19
38 37
36 37
8 7
13 12
27 26
47 46
34 33
24 25
10 11
13 14
12 11
22 21
46 45
20 19
3 2
17 16

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'