답안 #219771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219771 2020-04-06T10:17:19 Z Rakhmand Dango Maker (JOI18_dango_maker) C++14
100 / 100
874 ms 186232 KB
//  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

dango_maker.cpp: In function 'void istxt(bool)':
dango_maker.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("sum2.in", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("sum2.out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/input.txt", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 512 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 5 ms 512 KB Output is correct
24 Correct 5 ms 512 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 640 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 5 ms 640 KB Output is correct
30 Correct 5 ms 512 KB Output is correct
31 Correct 5 ms 512 KB Output is correct
32 Correct 5 ms 512 KB Output is correct
33 Correct 5 ms 640 KB Output is correct
34 Correct 5 ms 640 KB Output is correct
35 Correct 5 ms 640 KB Output is correct
36 Correct 5 ms 640 KB Output is correct
37 Correct 5 ms 640 KB Output is correct
38 Correct 5 ms 512 KB Output is correct
39 Correct 5 ms 640 KB Output is correct
40 Correct 5 ms 640 KB Output is correct
41 Correct 5 ms 640 KB Output is correct
42 Correct 5 ms 640 KB Output is correct
43 Correct 5 ms 640 KB Output is correct
44 Correct 5 ms 512 KB Output is correct
45 Correct 5 ms 640 KB Output is correct
46 Correct 5 ms 640 KB Output is correct
47 Correct 5 ms 640 KB Output is correct
48 Correct 5 ms 640 KB Output is correct
49 Correct 5 ms 640 KB Output is correct
50 Correct 5 ms 512 KB Output is correct
51 Correct 5 ms 528 KB Output is correct
52 Correct 5 ms 640 KB Output is correct
53 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 512 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 5 ms 512 KB Output is correct
24 Correct 5 ms 512 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 640 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 5 ms 640 KB Output is correct
30 Correct 5 ms 512 KB Output is correct
31 Correct 5 ms 512 KB Output is correct
32 Correct 5 ms 512 KB Output is correct
33 Correct 5 ms 640 KB Output is correct
34 Correct 5 ms 640 KB Output is correct
35 Correct 5 ms 640 KB Output is correct
36 Correct 5 ms 640 KB Output is correct
37 Correct 5 ms 640 KB Output is correct
38 Correct 5 ms 512 KB Output is correct
39 Correct 5 ms 640 KB Output is correct
40 Correct 5 ms 640 KB Output is correct
41 Correct 5 ms 640 KB Output is correct
42 Correct 5 ms 640 KB Output is correct
43 Correct 5 ms 640 KB Output is correct
44 Correct 5 ms 512 KB Output is correct
45 Correct 5 ms 640 KB Output is correct
46 Correct 5 ms 640 KB Output is correct
47 Correct 5 ms 640 KB Output is correct
48 Correct 5 ms 640 KB Output is correct
49 Correct 5 ms 640 KB Output is correct
50 Correct 5 ms 512 KB Output is correct
51 Correct 5 ms 528 KB Output is correct
52 Correct 5 ms 640 KB Output is correct
53 Correct 5 ms 512 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 34 ms 25336 KB Output is correct
56 Correct 5 ms 640 KB Output is correct
57 Correct 30 ms 36224 KB Output is correct
58 Correct 106 ms 36600 KB Output is correct
59 Correct 873 ms 185208 KB Output is correct
60 Correct 874 ms 185208 KB Output is correct
61 Correct 869 ms 185160 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 832 ms 181288 KB Output is correct
64 Correct 758 ms 186232 KB Output is correct
65 Correct 763 ms 186232 KB Output is correct
66 Correct 754 ms 186232 KB Output is correct
67 Correct 624 ms 91256 KB Output is correct
68 Correct 616 ms 91384 KB Output is correct
69 Correct 644 ms 108668 KB Output is correct
70 Correct 90 ms 36856 KB Output is correct
71 Correct 93 ms 36908 KB Output is correct
72 Correct 89 ms 36856 KB Output is correct
73 Correct 91 ms 36856 KB Output is correct
74 Correct 92 ms 36856 KB Output is correct
75 Correct 98 ms 36856 KB Output is correct
76 Correct 90 ms 36856 KB Output is correct
77 Correct 91 ms 36856 KB Output is correct
78 Correct 92 ms 36856 KB Output is correct
79 Correct 90 ms 36856 KB Output is correct
80 Correct 97 ms 37112 KB Output is correct
81 Correct 93 ms 36856 KB Output is correct
82 Correct 90 ms 36856 KB Output is correct
83 Correct 91 ms 36856 KB Output is correct
84 Correct 94 ms 36856 KB Output is correct
85 Correct 91 ms 36960 KB Output is correct
86 Correct 90 ms 36832 KB Output is correct
87 Correct 94 ms 36856 KB Output is correct
88 Correct 94 ms 36856 KB Output is correct
89 Correct 99 ms 36856 KB Output is correct
90 Correct 93 ms 36948 KB Output is correct