Submission #1144365

#TimeUsernameProblemLanguageResultExecution timeMemory
1144365tntDango Maker (JOI18_dango_maker)C++20
13 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") #define pb push_back #define ll long long #define int long long //#define sort(all(v)) sort(v.begin(),v.end()) int mod = 998244353; const int N = 4e5 + 10; const int inf = 1e9; int fact[200001]; ll binpow(ll a, ll b){ if(b == 0) return 1; else if(b % 2 == 1) return (a * binpow(a, b - 1)) % mod; ll p = binpow(a,b / 2); return (p * p) % mod; } signed main(){ //freopen("mootube.in", "r", stdin); //freopen("mootube.out", "w", stdout); int n,m; cin >> n >> m; char a[n + 1][m + 1],a1[n + 1][m + 1]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin >> a[i][j]; a1[i][j] = a[i][j]; } } if(n <= 2 && m <= 2){ cout << 0; return 0; } int ans = 0; if(n <= 2 && m >= 3){ int cnt = 0; for(int i = 1; i <= n; i++){ if(a[i][1] == 'R' && a[i][2] == 'G' && a[i][3] == 'W')cnt++; } cout << cnt; return 0; } else if(n >= 3 && m <= 2){ int cnt = 0; for(int i = 1; i <= n; i++){ if(a[1][i] == 'R' && a[2][i] == 'G' && a[3][i] == 'W')cnt++; } cout << cnt; return 0; } else if(n == 3 && m == 3){ int cnt = 0,cnt1 = 0; for(int i = 1; i <= n; i++){ if(a[i][1] == 'R' && a[i][2] == 'G' && a[i][3] == 'W')cnt++; } for(int i = 1; i <= n; i++){ if(a[1][i] == 'R' && a[2][i] == 'G' && a[3][i] == 'W')cnt1++; } cout << max(cnt,cnt1); return 0; } int f = 0; int cnt = 0; for(int i = 1; i <= n; i++){ if(a[i][1] == 'R' && a[i][2] == 'G' && a[i][3] == 'W'){ cnt++; a[i][1] = a[i][2] = a[i][3] = '%'; } else if(m >= 4){ if(a[i][2] == 'R' && a[i][3] == 'G' && a[i][4] == 'W'){ cnt++; a[i][2] = a[i][3] = a[i][4] = '%'; } } } for(int i = 1; i <= m; i++){ if(a[1][i] == 'R' && a[2][i] == 'G' && a[3][i] == 'W'){ cnt++; a[1][i] = a[2][i] = a[3][i] = '%'; } else if(n >= 4){ if(a[2][i] == 'R' && a[3][i] == 'G' && a[4][i] == 'W'){ cnt++; a[2][i] = a[3][i] = a[4][i] = '%'; } } } ans = max(cnt,ans); cnt = 0; for(int i = 1; i <= m; i++){ if(a1[1][i] == 'R' && a1[2][i] == 'G' && a1[3][i] == 'W'){ cnt++; a1[1][i] = a1[2][i] = a1[3][i] = '%'; } else if(n >= 4){ if(a1[2][i] == 'R' && a1[3][i] == 'G' && a1[4][i] == 'W'){ cnt++; a1[2][i] = a1[3][i] = a1[4][i] = '%'; } } } for(int i = 1; i <= n; i++){ if(a1[i][1] == 'R' && a1[i][2] == 'G' && a1[i][3] == 'W'){ cnt++; a1[i][1] = a1[i][2] = a1[i][3] = '%'; } else if(m >= 4){ if(a1[i][2] == 'R' && a1[i][3] == 'G' && a1[i][4] == 'W'){ cnt++; a1[i][2] = a1[i][3] = a1[i][4] = '%'; } } } ans = max(cnt,ans); cnt = 0; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...