Submission #224062

# Submission time Handle Problem Language Result Execution time Memory
224062 2020-04-17T06:56:10 Z Ruxandra985 Dango Maker (JOI18_dango_maker) C++14
13 / 100
5 ms 512 KB
#include <bits/stdc++.h>

using namespace std;
char a[3010][3010];
int f[3010][3010] , vert , oriz;
void fill (int i , int j){

    f[i][j] = 1;

    if (a[i][j] == 'R'){

        if (a[i][j + 1] == 'G' && a[i][j + 2] == 'W' && !f[i][j + 1] && !f[i][j + 2]){
            oriz++;
            fill (i , j + 1);
            fill (i , j + 2);
        }


        if (a[i + 1][j] == 'G' && a[i + 2][j] == 'W' && !f[i + 1][j] && !f[i + 2][j]){
            vert++;
            fill (i + 1 , j);
            fill (i + 2 , j);
        }


    }
    else if (a[i][j] == 'G'){

        if (a[i][j - 1] == 'R' && a[i][j + 1] == 'W' && !f[i][j + 1] && !f[i][j - 1]){
            oriz++;
            fill (i , j - 1);
            fill (i , j + 1);
        }


        if (a[i - 1][j] == 'R' && a[i + 1][j] == 'W' && !f[i - 1][j] && !f[i + 1][j]){
            vert++;
            fill (i + 1 , j);
            fill (i - 1 , j);
        }

    }
    else {
        if (a[i][j - 1] == 'G' && a[i][j - 2] == 'R' && !f[i][j - 1] && !f[i][j - 2]){
            oriz++;
            fill (i , j - 1);
            fill (i , j - 2);
        }


        if (a[i - 1][j] == 'G' && a[i - 2][j] == 'R' && !f[i - 1][j] && !f[i - 2][j]){
            vert++;
            fill (i - 1 , j);
            fill (i - 2 , j);
        }
    }


}
int main()
{
    FILE *fin = stdin;
    FILE *fout = stdout;
    int n , m , i , j , sol = 0;
    fscanf (fin,"%d%d\n",&n,&m);
    for (i = 1 ; i <= n ; i++)
        fgets(a[i] + 1 , m + 10 , fin);

    for (i = 1 ; i <= n ; i++){
        for (j = 1 ; j <= m ; j++){
            if (!f[i][j] && a[i][j] == 'R'){
                vert = oriz = 0;
                fill (i , j);
                sol = sol + max(vert , oriz);
            }
        }
    }
    fprintf (fout,"%d",sol);
    return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:65:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d%d\n",&n,&m);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:67:14: warning: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         fgets(a[i] + 1 , m + 10 , fin);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 436 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 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 5 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 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 436 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 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 5 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 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Incorrect 4 ms 384 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 436 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 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 5 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 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Incorrect 4 ms 384 KB Output isn't correct
35 Halted 0 ms 0 KB -