답안 #908700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908700 2024-01-16T17:12:00 Z amirhoseinfar1385 Amusement Park (CEOI19_amusementpark) C++17
42 / 100
1831 ms 60628 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn=15,maxm=14348907;
int dp[maxm],pd[maxm];
pair<int,int>tab2(int a){
	int now=0;
	pair<int,int>ret=make_pair(0,0);
	while(a!=0){
		if(a%3==1){
			ret.first+=(1<<now);
		}else if(a%3==2){
			ret.second+=(1<<now);
		}
		now++;
		a/=3;
	}
	return ret;
}

int back3(int a,int b){
	int ret=0,now=1;
	while(a+b!=0){
		if(a&1){
			ret+=now;
		}
		else if(b&1){
			ret+=2*now;
		}
		now*=3;
		a>>=1;
		b>>=1;
	}
	return ret;
}
vector<int>tartib[18];
int adj[maxn],adja[maxn];
int n,m;

void aval(){
	int nx=1;
	for(int i=1;i<=n;i++){
		nx*=3;
	}
	for(int i=0;i<nx;i++){
		pair<int,int>fake=tab2(i);
//		cout<<i<<" "<<fake.first<<" "<<fake.second<<"\n";
		tartib[__builtin_popcount(fake.first)].push_back(i);
	}
}

void solve(){
	for(int i=0;i<maxn;i++){
		for(auto x:tartib[i]){
			pair<int,int>now=tab2(x);
		//	cout<<now.first<<" "<<now.second<<" "<<pd[x]<<" "<<dp[x]<<endl;
			for(int j=0;j<n;j++){
				if((now.second>>j)&1){
					pair<int,int>fake=now;
					fake.first|=(1<<j);
					for(int h=0;h<=j;h++){
						if((fake.second>>h)&1){
							fake.second^=(1<<h);
						}
					}
					fake.second|=(adj[j]^(adj[j]&now.first));
					int tof=back3(fake.first,fake.second);
				//	cout<<now.first<<" "<<now.second<<" "<<fake.first<<" "<<fake.second<<" "<<adja[j]<<" salam\n";
					pd[tof]+=pd[x];
					dp[tof]+=dp[x]+pd[x]*(__builtin_popcount(adja[j]&now.first));
				}
			}
		}
	}
}

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);
	//dp[res]=pd[res]*m;
	cout<<dp[res]<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 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 344 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 5 ms 856 KB Output is correct
40 Correct 5 ms 604 KB Output is correct
41 Correct 5 ms 600 KB Output is correct
42 Correct 5 ms 604 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 5 ms 600 KB Output is correct
45 Correct 5 ms 600 KB Output is correct
46 Correct 5 ms 604 KB Output is correct
47 Correct 5 ms 604 KB Output is correct
48 Correct 5 ms 768 KB Output is correct
49 Correct 6 ms 604 KB Output is correct
50 Correct 5 ms 604 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 17 ms 3160 KB Output is correct
53 Correct 15 ms 3216 KB Output is correct
54 Correct 15 ms 3288 KB Output is correct
55 Correct 16 ms 3160 KB Output is correct
56 Correct 15 ms 3164 KB Output is correct
57 Correct 15 ms 3080 KB Output is correct
58 Correct 15 ms 3416 KB Output is correct
59 Correct 15 ms 2908 KB Output is correct
60 Correct 15 ms 2908 KB Output is correct
61 Correct 15 ms 3164 KB Output is correct
62 Correct 17 ms 3420 KB Output is correct
63 Correct 15 ms 2908 KB Output is correct
64 Correct 15 ms 3032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 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 344 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 5 ms 856 KB Output is correct
40 Correct 5 ms 604 KB Output is correct
41 Correct 5 ms 600 KB Output is correct
42 Correct 5 ms 604 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 5 ms 600 KB Output is correct
45 Correct 5 ms 600 KB Output is correct
46 Correct 5 ms 604 KB Output is correct
47 Correct 5 ms 604 KB Output is correct
48 Correct 5 ms 768 KB Output is correct
49 Correct 6 ms 604 KB Output is correct
50 Correct 5 ms 604 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 17 ms 3160 KB Output is correct
53 Correct 15 ms 3216 KB Output is correct
54 Correct 15 ms 3288 KB Output is correct
55 Correct 16 ms 3160 KB Output is correct
56 Correct 15 ms 3164 KB Output is correct
57 Correct 15 ms 3080 KB Output is correct
58 Correct 15 ms 3416 KB Output is correct
59 Correct 15 ms 2908 KB Output is correct
60 Correct 15 ms 2908 KB Output is correct
61 Correct 15 ms 3164 KB Output is correct
62 Correct 17 ms 3420 KB Output is correct
63 Correct 15 ms 2908 KB Output is correct
64 Correct 15 ms 3032 KB Output is correct
65 Correct 1831 ms 60508 KB Output is correct
66 Incorrect 1816 ms 60628 KB Output isn't correct
67 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 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 344 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 344 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 5 ms 856 KB Output is correct
40 Correct 5 ms 604 KB Output is correct
41 Correct 5 ms 600 KB Output is correct
42 Correct 5 ms 604 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 5 ms 600 KB Output is correct
45 Correct 5 ms 600 KB Output is correct
46 Correct 5 ms 604 KB Output is correct
47 Correct 5 ms 604 KB Output is correct
48 Correct 5 ms 768 KB Output is correct
49 Correct 6 ms 604 KB Output is correct
50 Correct 5 ms 604 KB Output is correct
51 Correct 5 ms 604 KB Output is correct
52 Correct 17 ms 3160 KB Output is correct
53 Correct 15 ms 3216 KB Output is correct
54 Correct 15 ms 3288 KB Output is correct
55 Correct 16 ms 3160 KB Output is correct
56 Correct 15 ms 3164 KB Output is correct
57 Correct 15 ms 3080 KB Output is correct
58 Correct 15 ms 3416 KB Output is correct
59 Correct 15 ms 2908 KB Output is correct
60 Correct 15 ms 2908 KB Output is correct
61 Correct 15 ms 3164 KB Output is correct
62 Correct 17 ms 3420 KB Output is correct
63 Correct 15 ms 2908 KB Output is correct
64 Correct 15 ms 3032 KB Output is correct
65 Correct 1831 ms 60508 KB Output is correct
66 Incorrect 1816 ms 60628 KB Output isn't correct
67 Halted 0 ms 0 KB -