# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
241269 | 2020-06-23T13:13:13 Z | dsjong | Dango Maker (JOI18_dango_maker) | C++14 | 5 ms | 384 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<n){ 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<m){ 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; //cout<<i<<" "<<j<<endl; } } } 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[v[j]][v[k]]) goto hell; } } fans=max(ans, fans); hell:; } // cout<<fans<<endl; sum+=fans; } cout<<sum; }
Compilation message
# | 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 | 4 ms | 384 KB | Output is correct |
6 | Incorrect | 4 ms | 384 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 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 | 4 ms | 384 KB | Output is correct |
6 | Incorrect | 4 ms | 384 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 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 | 4 ms | 384 KB | Output is correct |
6 | Incorrect | 4 ms | 384 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |