Submission #64990

# Submission time Handle Problem Language Result Execution time Memory
64990 2018-08-06T11:26:59 Z patrikpavic2 Dango Maker (JOI18_dango_maker) C++17
13 / 100
85 ms 60780 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];

bool bio[M], ty[M];
int mat[M], kk[N][N][2];
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;
            int kol = 0;
            if(s[i - 1][j] == 'R' && s[i + 1][j] == 'W'){
                kk[i][j][0] = cnt;
                cnt++;kol++;
            }
            if(s[i][j - 1] == 'R' && s[i][j + 1] == 'W'){
                ty[cnt] = 1;
                kk[i][j][1] = cnt;
                cnt++;kol++;
            }
            if(kol == 2){
                v[cnt - 1].push_back(cnt - 2);
                v[cnt - 2].push_back(cnt - 1);
            }
        }
    }
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            if(s[i][j] == 'R' && s[i + 1][j] == 'G' && s[i][j + 1] == 'G' && s[i + 2][j] == 'W' && s[i][j + 2] == 'W'){
                v[kk[i + 1][j][0]].push_back(kk[i][j + 1][1]);
                v[kk[i][j + 1][1]].push_back(kk[i + 1][j][0]);
            }
            if(i > 1 && j > 1 && s[i][j] == 'W' && s[i - 1][j] == 'G' && s[i][j - 1] == 'G' && s[i - 2][j] == 'R' && s[i][j - 2] == 'R'){
                v[kk[i - 1][j][0]].push_back(kk[i][j - 1][1]);
                v[kk[i][j - 1][1]].push_back(kk[i - 1][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 54 ms 60408 KB Output is correct
2 Correct 58 ms 60472 KB Output is correct
3 Correct 65 ms 60556 KB Output is correct
4 Correct 53 ms 60556 KB Output is correct
5 Correct 71 ms 60556 KB Output is correct
6 Correct 60 ms 60628 KB Output is correct
7 Correct 84 ms 60628 KB Output is correct
8 Correct 67 ms 60704 KB Output is correct
9 Correct 65 ms 60704 KB Output is correct
10 Correct 64 ms 60704 KB Output is correct
11 Correct 56 ms 60780 KB Output is correct
12 Correct 55 ms 60780 KB Output is correct
13 Correct 63 ms 60780 KB Output is correct
14 Correct 85 ms 60780 KB Output is correct
15 Correct 67 ms 60780 KB Output is correct
16 Correct 70 ms 60780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 60408 KB Output is correct
2 Correct 58 ms 60472 KB Output is correct
3 Correct 65 ms 60556 KB Output is correct
4 Correct 53 ms 60556 KB Output is correct
5 Correct 71 ms 60556 KB Output is correct
6 Correct 60 ms 60628 KB Output is correct
7 Correct 84 ms 60628 KB Output is correct
8 Correct 67 ms 60704 KB Output is correct
9 Correct 65 ms 60704 KB Output is correct
10 Correct 64 ms 60704 KB Output is correct
11 Correct 56 ms 60780 KB Output is correct
12 Correct 55 ms 60780 KB Output is correct
13 Correct 63 ms 60780 KB Output is correct
14 Correct 85 ms 60780 KB Output is correct
15 Correct 67 ms 60780 KB Output is correct
16 Correct 70 ms 60780 KB Output is correct
17 Correct 64 ms 60780 KB Output is correct
18 Correct 64 ms 60780 KB Output is correct
19 Correct 59 ms 60780 KB Output is correct
20 Correct 62 ms 60780 KB Output is correct
21 Correct 65 ms 60780 KB Output is correct
22 Correct 60 ms 60780 KB Output is correct
23 Correct 64 ms 60780 KB Output is correct
24 Correct 58 ms 60780 KB Output is correct
25 Correct 62 ms 60780 KB Output is correct
26 Correct 54 ms 60780 KB Output is correct
27 Incorrect 53 ms 60780 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 60408 KB Output is correct
2 Correct 58 ms 60472 KB Output is correct
3 Correct 65 ms 60556 KB Output is correct
4 Correct 53 ms 60556 KB Output is correct
5 Correct 71 ms 60556 KB Output is correct
6 Correct 60 ms 60628 KB Output is correct
7 Correct 84 ms 60628 KB Output is correct
8 Correct 67 ms 60704 KB Output is correct
9 Correct 65 ms 60704 KB Output is correct
10 Correct 64 ms 60704 KB Output is correct
11 Correct 56 ms 60780 KB Output is correct
12 Correct 55 ms 60780 KB Output is correct
13 Correct 63 ms 60780 KB Output is correct
14 Correct 85 ms 60780 KB Output is correct
15 Correct 67 ms 60780 KB Output is correct
16 Correct 70 ms 60780 KB Output is correct
17 Correct 64 ms 60780 KB Output is correct
18 Correct 64 ms 60780 KB Output is correct
19 Correct 59 ms 60780 KB Output is correct
20 Correct 62 ms 60780 KB Output is correct
21 Correct 65 ms 60780 KB Output is correct
22 Correct 60 ms 60780 KB Output is correct
23 Correct 64 ms 60780 KB Output is correct
24 Correct 58 ms 60780 KB Output is correct
25 Correct 62 ms 60780 KB Output is correct
26 Correct 54 ms 60780 KB Output is correct
27 Incorrect 53 ms 60780 KB Output isn't correct
28 Halted 0 ms 0 KB -