Submission #884479

#TimeUsernameProblemLanguageResultExecution timeMemory
884479ReLiceDango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms4444 KiB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define bc back()
#define ar array
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool flag=false;
    if(x>y){
        x=y;flag|=true;
    }
    return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool flag=false;
    if (x<y){
        x=y;flag|=true;
    }
    return flag;
}
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e9+7;
const ll mod=1e9+7;
const ll N=3e3+7;
const ld eps=1e-9;
char a[N][N];
ll l[N][N],r[N][N];
void solve(){
	ll i,j;
	ll n,m;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>a[i][j];
			l[i][j]=1;
			r[i][j]=1;
			if(j==m)r[i][j]=0;
			if(j==1)l[i][j]=0;
		}
	}
	ll c=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(a[i][j]=='R'){
				if(a[i][j+r[i][j]]=='G' && a[i][j+r[i][j]+r[i][j+r[i][j]]]=='W'){
					a[i][j]=a[i][j+r[i][j]]=a[i][j+r[i][j+r[i][j]+r[i][j]]]=0;
					r[i][j-l[i][j]]+=3;
					l[i][j+3]=r[i][j-l[i][j]];
					j-=l[i][j];
					j-=l[i][j];
					c++;
				}
				else if(a[i+1][j]=='G' && a[i+2][j]=='W'){
					a[i][j]=a[i+1][j]=a[i+2][j]=0;
					r[i+1][j-l[i+1][j]]++;
					r[i+2][j-l[i+2][j]]++;
					l[i+1][j+1]=l[i+1][j]+1;
					l[i+2][j+1]=l[i+2][j]+1;
					c++;
				}
			}
		}
	}
	cout<<c<<endl;
}
signed main(){
	start();
    ll t=1;
	//cin>>t;
    while(t--) solve();
    return 0;
}
/*








*/

Compilation message (stderr)

dango_maker.cpp: In function 'void fre(std::string)':
dango_maker.cpp:41:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:41:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp: In function 'void solve()':
dango_maker.cpp:71:13: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   71 |      a[i][j]=a[i][j+r[i][j]]=a[i][j+r[i][j+r[i][j]+r[i][j]]]=0;
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:51:6: note: at offset 0 to object 'a' with size 9042049 declared here
   51 | char a[N][N];
      |      ^
dango_maker.cpp:79:33: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   79 |      a[i][j]=a[i+1][j]=a[i+2][j]=0;
      |                        ~~~~~~~~~^~
dango_maker.cpp:51:6: note: at offset 0 to object 'a' with size 9042049 declared here
   51 | char a[N][N];
      |      ^
dango_maker.cpp:79:23: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   79 |      a[i][j]=a[i+1][j]=a[i+2][j]=0;
      |              ~~~~~~~~~^~~~~~~~~~~~
dango_maker.cpp:51:6: note: at offset 0 to object 'a' with size 9042049 declared here
   51 | char a[N][N];
      |      ^
dango_maker.cpp:79:13: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   79 |      a[i][j]=a[i+1][j]=a[i+2][j]=0;
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:51:6: note: at offset 0 to object 'a' with size 9042049 declared here
   51 | char a[N][N];
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...