답안 #908767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908767 2024-01-16T19:40:07 Z amirhoseinfar1385 Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1407 ms 269252 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn=18,maxm=387420489,mod=998244353;
int pd[maxm],t[(1<<maxn)],mar;
long long mypow(long long m,long long y){
    if(y==0){
        return 1;
    }
    long long p=mypow(m,(y>>1));
    p*=p;
    p%=mod;
    if(y&1){
        p*=m;
        p%=mod;
    }
    return p;
}

int ww(int a){
	if(a>=mod){
		a-=mod;
	}
	return a;
}

int back3(int a,int b){
	int ret=t[a]+2*t[b];
	return ret;
}
vector<int>tartib[maxn+2];
int adj[maxn],adja[maxn];
int n,m;

void aval(){
	mar=(1<<n)-1;
	int nx=1;
	for(int i=0;i<(1<<n);i++){
		int now=1,ret=0;
		for(int j=0;j<n;j++){
			if((i>>j)&1){
				ret+=now;
			}
			now*=3;
		}
		t[i]=ret;
		tartib[__builtin_popcount(i)].push_back(i);
	}
}

void solve(){
	for(int i=0;i<maxn+2;i++){
		for(auto xx:tartib[i]){
			for(int y=(mar^xx);y>0;y=(y-1)&(mar^xx)){
			int x=back3(xx,y);
			if(pd[x]==0){
				continue;
			}
			pair<int,int>now=make_pair(xx,y);
			for(int j=0;j<n;j++){
				if((now.second>>j)&1){
					now.second^=(1<<j);
					pair<int,int>fake=now;
					fake.first|=(1<<j);
					fake.second|=(adj[j]^(adj[j]&now.first));
					int tof=back3(fake.first,fake.second);
					pd[tof]+=pd[x];
					pd[tof]=ww(pd[tof]);
				}
			}
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	aval();	
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		adj[u]|=(1<<v);
		adj[v]|=(1<<u);
		adja[u]|=(1<<v);
	}
	pd[back3(0,(1<<n)-1)]=1;
	solve();
	int res=back3((1<<n)-1,0);
	pd[res]=1ll*pd[res]*m%mod;
	pd[res]=1ll*pd[res]*mypow(2,mod-2)%mod;
	cout<<pd[res]<<"\n";
}

Compilation message

amusementpark.cpp: In function 'void aval()':
amusementpark.cpp:36:6: warning: unused variable 'nx' [-Wunused-variable]
   36 |  int nx=1;
      |      ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2416 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2648 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2392 KB Output is correct
58 Correct 1 ms 2392 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2392 KB Output is correct
61 Correct 2 ms 2396 KB Output is correct
62 Correct 1 ms 2392 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2416 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2648 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2392 KB Output is correct
58 Correct 1 ms 2392 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2392 KB Output is correct
61 Correct 2 ms 2396 KB Output is correct
62 Correct 1 ms 2392 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 16 ms 5980 KB Output is correct
66 Correct 17 ms 6624 KB Output is correct
67 Correct 15 ms 5720 KB Output is correct
68 Correct 14 ms 5724 KB Output is correct
69 Correct 12 ms 5008 KB Output is correct
70 Correct 11 ms 4956 KB Output is correct
71 Correct 10 ms 4700 KB Output is correct
72 Correct 10 ms 4440 KB Output is correct
73 Correct 11 ms 4956 KB Output is correct
74 Correct 10 ms 4700 KB Output is correct
75 Correct 10 ms 4576 KB Output is correct
76 Correct 10 ms 4188 KB Output is correct
77 Correct 49 ms 16220 KB Output is correct
78 Correct 51 ms 14420 KB Output is correct
79 Correct 51 ms 14556 KB Output is correct
80 Correct 53 ms 11856 KB Output is correct
81 Correct 46 ms 12116 KB Output is correct
82 Correct 53 ms 11656 KB Output is correct
83 Correct 37 ms 9256 KB Output is correct
84 Correct 34 ms 8272 KB Output is correct
85 Correct 33 ms 8712 KB Output is correct
86 Correct 31 ms 8784 KB Output is correct
87 Correct 28 ms 8028 KB Output is correct
88 Correct 26 ms 7136 KB Output is correct
89 Correct 27 ms 8536 KB Output is correct
90 Correct 26 ms 8008 KB Output is correct
91 Correct 32 ms 7588 KB Output is correct
92 Correct 29 ms 6984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2416 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2648 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2392 KB Output is correct
58 Correct 1 ms 2392 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2392 KB Output is correct
61 Correct 2 ms 2396 KB Output is correct
62 Correct 1 ms 2392 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 16 ms 5980 KB Output is correct
66 Correct 17 ms 6624 KB Output is correct
67 Correct 15 ms 5720 KB Output is correct
68 Correct 14 ms 5724 KB Output is correct
69 Correct 12 ms 5008 KB Output is correct
70 Correct 11 ms 4956 KB Output is correct
71 Correct 10 ms 4700 KB Output is correct
72 Correct 10 ms 4440 KB Output is correct
73 Correct 11 ms 4956 KB Output is correct
74 Correct 10 ms 4700 KB Output is correct
75 Correct 10 ms 4576 KB Output is correct
76 Correct 10 ms 4188 KB Output is correct
77 Correct 49 ms 16220 KB Output is correct
78 Correct 51 ms 14420 KB Output is correct
79 Correct 51 ms 14556 KB Output is correct
80 Correct 53 ms 11856 KB Output is correct
81 Correct 46 ms 12116 KB Output is correct
82 Correct 53 ms 11656 KB Output is correct
83 Correct 37 ms 9256 KB Output is correct
84 Correct 34 ms 8272 KB Output is correct
85 Correct 33 ms 8712 KB Output is correct
86 Correct 31 ms 8784 KB Output is correct
87 Correct 28 ms 8028 KB Output is correct
88 Correct 26 ms 7136 KB Output is correct
89 Correct 27 ms 8536 KB Output is correct
90 Correct 26 ms 8008 KB Output is correct
91 Correct 32 ms 7588 KB Output is correct
92 Correct 29 ms 6984 KB Output is correct
93 Correct 782 ms 70596 KB Output is correct
94 Correct 691 ms 33532 KB Output is correct
95 Correct 688 ms 25900 KB Output is correct
96 Correct 820 ms 70672 KB Output is correct
97 Correct 766 ms 70672 KB Output is correct
98 Correct 766 ms 70928 KB Output is correct
99 Correct 123 ms 35920 KB Output is correct
100 Correct 134 ms 34128 KB Output is correct
101 Correct 159 ms 36948 KB Output is correct
102 Correct 164 ms 35416 KB Output is correct
103 Correct 208 ms 14652 KB Output is correct
104 Correct 224 ms 14928 KB Output is correct
105 Correct 280 ms 44676 KB Output is correct
106 Correct 381 ms 68484 KB Output is correct
107 Correct 653 ms 23848 KB Output is correct
108 Correct 776 ms 72836 KB Output is correct
109 Correct 1047 ms 161732 KB Output is correct
110 Correct 1407 ms 269252 KB Output is correct
111 Correct 166 ms 37484 KB Output is correct
112 Correct 116 ms 20848 KB Output is correct
113 Correct 137 ms 24608 KB Output is correct
114 Correct 92 ms 18556 KB Output is correct
115 Correct 78 ms 18772 KB Output is correct
116 Correct 90 ms 17644 KB Output is correct
117 Correct 74 ms 14932 KB Output is correct
118 Correct 85 ms 18768 KB Output is correct
119 Correct 79 ms 17532 KB Output is correct
120 Correct 88 ms 16688 KB Output is correct
121 Correct 79 ms 14928 KB Output is correct
122 Correct 429 ms 76544 KB Output is correct
123 Correct 487 ms 87584 KB Output is correct
124 Correct 452 ms 68852 KB Output is correct
125 Correct 418 ms 62548 KB Output is correct
126 Correct 391 ms 53496 KB Output is correct
127 Correct 339 ms 37340 KB Output is correct
128 Correct 271 ms 29220 KB Output is correct
129 Correct 231 ms 21484 KB Output is correct
130 Correct 202 ms 14596 KB Output is correct
131 Correct 271 ms 35572 KB Output is correct
132 Correct 255 ms 35632 KB Output is correct
133 Correct 260 ms 33516 KB Output is correct
134 Correct 239 ms 27464 KB Output is correct
135 Correct 263 ms 35668 KB Output is correct
136 Correct 268 ms 33532 KB Output is correct
137 Correct 288 ms 31464 KB Output is correct
138 Correct 265 ms 27776 KB Output is correct
139 Correct 267 ms 35536 KB Output is correct
140 Correct 256 ms 30804 KB Output is correct
141 Correct 261 ms 26708 KB Output is correct
142 Correct 1218 ms 172244 KB Output is correct
143 Correct 1143 ms 144924 KB Output is correct
144 Correct 1006 ms 95812 KB Output is correct
145 Correct 895 ms 76488 KB Output is correct
146 Correct 755 ms 55236 KB Output is correct
147 Correct 655 ms 23860 KB Output is correct
148 Correct 1236 ms 172108 KB Output is correct
149 Correct 1113 ms 123552 KB Output is correct
150 Correct 1259 ms 179440 KB Output is correct
151 Correct 730 ms 54912 KB Output is correct
152 Correct 753 ms 58832 KB Output is correct
153 Correct 796 ms 70592 KB Output is correct
154 Correct 769 ms 70464 KB Output is correct
155 Correct 766 ms 60908 KB Output is correct
156 Correct 757 ms 53988 KB Output is correct
157 Correct 783 ms 66484 KB Output is correct
158 Correct 812 ms 62324 KB Output is correct
159 Correct 790 ms 70504 KB Output is correct
160 Correct 786 ms 62416 KB Output is correct
161 Correct 755 ms 51908 KB Output is correct
162 Correct 807 ms 70420 KB Output is correct
163 Correct 772 ms 66584 KB Output is correct
164 Correct 770 ms 62192 KB Output is correct
165 Correct 747 ms 57976 KB Output is correct
166 Correct 767 ms 53828 KB Output is correct
167 Correct 754 ms 48668 KB Output is correct