답안 #957754

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957754 2024-04-04T09:19:28 Z hariaakas646 Dango Maker (JOI18_dango_maker) C++14
100 / 100
138 ms 92588 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;


void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int n, m;
vector<string> grid;

bool check(int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < m;
}

int main() {
    // usaco();
    fastio();
    cin >> n >> m;
    grid = vector<string>(n);

    frange(i, n) cin >> grid[i];

    vector<vb> up(n, vb(m)), left(n, vb(m));
    frange(i, n) {
        frange(j, m) {
            if(grid[i][j] == 'G' && check(i-1, j) && check(i+1, j) && grid[i-1][j] == 'R' && grid[i+1][j] == 'W') up[i][j] = true;
            if(grid[i][j] == 'G' && check(i, j-1) && check(i, j+1) && grid[i][j-1] == 'R' && grid[i][j+1] == 'W') left[i][j] = true;
            // cout <<  i << " " << j << " " << check(i, j) << "\n";
        }
    }

    vvi dpu(n, vi(m)), dpl(n, vi(m));

    frange(i, n) {
        for(int j=m-1; j>=0; j--) {
            if(check(i-1, j+1)) {
                dpu[i][j] = dpl[i][j] = max(dpu[i-1][j+1], dpl[i-1][j+1]);
            }
            if(up[i][j]) {
                if(check(i-1, j+1)) dpu[i][j] = max(dpu[i][j], dpu[i-1][j+1] + 1); 
                else dpu[i][j] = 1;
            }
            if(left[i][j]) {
                if(check(i-1, j+1)) dpl[i][j] = max(dpl[i][j], dpl[i-1][j+1] + 1);
                else dpl[i][j] = 1;
            }
            
        } 
    }
    int tot = 0;
    frange(i, n) tot += max(dpu[i][0], dpl[i][0]);
    forr(i, 1, m) tot += max(dpu[n-1][i], dpl[n-1][i]);

    cout << tot;
}

Compilation message

dango_maker.cpp: In function 'void usaco()':
dango_maker.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 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 0 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 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 600 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 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 0 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 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 600 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 756 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 452 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 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 0 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 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 600 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 756 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 452 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 1116 KB Output is correct
56 Correct 0 ms 604 KB Output is correct
57 Correct 1 ms 860 KB Output is correct
58 Correct 16 ms 10588 KB Output is correct
59 Correct 137 ms 92200 KB Output is correct
60 Correct 138 ms 92344 KB Output is correct
61 Correct 137 ms 92208 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 133 ms 89140 KB Output is correct
64 Correct 101 ms 92316 KB Output is correct
65 Correct 93 ms 92212 KB Output is correct
66 Correct 96 ms 92032 KB Output is correct
67 Correct 86 ms 92244 KB Output is correct
68 Correct 89 ms 92588 KB Output is correct
69 Correct 92 ms 92244 KB Output is correct
70 Correct 11 ms 10584 KB Output is correct
71 Correct 11 ms 10584 KB Output is correct
72 Correct 11 ms 10588 KB Output is correct
73 Correct 10 ms 10756 KB Output is correct
74 Correct 11 ms 10584 KB Output is correct
75 Correct 11 ms 10796 KB Output is correct
76 Correct 11 ms 10732 KB Output is correct
77 Correct 11 ms 10588 KB Output is correct
78 Correct 11 ms 10588 KB Output is correct
79 Correct 11 ms 10588 KB Output is correct
80 Correct 11 ms 10596 KB Output is correct
81 Correct 11 ms 10588 KB Output is correct
82 Correct 11 ms 10584 KB Output is correct
83 Correct 11 ms 10588 KB Output is correct
84 Correct 11 ms 10588 KB Output is correct
85 Correct 12 ms 10704 KB Output is correct
86 Correct 11 ms 10588 KB Output is correct
87 Correct 11 ms 10584 KB Output is correct
88 Correct 12 ms 10588 KB Output is correct
89 Correct 11 ms 10588 KB Output is correct
90 Correct 11 ms 10588 KB Output is correct