답안 #696744

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
696744 2023-02-07T06:53:43 Z vjudge1 Amusement Park (CEOI19_amusementpark) C++14
100 / 100
2700 ms 1800 KB
#include<bits/stdc++.h>
#define ll long long
#define lll __int128
#define db double
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define vi vector<int>
using namespace std;
namespace IO
{
	const int SZ=1<<20;
	char gchar()
	{
	    static char buf[SZ];
	    static int i=SZ;
	    if(i==SZ)i=0,fread(buf,1,SZ,stdin);
	    return buf[i++];
	}
	void pchar(char c)
	{
	    static char buf[SZ];
	    static int i=0;
	    if(c)buf[i++]=c;
	    if(!c||i==SZ)fwrite(buf,1,i,stdout),i=0;
	}
	void pstr(string s,char end='\n')
	{
		for(char c:s)pchar(c);
		pchar(end);
	}
	template<typename T>void read(T &x)
	{
	    x=0;int f=1;
	    static char c;
	    while((c=gchar())>'9'||c<'0')if(c=='-')f=-1;
	    x=c-'0';
	    while((c=gchar())>='0'&&c<='9')
			x=(x<<1)+(x<<3)+(c^48);
		x*=f;
	}
	template<typename T,typename ...Args>void read(T &x,Args&...args){read(x),read(args...);}
	template<typename T>void i_write(T x)
	{
	    if(x>9)i_write(x/10);
	    pchar(x%10+'0');
	}
	template<typename T>void write(T x,char end='\n')
	{
	    if(x<0)pchar('-'),x=-x;
	    if(x>9)i_write(x/10);
	    pchar(x%10+'0');
	    pchar(end);
	}
}
using IO::read;
using IO::write;
const int N=400,mod=998244353,inv2=(mod+1)>>1;
int n,m,x[N],y[N],f[1<<18];
bool flg[1<<18];
int main()
{
	read(n,m);
	for(int i=1;i<=m;i++)read(x[i],y[i]);
	for(int msk=0;msk<(1<<n);msk++)
		for(int i=1;i<=m;i++)
			if((msk&(1<<x[i]-1))&&(msk&(1<<y[i]-1)))flg[msk]=1;
	f[0]=1;
	for(int msk=1;msk<(1<<n);msk++)
		for(int s=msk;s;s=msk&(s-1))
			if(!flg[s])f[msk]=(0ll+f[msk]+(__builtin_popcount(s)&1?1:-1)*f[msk^s]+mod)%mod;
	printf("%lld",1ll*m*inv2%mod*f[(1<<n)-1]%mod);
	IO::pchar(0);
	return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:68:20: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   68 |    if((msk&(1<<x[i]-1))&&(msk&(1<<y[i]-1)))flg[msk]=1;
      |                ~~~~^~
amusementpark.cpp:68:39: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   68 |    if((msk&(1<<x[i]-1))&&(msk&(1<<y[i]-1)))flg[msk]=1;
      |                                   ~~~~^~
amusementpark.cpp: In function 'char IO::gchar()':
amusementpark.cpp:18:24: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |      if(i==SZ)i=0,fread(buf,1,SZ,stdin);
      |                   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 316 KB Output is correct
28 Correct 0 ms 316 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 316 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 320 KB Output is correct
47 Correct 1 ms 320 KB Output is correct
48 Correct 1 ms 316 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 320 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 320 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 312 KB Output is correct
64 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 316 KB Output is correct
28 Correct 0 ms 316 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 316 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 320 KB Output is correct
47 Correct 1 ms 320 KB Output is correct
48 Correct 1 ms 316 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 320 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 320 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 312 KB Output is correct
64 Correct 1 ms 316 KB Output is correct
65 Correct 12 ms 340 KB Output is correct
66 Correct 12 ms 408 KB Output is correct
67 Correct 12 ms 400 KB Output is correct
68 Correct 12 ms 340 KB Output is correct
69 Correct 22 ms 488 KB Output is correct
70 Correct 17 ms 368 KB Output is correct
71 Correct 17 ms 340 KB Output is correct
72 Correct 18 ms 312 KB Output is correct
73 Correct 15 ms 316 KB Output is correct
74 Correct 18 ms 388 KB Output is correct
75 Correct 16 ms 460 KB Output is correct
76 Correct 18 ms 340 KB Output is correct
77 Correct 35 ms 452 KB Output is correct
78 Correct 33 ms 444 KB Output is correct
79 Correct 33 ms 468 KB Output is correct
80 Correct 32 ms 456 KB Output is correct
81 Correct 33 ms 476 KB Output is correct
82 Correct 38 ms 432 KB Output is correct
83 Correct 33 ms 444 KB Output is correct
84 Correct 33 ms 452 KB Output is correct
85 Correct 69 ms 388 KB Output is correct
86 Correct 47 ms 460 KB Output is correct
87 Correct 52 ms 436 KB Output is correct
88 Correct 59 ms 460 KB Output is correct
89 Correct 37 ms 444 KB Output is correct
90 Correct 39 ms 400 KB Output is correct
91 Correct 40 ms 460 KB Output is correct
92 Correct 41 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 316 KB Output is correct
28 Correct 0 ms 316 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 316 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 320 KB Output is correct
47 Correct 1 ms 320 KB Output is correct
48 Correct 1 ms 316 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 320 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 320 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 312 KB Output is correct
64 Correct 1 ms 316 KB Output is correct
65 Correct 12 ms 340 KB Output is correct
66 Correct 12 ms 408 KB Output is correct
67 Correct 12 ms 400 KB Output is correct
68 Correct 12 ms 340 KB Output is correct
69 Correct 22 ms 488 KB Output is correct
70 Correct 17 ms 368 KB Output is correct
71 Correct 17 ms 340 KB Output is correct
72 Correct 18 ms 312 KB Output is correct
73 Correct 15 ms 316 KB Output is correct
74 Correct 18 ms 388 KB Output is correct
75 Correct 16 ms 460 KB Output is correct
76 Correct 18 ms 340 KB Output is correct
77 Correct 35 ms 452 KB Output is correct
78 Correct 33 ms 444 KB Output is correct
79 Correct 33 ms 468 KB Output is correct
80 Correct 32 ms 456 KB Output is correct
81 Correct 33 ms 476 KB Output is correct
82 Correct 38 ms 432 KB Output is correct
83 Correct 33 ms 444 KB Output is correct
84 Correct 33 ms 452 KB Output is correct
85 Correct 69 ms 388 KB Output is correct
86 Correct 47 ms 460 KB Output is correct
87 Correct 52 ms 436 KB Output is correct
88 Correct 59 ms 460 KB Output is correct
89 Correct 37 ms 444 KB Output is correct
90 Correct 39 ms 400 KB Output is correct
91 Correct 40 ms 460 KB Output is correct
92 Correct 41 ms 444 KB Output is correct
93 Correct 1203 ms 1520 KB Output is correct
94 Correct 1195 ms 1724 KB Output is correct
95 Correct 1295 ms 1584 KB Output is correct
96 Correct 864 ms 1544 KB Output is correct
97 Correct 839 ms 1472 KB Output is correct
98 Correct 987 ms 1580 KB Output is correct
99 Correct 105 ms 712 KB Output is correct
100 Correct 96 ms 740 KB Output is correct
101 Correct 94 ms 612 KB Output is correct
102 Correct 87 ms 624 KB Output is correct
103 Correct 893 ms 740 KB Output is correct
104 Correct 475 ms 844 KB Output is correct
105 Correct 340 ms 880 KB Output is correct
106 Correct 266 ms 940 KB Output is correct
107 Correct 2700 ms 1324 KB Output is correct
108 Correct 995 ms 1576 KB Output is correct
109 Correct 720 ms 1620 KB Output is correct
110 Correct 640 ms 1648 KB Output is correct
111 Correct 87 ms 568 KB Output is correct
112 Correct 80 ms 576 KB Output is correct
113 Correct 81 ms 580 KB Output is correct
114 Correct 204 ms 676 KB Output is correct
115 Correct 133 ms 596 KB Output is correct
116 Correct 146 ms 708 KB Output is correct
117 Correct 154 ms 548 KB Output is correct
118 Correct 102 ms 608 KB Output is correct
119 Correct 107 ms 532 KB Output is correct
120 Correct 114 ms 588 KB Output is correct
121 Correct 117 ms 544 KB Output is correct
122 Correct 240 ms 964 KB Output is correct
123 Correct 211 ms 920 KB Output is correct
124 Correct 206 ms 844 KB Output is correct
125 Correct 209 ms 984 KB Output is correct
126 Correct 217 ms 836 KB Output is correct
127 Correct 203 ms 940 KB Output is correct
128 Correct 216 ms 908 KB Output is correct
129 Correct 206 ms 948 KB Output is correct
130 Correct 225 ms 976 KB Output is correct
131 Correct 572 ms 1016 KB Output is correct
132 Correct 395 ms 924 KB Output is correct
133 Correct 435 ms 932 KB Output is correct
134 Correct 461 ms 976 KB Output is correct
135 Correct 295 ms 940 KB Output is correct
136 Correct 314 ms 916 KB Output is correct
137 Correct 329 ms 940 KB Output is correct
138 Correct 348 ms 956 KB Output is correct
139 Correct 251 ms 920 KB Output is correct
140 Correct 287 ms 844 KB Output is correct
141 Correct 280 ms 1056 KB Output is correct
142 Correct 541 ms 1580 KB Output is correct
143 Correct 557 ms 1620 KB Output is correct
144 Correct 561 ms 1656 KB Output is correct
145 Correct 539 ms 1596 KB Output is correct
146 Correct 569 ms 1516 KB Output is correct
147 Correct 584 ms 1504 KB Output is correct
148 Correct 558 ms 1580 KB Output is correct
149 Correct 579 ms 1576 KB Output is correct
150 Correct 561 ms 1504 KB Output is correct
151 Correct 682 ms 1612 KB Output is correct
152 Correct 674 ms 1540 KB Output is correct
153 Correct 867 ms 1568 KB Output is correct
154 Correct 898 ms 1580 KB Output is correct
155 Correct 989 ms 1644 KB Output is correct
156 Correct 1050 ms 1548 KB Output is correct
157 Correct 907 ms 1576 KB Output is correct
158 Correct 981 ms 1576 KB Output is correct
159 Correct 706 ms 1680 KB Output is correct
160 Correct 746 ms 1800 KB Output is correct
161 Correct 806 ms 1648 KB Output is correct
162 Correct 633 ms 1548 KB Output is correct
163 Correct 742 ms 1580 KB Output is correct
164 Correct 724 ms 1556 KB Output is correct
165 Correct 637 ms 1580 KB Output is correct
166 Correct 702 ms 1648 KB Output is correct
167 Correct 704 ms 1584 KB Output is correct