Submission #64983

# Submission time Handle Problem Language Result Execution time Memory
64983 2018-08-06T11:10:36 Z patrikpavic2 Dango Maker (JOI18_dango_maker) C++17
33 / 100
62 ms 38004 KB
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

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

vector < int > v[M], k[N][N];

int ty[M], sl[M], bio[M], 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:42: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:45: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 36 ms 37368 KB Output is correct
2 Correct 35 ms 37488 KB Output is correct
3 Correct 36 ms 37488 KB Output is correct
4 Correct 35 ms 37520 KB Output is correct
5 Correct 37 ms 37652 KB Output is correct
6 Correct 62 ms 37652 KB Output is correct
7 Correct 61 ms 37652 KB Output is correct
8 Correct 36 ms 37652 KB Output is correct
9 Correct 38 ms 37708 KB Output is correct
10 Correct 44 ms 37708 KB Output is correct
11 Correct 36 ms 37708 KB Output is correct
12 Correct 35 ms 37708 KB Output is correct
13 Correct 38 ms 37708 KB Output is correct
14 Correct 38 ms 37708 KB Output is correct
15 Correct 38 ms 37708 KB Output is correct
16 Correct 49 ms 37768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 37368 KB Output is correct
2 Correct 35 ms 37488 KB Output is correct
3 Correct 36 ms 37488 KB Output is correct
4 Correct 35 ms 37520 KB Output is correct
5 Correct 37 ms 37652 KB Output is correct
6 Correct 62 ms 37652 KB Output is correct
7 Correct 61 ms 37652 KB Output is correct
8 Correct 36 ms 37652 KB Output is correct
9 Correct 38 ms 37708 KB Output is correct
10 Correct 44 ms 37708 KB Output is correct
11 Correct 36 ms 37708 KB Output is correct
12 Correct 35 ms 37708 KB Output is correct
13 Correct 38 ms 37708 KB Output is correct
14 Correct 38 ms 37708 KB Output is correct
15 Correct 38 ms 37708 KB Output is correct
16 Correct 49 ms 37768 KB Output is correct
17 Correct 38 ms 37772 KB Output is correct
18 Correct 36 ms 37776 KB Output is correct
19 Correct 35 ms 37780 KB Output is correct
20 Correct 42 ms 37784 KB Output is correct
21 Correct 40 ms 37920 KB Output is correct
22 Correct 39 ms 37920 KB Output is correct
23 Correct 41 ms 37920 KB Output is correct
24 Correct 40 ms 37920 KB Output is correct
25 Correct 39 ms 37920 KB Output is correct
26 Correct 40 ms 37920 KB Output is correct
27 Correct 39 ms 37920 KB Output is correct
28 Correct 42 ms 37920 KB Output is correct
29 Correct 37 ms 37920 KB Output is correct
30 Correct 38 ms 37920 KB Output is correct
31 Correct 43 ms 37936 KB Output is correct
32 Correct 40 ms 37936 KB Output is correct
33 Correct 39 ms 37936 KB Output is correct
34 Correct 38 ms 37936 KB Output is correct
35 Correct 37 ms 37936 KB Output is correct
36 Correct 37 ms 37936 KB Output is correct
37 Correct 40 ms 37996 KB Output is correct
38 Correct 37 ms 38004 KB Output is correct
39 Correct 38 ms 38004 KB Output is correct
40 Correct 42 ms 38004 KB Output is correct
41 Correct 52 ms 38004 KB Output is correct
42 Correct 38 ms 38004 KB Output is correct
43 Correct 39 ms 38004 KB Output is correct
44 Correct 35 ms 38004 KB Output is correct
45 Correct 39 ms 38004 KB Output is correct
46 Correct 41 ms 38004 KB Output is correct
47 Correct 42 ms 38004 KB Output is correct
48 Correct 50 ms 38004 KB Output is correct
49 Correct 35 ms 38004 KB Output is correct
50 Correct 36 ms 38004 KB Output is correct
51 Correct 36 ms 38004 KB Output is correct
52 Correct 37 ms 38004 KB Output is correct
53 Correct 34 ms 38004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 37368 KB Output is correct
2 Correct 35 ms 37488 KB Output is correct
3 Correct 36 ms 37488 KB Output is correct
4 Correct 35 ms 37520 KB Output is correct
5 Correct 37 ms 37652 KB Output is correct
6 Correct 62 ms 37652 KB Output is correct
7 Correct 61 ms 37652 KB Output is correct
8 Correct 36 ms 37652 KB Output is correct
9 Correct 38 ms 37708 KB Output is correct
10 Correct 44 ms 37708 KB Output is correct
11 Correct 36 ms 37708 KB Output is correct
12 Correct 35 ms 37708 KB Output is correct
13 Correct 38 ms 37708 KB Output is correct
14 Correct 38 ms 37708 KB Output is correct
15 Correct 38 ms 37708 KB Output is correct
16 Correct 49 ms 37768 KB Output is correct
17 Correct 38 ms 37772 KB Output is correct
18 Correct 36 ms 37776 KB Output is correct
19 Correct 35 ms 37780 KB Output is correct
20 Correct 42 ms 37784 KB Output is correct
21 Correct 40 ms 37920 KB Output is correct
22 Correct 39 ms 37920 KB Output is correct
23 Correct 41 ms 37920 KB Output is correct
24 Correct 40 ms 37920 KB Output is correct
25 Correct 39 ms 37920 KB Output is correct
26 Correct 40 ms 37920 KB Output is correct
27 Correct 39 ms 37920 KB Output is correct
28 Correct 42 ms 37920 KB Output is correct
29 Correct 37 ms 37920 KB Output is correct
30 Correct 38 ms 37920 KB Output is correct
31 Correct 43 ms 37936 KB Output is correct
32 Correct 40 ms 37936 KB Output is correct
33 Correct 39 ms 37936 KB Output is correct
34 Correct 38 ms 37936 KB Output is correct
35 Correct 37 ms 37936 KB Output is correct
36 Correct 37 ms 37936 KB Output is correct
37 Correct 40 ms 37996 KB Output is correct
38 Correct 37 ms 38004 KB Output is correct
39 Correct 38 ms 38004 KB Output is correct
40 Correct 42 ms 38004 KB Output is correct
41 Correct 52 ms 38004 KB Output is correct
42 Correct 38 ms 38004 KB Output is correct
43 Correct 39 ms 38004 KB Output is correct
44 Correct 35 ms 38004 KB Output is correct
45 Correct 39 ms 38004 KB Output is correct
46 Correct 41 ms 38004 KB Output is correct
47 Correct 42 ms 38004 KB Output is correct
48 Correct 50 ms 38004 KB Output is correct
49 Correct 35 ms 38004 KB Output is correct
50 Correct 36 ms 38004 KB Output is correct
51 Correct 36 ms 38004 KB Output is correct
52 Correct 37 ms 38004 KB Output is correct
53 Correct 34 ms 38004 KB Output is correct
54 Incorrect 38 ms 38004 KB Output isn't correct
55 Halted 0 ms 0 KB -