답안 #251178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251178 2020-07-20T13:31:12 Z mat_v Dango Maker (JOI18_dango_maker) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



int n,m;
int mat[3005][3005];
bool moze[3005][3005][2];
int dp[3005][3];

pii kurac[6005];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    ff(i,1,n){
        string x;
        cin >> x;
        ff(j,0,m - 1){
            if(x[j] == 'R')mat[i][j + 1] = 0;
            else if(x[j] == 'G')mat[i][j + 1] = 1;
            else if(x[j] == 'W')mat[i][j + 1] = 2;
        }
    }
    ff(i,1,6000)kurac[i] = {1e9,0};
    ff(i,1,n){
        ff(j,1,m){
            kurac[i + j].xx = min(kurac[i + j].xx, j);
            kurac[i + j].yy = max(kurac[i + j].yy, j);
        }
    }
    ff(i,1,n){
        ff(j,1,m){
            if(mat[i][j] != 1)continue;
            if(mat[i][j - 1] == 0 && mat[i][j + 1] == 2){
                moze[i][j][0] = 1;
            }
            if(mat[i - 1][j] == 0 && mat[i + 1][j] == 2){
                moze[i][j][1] = 1;
            }
        }
    }
    int res = 0;
    ff(s,2,n + m){
        ff(i,1,m)dp[i][0] = dp[i][1] = dp[i][2] = 0;
        int l = kurac[s].xx;
        int r = kurac[s].yy;

        dp[l][0] = 0;
        if(moze[s - l][l][0])dp[l][1] = 1;
        else dp[l][1] = -1e9;
        if(moze[s - l][l][1])dp[l][2] = 1;
        else dp[l][2] = -1e9;
        ff(j,l + 1,r){
            dp[j][0] = max(dp[j - 1][0], max(dp[j - 1][1], dp[j - 1][2]));
            dp[j][0] = max(dp[j][0], 0);
            dp[j][1] = dp[j][2] = -1e9;
            if(moze[s - j][j][0])dp[j][1] = max(dp[j - 1][0], dp[j - 1][1]) + 1;
            if(moze[s - j][j][1])dp[j][2] = max(dp[j - 1][0], dp[j - 1][2]) + 1;
        }
        res += max(dp[r][0], max(dp[r][1], dp[r][2]));
    }
    cout << res << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -