#include<bits/stdc++.h>
#define MAXN 600007
using namespace std;
const int mod=998244353;
int n,m,a[4000],b[4000];
int perm[20],ans;
set< pair< vector<int> , int> > s;
void check(){
int c=0;
vector<int> w;
for(int i=1;i<=m;i++){
if(perm[a[i]]>perm[b[i]]){
c++; w.push_back(1);
}else{
w.push_back(0);
}
}
s.insert({w,c});
}
int main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
cin>>a[i]>>b[i];
}
for(int i=1;i<=n;i++)perm[i]=i;
do{
check();
}while(next_permutation(perm+1,perm+n+1));
for(pair<vector<int>,int> curr:s){
ans+=curr.second; ans%=mod;
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
440 KB |
Output is correct |
15 |
Correct |
0 ms |
440 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
432 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
440 KB |
Output is correct |
15 |
Correct |
0 ms |
440 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
432 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
348 KB |
Output is correct |
29 |
Correct |
2 ms |
604 KB |
Output is correct |
30 |
Correct |
3 ms |
860 KB |
Output is correct |
31 |
Correct |
3 ms |
1312 KB |
Output is correct |
32 |
Correct |
5 ms |
348 KB |
Output is correct |
33 |
Correct |
7 ms |
344 KB |
Output is correct |
34 |
Correct |
12 ms |
600 KB |
Output is correct |
35 |
Correct |
15 ms |
1008 KB |
Output is correct |
36 |
Correct |
20 ms |
2172 KB |
Output is correct |
37 |
Correct |
25 ms |
4708 KB |
Output is correct |
38 |
Correct |
37 ms |
8468 KB |
Output is correct |
39 |
Correct |
37 ms |
348 KB |
Output is correct |
40 |
Correct |
62 ms |
444 KB |
Output is correct |
41 |
Correct |
96 ms |
592 KB |
Output is correct |
42 |
Correct |
118 ms |
1108 KB |
Output is correct |
43 |
Correct |
171 ms |
5200 KB |
Output is correct |
44 |
Correct |
219 ms |
10324 KB |
Output is correct |
45 |
Correct |
283 ms |
24400 KB |
Output is correct |
46 |
Correct |
330 ms |
49748 KB |
Output is correct |
47 |
Correct |
439 ms |
85584 KB |
Output is correct |
48 |
Correct |
56 ms |
348 KB |
Output is correct |
49 |
Correct |
99 ms |
964 KB |
Output is correct |
50 |
Correct |
140 ms |
1060 KB |
Output is correct |
51 |
Correct |
115 ms |
856 KB |
Output is correct |
52 |
Correct |
452 ms |
348 KB |
Output is correct |
53 |
Correct |
785 ms |
600 KB |
Output is correct |
54 |
Correct |
1177 ms |
1364 KB |
Output is correct |
55 |
Correct |
1682 ms |
5788 KB |
Output is correct |
56 |
Correct |
2140 ms |
34388 KB |
Output is correct |
57 |
Correct |
2909 ms |
97296 KB |
Output is correct |
58 |
Execution timed out |
3055 ms |
216828 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
440 KB |
Output is correct |
15 |
Correct |
0 ms |
440 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
432 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
348 KB |
Output is correct |
29 |
Correct |
2 ms |
604 KB |
Output is correct |
30 |
Correct |
3 ms |
860 KB |
Output is correct |
31 |
Correct |
3 ms |
1312 KB |
Output is correct |
32 |
Correct |
5 ms |
348 KB |
Output is correct |
33 |
Correct |
7 ms |
344 KB |
Output is correct |
34 |
Correct |
12 ms |
600 KB |
Output is correct |
35 |
Correct |
15 ms |
1008 KB |
Output is correct |
36 |
Correct |
20 ms |
2172 KB |
Output is correct |
37 |
Correct |
25 ms |
4708 KB |
Output is correct |
38 |
Correct |
37 ms |
8468 KB |
Output is correct |
39 |
Correct |
37 ms |
348 KB |
Output is correct |
40 |
Correct |
62 ms |
444 KB |
Output is correct |
41 |
Correct |
96 ms |
592 KB |
Output is correct |
42 |
Correct |
118 ms |
1108 KB |
Output is correct |
43 |
Correct |
171 ms |
5200 KB |
Output is correct |
44 |
Correct |
219 ms |
10324 KB |
Output is correct |
45 |
Correct |
283 ms |
24400 KB |
Output is correct |
46 |
Correct |
330 ms |
49748 KB |
Output is correct |
47 |
Correct |
439 ms |
85584 KB |
Output is correct |
48 |
Correct |
56 ms |
348 KB |
Output is correct |
49 |
Correct |
99 ms |
964 KB |
Output is correct |
50 |
Correct |
140 ms |
1060 KB |
Output is correct |
51 |
Correct |
115 ms |
856 KB |
Output is correct |
52 |
Correct |
452 ms |
348 KB |
Output is correct |
53 |
Correct |
785 ms |
600 KB |
Output is correct |
54 |
Correct |
1177 ms |
1364 KB |
Output is correct |
55 |
Correct |
1682 ms |
5788 KB |
Output is correct |
56 |
Correct |
2140 ms |
34388 KB |
Output is correct |
57 |
Correct |
2909 ms |
97296 KB |
Output is correct |
58 |
Execution timed out |
3055 ms |
216828 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
440 KB |
Output is correct |
15 |
Correct |
0 ms |
440 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
432 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
348 KB |
Output is correct |
29 |
Correct |
2 ms |
604 KB |
Output is correct |
30 |
Correct |
3 ms |
860 KB |
Output is correct |
31 |
Correct |
3 ms |
1312 KB |
Output is correct |
32 |
Correct |
5 ms |
348 KB |
Output is correct |
33 |
Correct |
7 ms |
344 KB |
Output is correct |
34 |
Correct |
12 ms |
600 KB |
Output is correct |
35 |
Correct |
15 ms |
1008 KB |
Output is correct |
36 |
Correct |
20 ms |
2172 KB |
Output is correct |
37 |
Correct |
25 ms |
4708 KB |
Output is correct |
38 |
Correct |
37 ms |
8468 KB |
Output is correct |
39 |
Correct |
37 ms |
348 KB |
Output is correct |
40 |
Correct |
62 ms |
444 KB |
Output is correct |
41 |
Correct |
96 ms |
592 KB |
Output is correct |
42 |
Correct |
118 ms |
1108 KB |
Output is correct |
43 |
Correct |
171 ms |
5200 KB |
Output is correct |
44 |
Correct |
219 ms |
10324 KB |
Output is correct |
45 |
Correct |
283 ms |
24400 KB |
Output is correct |
46 |
Correct |
330 ms |
49748 KB |
Output is correct |
47 |
Correct |
439 ms |
85584 KB |
Output is correct |
48 |
Correct |
56 ms |
348 KB |
Output is correct |
49 |
Correct |
99 ms |
964 KB |
Output is correct |
50 |
Correct |
140 ms |
1060 KB |
Output is correct |
51 |
Correct |
115 ms |
856 KB |
Output is correct |
52 |
Correct |
452 ms |
348 KB |
Output is correct |
53 |
Correct |
785 ms |
600 KB |
Output is correct |
54 |
Correct |
1177 ms |
1364 KB |
Output is correct |
55 |
Correct |
1682 ms |
5788 KB |
Output is correct |
56 |
Correct |
2140 ms |
34388 KB |
Output is correct |
57 |
Correct |
2909 ms |
97296 KB |
Output is correct |
58 |
Execution timed out |
3055 ms |
216828 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |