Submission #79761

# Submission time Handle Problem Language Result Execution time Memory
79761 2018-10-16T06:16:20 Z antimirage Dango Maker (JOI18_dango_maker) C++17
13 / 100
217 ms 71376 KB
#include <bits/stdc++.h>

#define pb emplace_back

using namespace std;

const int N = 3005;

int n, m, d[2][N][N], sz, u[3000005], wh, bl, ans;

char ar[N][N];

vector <int> g[3000005];

void dfs (int v, int color)
{
    if (color == 0) wh++;
    else bl++;
    u[v] = 1;
    
    for (auto to : g[v])
    {
        if (!u[to])
            dfs(to, color ^ 1);
    }
}

main() 
{
    cin >> n >> m;
    
    for (int i = 1; i <= n; i++)
    {
        scanf("\n");
        for (int j = 1; j <= m; j++)
            scanf("%c", &ar[i][j]);
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if ( j + 2 <= m && ar[i][j] == 'R' && ar[i][j + 1] == 'G' && ar[i][j + 2] == 'W' )
                d[0][i][j] = ++sz;
            if ( i + 2 <= n && ar[i][j] == 'R' && ar[i + 1][j] == 'G' && ar[i + 2][j] == 'W')
                d[1][i][j] = ++sz;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if ( d[0][i][j] )
            {
                if (d[1][i][j]) 
                    g[ d[0][i][j] ].pb( d[1][i][j] ),
                    g[ d[1][i][j] ].pb( d[0][i][j] );
                    
                if (d[1][i - 1][j + 1])
                    g[ d[0][i][j] ].pb( d[1][i - 1][j + 1] ),
                    g[ d[1][i - 1][j + 1] ].pb( d[0][i][j] );
                    
                if (d[1][i - 2][j + 2])
                    g[ d[0][i][j] ].pb( d[1][i - 2][j + 2] ),
                    g[ d[1][i - 2][j + 2] ].pb( d[0][i][j] );
            }
            if ( d[1][i][j] )
            {
                if (d[0][i][j]) 
                    g[ d[1][i][j] ].pb( d[0][i][j] ),
                    g[ d[0][i][j] ].pb( d[1][i][j] );
                    
                if (d[0][i + 1][j - 1])
                    g[ d[0][i + 1][j - 1] ].pb( d[1][i][j] ),
                    g[ d[1][i][j] ].pb( d[0][i + 1][j - 1] );
                    
                if (d[0][i + 2][j - 2])
                    g[ d[0][i + 2][j - 2] ].pb( d[1][i][j] ),
                    g[ d[1][i][j] ].pb( d[0][i + 2][j - 2] );
            }
        }
    }
    for (int i = 1; i <= sz; i++)
    {
        if (u[i]) continue;
        wh = bl = 0;
        dfs(i, 0);
        ans += max( wh, bl );
    }
    cout << ans << endl;
}

Compilation message

dango_maker.cpp:28:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() 
      ^
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("\n");
         ~~~~~^~~~~~
dango_maker.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%c", &ar[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 217 ms 70780 KB Output is correct
2 Correct 65 ms 70780 KB Output is correct
3 Correct 70 ms 70880 KB Output is correct
4 Correct 65 ms 71008 KB Output is correct
5 Correct 79 ms 71008 KB Output is correct
6 Correct 63 ms 71008 KB Output is correct
7 Correct 63 ms 71112 KB Output is correct
8 Correct 63 ms 71112 KB Output is correct
9 Correct 62 ms 71112 KB Output is correct
10 Correct 67 ms 71168 KB Output is correct
11 Correct 65 ms 71224 KB Output is correct
12 Correct 64 ms 71224 KB Output is correct
13 Correct 63 ms 71224 KB Output is correct
14 Correct 62 ms 71224 KB Output is correct
15 Correct 66 ms 71224 KB Output is correct
16 Correct 63 ms 71224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 70780 KB Output is correct
2 Correct 65 ms 70780 KB Output is correct
3 Correct 70 ms 70880 KB Output is correct
4 Correct 65 ms 71008 KB Output is correct
5 Correct 79 ms 71008 KB Output is correct
6 Correct 63 ms 71008 KB Output is correct
7 Correct 63 ms 71112 KB Output is correct
8 Correct 63 ms 71112 KB Output is correct
9 Correct 62 ms 71112 KB Output is correct
10 Correct 67 ms 71168 KB Output is correct
11 Correct 65 ms 71224 KB Output is correct
12 Correct 64 ms 71224 KB Output is correct
13 Correct 63 ms 71224 KB Output is correct
14 Correct 62 ms 71224 KB Output is correct
15 Correct 66 ms 71224 KB Output is correct
16 Correct 63 ms 71224 KB Output is correct
17 Correct 62 ms 71248 KB Output is correct
18 Correct 62 ms 71248 KB Output is correct
19 Correct 64 ms 71248 KB Output is correct
20 Correct 63 ms 71248 KB Output is correct
21 Correct 63 ms 71248 KB Output is correct
22 Correct 62 ms 71248 KB Output is correct
23 Correct 63 ms 71248 KB Output is correct
24 Correct 65 ms 71248 KB Output is correct
25 Correct 63 ms 71248 KB Output is correct
26 Correct 64 ms 71248 KB Output is correct
27 Correct 64 ms 71376 KB Output is correct
28 Correct 67 ms 71376 KB Output is correct
29 Correct 67 ms 71376 KB Output is correct
30 Correct 65 ms 71376 KB Output is correct
31 Correct 62 ms 71376 KB Output is correct
32 Correct 64 ms 71376 KB Output is correct
33 Correct 62 ms 71376 KB Output is correct
34 Incorrect 67 ms 71376 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 217 ms 70780 KB Output is correct
2 Correct 65 ms 70780 KB Output is correct
3 Correct 70 ms 70880 KB Output is correct
4 Correct 65 ms 71008 KB Output is correct
5 Correct 79 ms 71008 KB Output is correct
6 Correct 63 ms 71008 KB Output is correct
7 Correct 63 ms 71112 KB Output is correct
8 Correct 63 ms 71112 KB Output is correct
9 Correct 62 ms 71112 KB Output is correct
10 Correct 67 ms 71168 KB Output is correct
11 Correct 65 ms 71224 KB Output is correct
12 Correct 64 ms 71224 KB Output is correct
13 Correct 63 ms 71224 KB Output is correct
14 Correct 62 ms 71224 KB Output is correct
15 Correct 66 ms 71224 KB Output is correct
16 Correct 63 ms 71224 KB Output is correct
17 Correct 62 ms 71248 KB Output is correct
18 Correct 62 ms 71248 KB Output is correct
19 Correct 64 ms 71248 KB Output is correct
20 Correct 63 ms 71248 KB Output is correct
21 Correct 63 ms 71248 KB Output is correct
22 Correct 62 ms 71248 KB Output is correct
23 Correct 63 ms 71248 KB Output is correct
24 Correct 65 ms 71248 KB Output is correct
25 Correct 63 ms 71248 KB Output is correct
26 Correct 64 ms 71248 KB Output is correct
27 Correct 64 ms 71376 KB Output is correct
28 Correct 67 ms 71376 KB Output is correct
29 Correct 67 ms 71376 KB Output is correct
30 Correct 65 ms 71376 KB Output is correct
31 Correct 62 ms 71376 KB Output is correct
32 Correct 64 ms 71376 KB Output is correct
33 Correct 62 ms 71376 KB Output is correct
34 Incorrect 67 ms 71376 KB Output isn't correct
35 Halted 0 ms 0 KB -