Submission #241272

# Submission time Handle Problem Language Result Execution time Memory
241272 2020-06-23T13:20:07 Z dsjong Dango Maker (JOI18_dango_maker) C++14
33 / 100
11 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
set<int>node[100];
bool edge[100][100];
bool vis[100];
char a[15][15];
vector<int>adj[100];
vector<int>v;
void dfs(int x){
	vis[x]=true;
	v.push_back(x);
	for(int y:adj[x]){
		if(vis[y]) continue;
		dfs(y);
	}
}
int main(){
	int n, m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			string s="";
			if(j+2<m){
				s=(s+a[i][j]+a[i][j+1]+a[i][j+2]);
				//cout<<s<<endl;
				if(s=="RGW"){
					node[cnt].insert(i*m+j);
					node[cnt].insert(i*m+j+1);
					node[cnt].insert(i*m+j+2);
					cnt++;
				}
			}
			if(i+2<n){
				s="";
				s=s+a[i][j]+a[i+1][j]+a[i+2][j];
				//cout<<s<<endl;
				if(s=="RGW"){
					node[cnt].insert(i*m+j);
					node[cnt].insert((i+1)*m+j);
					node[cnt].insert((i+2)*m+j);
					cnt++;
				}
			}
		}
	}
	memset(edge, false, sizeof edge);
	for(int i=0;i<cnt;i++){
		for(int j=i+1;j<cnt;j++){
			set<int>s;
			for(int k:node[i]) s.insert(k);
			for(int k:node[j]) s.insert(k);
			if((int)s.size()!=6){
				adj[i].push_back(j);
				adj[j].push_back(i);
				edge[i][j]=edge[j][i]=true;
			}
		}
	}
	memset(vis, false, sizeof vis);
	int sum=0;
	for(int i=0;i<cnt;i++){
		if(vis[i]) continue;
		//cout<<i<<endl;
		v.clear();
		dfs(i);
		int sz=v.size();
		vector<int>vv;
		int fans=0;
		for(int i=0;i<(1<<sz);i++){
			vv.clear();
			int ans=0;
			for(int j=0;j<sz;j++){
				if(i&(1<<j)){
					vv.push_back(v[j]);
					ans++;
				}
			}
			for(int j=0;j<vv.size();j++){
				for(int k=j+1;k<vv.size();k++){
					if(edge[vv[j]][vv[k]]) goto hell;
				}
			}
			fans=max(ans, fans);
			hell:;
		}
		// cout<<fans<<endl;
		sum+=fans;
	}
	cout<<sum;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:84:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<vv.size();j++){
                ~^~~~~~~~~~
dango_maker.cpp:85:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int k=j+1;k<vv.size();k++){
                   ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 6 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 8 ms 384 KB Output is correct
35 Correct 11 ms 384 KB Output is correct
36 Correct 11 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 6 ms 384 KB Output is correct
40 Correct 10 ms 384 KB Output is correct
41 Correct 6 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 6 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 6 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 5 ms 384 KB Output is correct
53 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 6 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 8 ms 384 KB Output is correct
35 Correct 11 ms 384 KB Output is correct
36 Correct 11 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 6 ms 384 KB Output is correct
40 Correct 10 ms 384 KB Output is correct
41 Correct 6 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 6 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 6 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 5 ms 384 KB Output is correct
53 Correct 5 ms 384 KB Output is correct
54 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
55 Halted 0 ms 0 KB -