답안 #254630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
254630 2020-07-30T11:18:31 Z Atill83 Dango Maker (JOI18_dango_maker) C++14
100 / 100
294 ms 27004 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e3+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, m;
char gr[MAXN][MAXN];

vector<int> adj[MAXN];
bool done[MAXN][MAXN];
int lst[3][2];


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    cin>>n>>m;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin>>gr[i][j];
            if(gr[i][j] != 'G') done[i][j] = 1;
        }
    }
    int cnt = 0;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(done[i][j] == 1) continue;
            if(gr[i][j] == 'G'){
                int curi = i, curj = j;
                while(curj > 1 && curi < n && gr[curi + 1][curj - 1] == 'G'){
                    curj--;
                    curi++;
                }
                int idx = 0;
                memset(lst, 0, sizeof(lst));
                while(curj <= m && curi >= 1 && gr[curi][curj] == 'G'){
                    done[curi][curj] = 1;
                    
                    lst[idx][0] = max(lst[(idx + 1) % 3][1], lst[(idx + 2) % 3][0]);
                    if(gr[curi - 1][curj] == 'R' && gr[curi + 1][curj] == 'W'){
                        lst[idx][0]++;
                    }

                    lst[idx][1] = max(lst[(idx + 1) % 3][0], lst[(idx + 2) % 3][1]);

                    if(gr[curi][curj - 1] == 'R' && gr[curi][curj + 1] == 'W') 
                        lst[idx][1]++;
                    curj++;
                    curi--;
                    idx ++;
                    idx %= 3;
                }
                idx = (idx + 2) % 3;

                cnt += max(lst[idx][0], lst[idx][1]);

            }else{
                done[i][j] = 1;
            }

        }
    }
    


    cout<<cnt<<endl;





    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}
# 결과 실행 시간 메모리 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 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 0 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 0 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 0 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 0 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 0 ms 512 KB Output is correct
41 Correct 0 ms 512 KB Output is correct
42 Correct 0 ms 512 KB Output is correct
43 Correct 0 ms 512 KB Output is correct
44 Correct 0 ms 512 KB Output is correct
45 Correct 0 ms 512 KB Output is correct
46 Correct 0 ms 512 KB Output is correct
47 Correct 0 ms 512 KB Output is correct
48 Correct 0 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 0 ms 512 KB Output is correct
51 Correct 0 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 0 ms 512 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 0 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 0 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 0 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 0 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 0 ms 512 KB Output is correct
41 Correct 0 ms 512 KB Output is correct
42 Correct 0 ms 512 KB Output is correct
43 Correct 0 ms 512 KB Output is correct
44 Correct 0 ms 512 KB Output is correct
45 Correct 0 ms 512 KB Output is correct
46 Correct 0 ms 512 KB Output is correct
47 Correct 0 ms 512 KB Output is correct
48 Correct 0 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 0 ms 512 KB Output is correct
51 Correct 0 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 0 ms 512 KB Output is correct
54 Correct 0 ms 384 KB Output is correct
55 Correct 9 ms 18048 KB Output is correct
56 Correct 1 ms 512 KB Output is correct
57 Correct 8 ms 12160 KB Output is correct
58 Correct 36 ms 7296 KB Output is correct
59 Correct 291 ms 27004 KB Output is correct
60 Correct 290 ms 26872 KB Output is correct
61 Correct 294 ms 27000 KB Output is correct
62 Correct 1 ms 384 KB Output is correct
63 Correct 290 ms 26620 KB Output is correct
64 Correct 201 ms 26872 KB Output is correct
65 Correct 207 ms 27004 KB Output is correct
66 Correct 206 ms 27000 KB Output is correct
67 Correct 178 ms 26872 KB Output is correct
68 Correct 185 ms 26872 KB Output is correct
69 Correct 191 ms 27000 KB Output is correct
70 Correct 22 ms 7296 KB Output is correct
71 Correct 23 ms 7296 KB Output is correct
72 Correct 22 ms 7288 KB Output is correct
73 Correct 23 ms 7296 KB Output is correct
74 Correct 22 ms 7288 KB Output is correct
75 Correct 21 ms 7296 KB Output is correct
76 Correct 23 ms 7288 KB Output is correct
77 Correct 22 ms 7296 KB Output is correct
78 Correct 22 ms 7296 KB Output is correct
79 Correct 22 ms 7296 KB Output is correct
80 Correct 22 ms 7296 KB Output is correct
81 Correct 22 ms 7288 KB Output is correct
82 Correct 22 ms 7296 KB Output is correct
83 Correct 22 ms 7296 KB Output is correct
84 Correct 23 ms 7296 KB Output is correct
85 Correct 23 ms 7296 KB Output is correct
86 Correct 34 ms 7288 KB Output is correct
87 Correct 23 ms 7296 KB Output is correct
88 Correct 32 ms 7288 KB Output is correct
89 Correct 23 ms 7296 KB Output is correct
90 Correct 21 ms 7296 KB Output is correct