답안 #1094187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094187 2024-09-28T22:17:20 Z Marco_Escandon Dango Maker (JOI18_dango_maker) C++11
13 / 100
1 ms 460 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define x first
#define y second
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> cad(n,vector<ll>(m,0));
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            char car;
            cin>>car;
            if(car=='R') cad[i][j]=1;
            else if(car=='G') cad[i][j]=2;
            else cad[i][j]=3;
        }
    }
    ll cont=0;
    for(int z=0; z<n; z++)
    {
        map<ll,ll> dp;
        ll a=z,b=0;
        ll i=0;
        while(a>=0&&b<m)
        {
            dp[i]=max(dp[i],dp[i-1]);
            if(a>=2) dp[i]=max(dp[i],dp[i-1]+((cad[a][b]==3)&(cad[a-1][b]==2)&(cad[a-2][b]==1)));
            if(b>=2) dp[i]=max(dp[i],dp[i-3]+((cad[a][b]==3)&(cad[a][b-1]==2)&(cad[a][b-2]==1)));
            a--;
            b++;
            i++;
        }
        cont+=dp[i-1];
    }
    for(int z=1; z<m; z++)
    {
        map<ll,ll> dp;
        ll a=n-1,b=z;
        ll i=0;
        while(a>=0&&b<m)
        {
            dp[i]=max(dp[i],dp[i-1]);
            if(a>=2) dp[i]=max(dp[i],dp[i-1]+((cad[a][b]==3)&(cad[a-1][b]==2)&(cad[a-2][b]==1)));
            if(b>=2) dp[i]=max(dp[i],dp[i-3]+((cad[a][b]==3)&(cad[a][b-1]==2)&(cad[a][b-2]==1)));
            a--;
            b++;
            i++;
        }
        cont+=dp[i-1];
    }
    cout<<cont;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 352 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Incorrect 0 ms 352 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 352 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Incorrect 0 ms 352 KB Output isn't correct
19 Halted 0 ms 0 KB -