Submission #524398

# Submission time Handle Problem Language Result Execution time Memory
524398 2022-02-09T07:10:10 Z AA_Surely Dango Maker (JOI18_dango_maker) C++17
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>

#define FOR(i,x,n) 	for(int i=x; i<n; i++)
#define F0R(i,n) 	FOR(i,0,n)
#define ROF(i,x,n) 	for(int i=n-1; i>=x; i--)
#define R0F(i,n) 	ROF(i,0,n)

#define WTF 		cout << "WTF" << endl

#define IOS 		ios::sync_with_stdio(false); cin.tie(0)
#define F 			first
#define S	 		second
#define pb 			push_back

#define ALL(x) 		x.begin(), x.end()
#define RALL(x) 	x.rbegin(), x.rend()

using namespace std;
typedef long long 		LL;

typedef pair<int, int> 	PII;
typedef pair<LL, LL> 	PLL;

typedef vector<int> 	VI;
typedef vector<LL> 		VLL;
typedef vector<PII> 	VPII;
typedef vector<PLL> 	VPLL;

const int MAXN = 3e3 + 7;
const int ALPHA = 27;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int LOG = 22;

int n, m;
char grid[MAXN][MAXN];
int gs[MAXN][MAXN];

inline bool safe(int x, int y) {
    if (x < 0 || x >= n) return 0;
    if (y < 0 || y >= m) return 0;
    return 1;
}

int main() {
    IOS;
    
    cin >> n >> m;
    F0R(i, n) F0R(j, m) cin >> grid[i][j];
    int ans = 0;
    F0R(i, n) F0R(j, m) {
        if (grid[i][j] != 'G') continue;

        if (i && grid[i - 1][j] == 'R' && i < n - 1 && grid[i + 1][j] == 'W') gs[i][j] = 1;
        if (j && grid[i][j - 1] == 'R' && j < m - 1 && grid[i][j + 1] == 'W') gs[i][j] |= 2;
        ans += (gs[i][j] != 0);
    }
    //cout << ans << endl;
    /*
    F0R(i, n) {
        F0R(j, m) cout << gs[i][j];
        cout << endl;
    }
    */
    F0R(j, m) {
        int x = 0, y = j, cnt = 0;
        while(safe(x, y)) {
            if (gs[x][y] == 3) {
                x++; y--; 
                continue;
            }
            
            if (gs[x][y] == 0 || !x || y + 1 >= m || gs[x][y] == gs[x - 1][y + 1]) {
                ans -= (cnt >> 1);
                cnt = 0;
            }
            cnt += (gs[x][y] != 0);

            x++; y--;
        }
        ans -= (cnt >> 1);
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Incorrect 1 ms 324 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Incorrect 1 ms 324 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Incorrect 1 ms 324 KB Output isn't correct
7 Halted 0 ms 0 KB -