# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
709710 | Baytoro | Dango Maker (JOI18_dango_maker) | C++17 | 2055 ms | 304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl '\n'
#define ll long long
#define int long long
void fopn(string name){
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
const int INF=2e9,mod=1e9+7,N=2e5+10;
char c[15][15];
int used[15][15];
void solve(){
int n,m;
cin>>n>>m;
int M=1;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>c[i][j];
M*=3;
}
}
int res=0;
for(int mask=0;mask<M;mask++){
int x=mask;
int ans=0,ok=1;
for(int i=n-1;i>=0 && ok;i--){
for(int j=m-1;j>=0 && ok;j--){
used[i][j]=0;
if(x%3 && c[i][j]!='R') ok=0;
else if(x%3){
if(x%3==1){
if(j+2>=m || c[i][j+1]!='G' || c[i][j+2]!='W') ok=0;
else
used[i][j]++,used[i][j+1]++,used[i][j+2]++;
}
else{
if(i+2>=n || c[i+1][j]!='G' || c[i+2][j]!='W') ok=0;
else
used[i][j]++,used[i+1][j]++,used[i+2][j]++;
}
}
x/=3;
}
}
if(ok){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
if(used[i][j]>1) ok=0;
if(used[i][j] && c[i][j]=='R') ans++;
}
if(ok){
res=max(res,ans);
}
}
}
cout<<res;
}
main(){
//fopn("cbarn");
//ios;
int T=1;
//cin>>T;
for(int i=1;i<=T;i++){
//cout<<"Case #"<<i<<": ";
solve();
//cout<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |