Submission #64988

# Submission time Handle Problem Language Result Execution time Memory
64988 2018-08-06T11:16:28 Z patrikpavic2 Dango Maker (JOI18_dango_maker) C++17
33 / 100
250 ms 210996 KB
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

const int N = 3e3 + 50;
const int M = N * N / 5;

vector < int > v[M], k[1905][1005];

bool bio[M], ty[M];
int mat[M];
char s[N][N];
int n, m, edg, cnt = 1;

int dfs( int node ) {
    if( bio[ node ] ) return 0;
    bio[ node ] = 1;
    for(int sus : v[node]){
        if( mat[ sus ] == -1 || dfs( mat[ sus ]) ) {
            mat[ sus ] = node;
            return 1;
        }
    }
    return 0;
}

int matching( ) {
    int sol = 0;
    memset( mat, -1, sizeof( mat ) );
    for( int i = 1; i < cnt; i++) {
        if(ty[i]) continue;
        sol += dfs(i);

    }
    return sol;
}


int main(){
    memset(s, '.', sizeof(s));
    scanf("%d%d", &n, &m);
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            scanf(" %c", &s[i][j]);
        }
    }
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            if(s[i][j] != 'G') continue;
            if(s[i - 1][j] == 'R' && s[i + 1][j] == 'W'){
                k[i - 1][j].push_back(cnt);
                k[i + 1][j].push_back(cnt);
                k[i][j].push_back(cnt);
                cnt++;
            }
            if(s[i][j - 1] == 'R' && s[i][j + 1] == 'W'){
                k[i][j - 1].push_back(cnt);
                k[i][j + 1].push_back(cnt);
                k[i][j].push_back(cnt);
                ty[cnt] = 1;
                cnt++;
            }
        }
    }
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            if(k[i][j].size() == 2){
                v[k[i][j][0]].push_back(k[i][j][1]);
                v[k[i][j][1]].push_back(k[i][j][0]);
            }
        }
    }
    printf("%d\n", cnt - matching() - 1);
    return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:46:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c", &s[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 107 ms 105336 KB Output is correct
2 Correct 102 ms 105336 KB Output is correct
3 Correct 110 ms 105520 KB Output is correct
4 Correct 106 ms 105520 KB Output is correct
5 Correct 105 ms 105520 KB Output is correct
6 Correct 135 ms 105520 KB Output is correct
7 Correct 103 ms 105520 KB Output is correct
8 Correct 93 ms 105552 KB Output is correct
9 Correct 108 ms 105552 KB Output is correct
10 Correct 90 ms 105552 KB Output is correct
11 Correct 91 ms 105564 KB Output is correct
12 Correct 105 ms 105732 KB Output is correct
13 Correct 102 ms 105732 KB Output is correct
14 Correct 93 ms 105732 KB Output is correct
15 Correct 103 ms 105732 KB Output is correct
16 Correct 108 ms 105732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 105336 KB Output is correct
2 Correct 102 ms 105336 KB Output is correct
3 Correct 110 ms 105520 KB Output is correct
4 Correct 106 ms 105520 KB Output is correct
5 Correct 105 ms 105520 KB Output is correct
6 Correct 135 ms 105520 KB Output is correct
7 Correct 103 ms 105520 KB Output is correct
8 Correct 93 ms 105552 KB Output is correct
9 Correct 108 ms 105552 KB Output is correct
10 Correct 90 ms 105552 KB Output is correct
11 Correct 91 ms 105564 KB Output is correct
12 Correct 105 ms 105732 KB Output is correct
13 Correct 102 ms 105732 KB Output is correct
14 Correct 93 ms 105732 KB Output is correct
15 Correct 103 ms 105732 KB Output is correct
16 Correct 108 ms 105732 KB Output is correct
17 Correct 101 ms 105732 KB Output is correct
18 Correct 102 ms 105732 KB Output is correct
19 Correct 98 ms 105732 KB Output is correct
20 Correct 102 ms 105732 KB Output is correct
21 Correct 111 ms 105800 KB Output is correct
22 Correct 144 ms 105800 KB Output is correct
23 Correct 105 ms 105800 KB Output is correct
24 Correct 105 ms 105800 KB Output is correct
25 Correct 100 ms 105800 KB Output is correct
26 Correct 100 ms 105800 KB Output is correct
27 Correct 104 ms 105800 KB Output is correct
28 Correct 106 ms 105800 KB Output is correct
29 Correct 95 ms 105800 KB Output is correct
30 Correct 106 ms 105800 KB Output is correct
31 Correct 104 ms 105800 KB Output is correct
32 Correct 100 ms 105800 KB Output is correct
33 Correct 116 ms 105800 KB Output is correct
34 Correct 120 ms 105800 KB Output is correct
35 Correct 104 ms 105800 KB Output is correct
36 Correct 101 ms 105800 KB Output is correct
37 Correct 105 ms 105800 KB Output is correct
38 Correct 96 ms 105800 KB Output is correct
39 Correct 111 ms 105800 KB Output is correct
40 Correct 114 ms 105800 KB Output is correct
41 Correct 101 ms 105800 KB Output is correct
42 Correct 102 ms 105800 KB Output is correct
43 Correct 96 ms 105800 KB Output is correct
44 Correct 103 ms 105800 KB Output is correct
45 Correct 96 ms 105800 KB Output is correct
46 Correct 103 ms 105800 KB Output is correct
47 Correct 95 ms 105800 KB Output is correct
48 Correct 88 ms 105800 KB Output is correct
49 Correct 99 ms 105800 KB Output is correct
50 Correct 92 ms 105800 KB Output is correct
51 Correct 95 ms 105800 KB Output is correct
52 Correct 94 ms 105800 KB Output is correct
53 Correct 87 ms 105800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 105336 KB Output is correct
2 Correct 102 ms 105336 KB Output is correct
3 Correct 110 ms 105520 KB Output is correct
4 Correct 106 ms 105520 KB Output is correct
5 Correct 105 ms 105520 KB Output is correct
6 Correct 135 ms 105520 KB Output is correct
7 Correct 103 ms 105520 KB Output is correct
8 Correct 93 ms 105552 KB Output is correct
9 Correct 108 ms 105552 KB Output is correct
10 Correct 90 ms 105552 KB Output is correct
11 Correct 91 ms 105564 KB Output is correct
12 Correct 105 ms 105732 KB Output is correct
13 Correct 102 ms 105732 KB Output is correct
14 Correct 93 ms 105732 KB Output is correct
15 Correct 103 ms 105732 KB Output is correct
16 Correct 108 ms 105732 KB Output is correct
17 Correct 101 ms 105732 KB Output is correct
18 Correct 102 ms 105732 KB Output is correct
19 Correct 98 ms 105732 KB Output is correct
20 Correct 102 ms 105732 KB Output is correct
21 Correct 111 ms 105800 KB Output is correct
22 Correct 144 ms 105800 KB Output is correct
23 Correct 105 ms 105800 KB Output is correct
24 Correct 105 ms 105800 KB Output is correct
25 Correct 100 ms 105800 KB Output is correct
26 Correct 100 ms 105800 KB Output is correct
27 Correct 104 ms 105800 KB Output is correct
28 Correct 106 ms 105800 KB Output is correct
29 Correct 95 ms 105800 KB Output is correct
30 Correct 106 ms 105800 KB Output is correct
31 Correct 104 ms 105800 KB Output is correct
32 Correct 100 ms 105800 KB Output is correct
33 Correct 116 ms 105800 KB Output is correct
34 Correct 120 ms 105800 KB Output is correct
35 Correct 104 ms 105800 KB Output is correct
36 Correct 101 ms 105800 KB Output is correct
37 Correct 105 ms 105800 KB Output is correct
38 Correct 96 ms 105800 KB Output is correct
39 Correct 111 ms 105800 KB Output is correct
40 Correct 114 ms 105800 KB Output is correct
41 Correct 101 ms 105800 KB Output is correct
42 Correct 102 ms 105800 KB Output is correct
43 Correct 96 ms 105800 KB Output is correct
44 Correct 103 ms 105800 KB Output is correct
45 Correct 96 ms 105800 KB Output is correct
46 Correct 103 ms 105800 KB Output is correct
47 Correct 95 ms 105800 KB Output is correct
48 Correct 88 ms 105800 KB Output is correct
49 Correct 99 ms 105800 KB Output is correct
50 Correct 92 ms 105800 KB Output is correct
51 Correct 95 ms 105800 KB Output is correct
52 Correct 94 ms 105800 KB Output is correct
53 Correct 87 ms 105800 KB Output is correct
54 Correct 105 ms 105800 KB Output is correct
55 Runtime error 250 ms 210996 KB Execution killed with signal 11 (could be triggered by violating memory limits)
56 Halted 0 ms 0 KB -