Submission #709710

#TimeUsernameProblemLanguageResultExecution timeMemory
709710BaytoroDango Maker (JOI18_dango_maker)C++17
13 / 100
2055 ms304 KiB
#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)

dango_maker.cpp:65:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   65 | main(){
      | ^~~~
dango_maker.cpp: In function 'void fopn(std::string)':
dango_maker.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...