# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
219771 | Rakhmand | Dango Maker (JOI18_dango_maker) | C++14 | 874 ms | 186232 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.
// I feel still alive.
// Created by existence on 18/04/2003.
// Copyright © 2020 Rakhman. All rights reserved.
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define S second
#define F first
#define nl '\n'
const long long mxn = 510501;
const long long mod = 1e5 + 7;
const long long inf = 1e18;
typedef long long llong;
using namespace std;
void istxt(bool yes){
if(yes == 1){
freopen("sum2.in", "r", stdin);
freopen("sum2.out", "w", stdout);
}else{
freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/input.txt", "r", stdin);
}
}
int n, m, last, x;
char a[4040][4040];
bool l[4040][4040], d[4040][4004];
int dp[3][4040][4040];
int main(){
ios;
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> a[i][j];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(a[i][j - 1] == 'R' && a[i][j] == 'G' && a[i][j + 1] == 'W'){
l[i][j] = true;
}
if(a[i - 1][j] == 'R' && a[i][j] == 'G' && a[i + 1][j] == 'W'){
d[i][j] = true;
}
}
}
for(int s = 2; s <= n + m; s++){
for(int r = 1; r <= n; r++){
int c = s - r;
if(c < 0 || c > m){
continue;
}
dp[0][r][c] = max({last, dp[0][r][c], dp[1][r][c], dp[2][r][c]});
if(l[r][c] == 1){
dp[1][r][c] = max({x, dp[0][r - 1][c + 1], dp[1][r - 1][c + 1]}) + 1;
}
if(d[r][c] == 1){
dp[2][r][c] = max({x, dp[0][r - 1][c + 1], dp[2][r - 1][c + 1]}) + 1;
}
last = max({dp[0][r][c], dp[1][r][c], dp[2][r][c]});
}
x = last;
}
cout << x;
}
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... |