답안 #889327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889327 2023-12-19T11:14:07 Z alexander707070 Dango Maker (JOI18_dango_maker) C++14
33 / 100
57 ms 262144 KB
#include<bits/stdc++.h>
#define MAXN 10000007
using namespace std;

struct edge{
    int to,flow,cap,rev;
};

int n,m;
char t[3007][3007];

vector<edge> v[MAXN];
int s[MAXN],cnt1,cnt2,ans;
int num[3007][3007],num2[3007][3007],total;

int flow,maxflow,source,sink;
int li[MAXN],tim;

void add_edge(int from,int to){
    v[from].push_back({to,0,1,int(v[to].size())});
    v[to].push_back({from,0,0,int(v[from].size())-1});
}

int dfs(int x,int mins){
    if(x==sink)return mins;

    li[x]=tim;
    for(int i=0;i<v[x].size();i++){
        if(li[v[x][i].to]==tim or v[x][i].cap-v[x][i].flow<=0)continue;
        int curr=dfs(v[x][i].to,1);

        if(curr>0){
            v[x][i].flow+=curr;
            v[v[x][i].to][v[x][i].rev].flow-=curr;
            return curr;
        }
    }

    return 0;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;

    for(int i=0;i<=n+1;i++){
        for(int f=0;f<=m+1;f++){
            t[i][f]='#';
        }
    }

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            cin>>t[i][f];
        }
    }

    source=0; sink=n*m;

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){

            if(t[i][f]=='R' and t[i][f+1]=='G' and t[i][f+2]=='W'){
                total++; num[i][f]=total;
                add_edge(source,total);
            }
            if(t[i][f]=='R' and t[i+1][f]=='G' and t[i+2][f]=='W'){
                total++; num2[i][f]=total;
                add_edge(total,sink);
            }

            if(t[i][f]=='R' and t[i][f+1]=='G' and t[i][f+2]=='W' and t[i+1][f]=='G' and t[i+2][f]=='W'){
                add_edge(num[i][f],num2[i][f]);
            }
        }
    }

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            if(t[i][f]=='G' and t[i][f-1]=='R' and t[i][f+1]=='W' and t[i-1][f]=='R' and t[i+1][f]=='W'){
                add_edge(num[i][f-1],num2[i-1][f]);
            }
        }
    }

    for(int i=2;i<=n;i++){
        for(int f=2;f<=m;f++){
            if(t[i][f]=='W' and t[i][f-2]=='R' and t[i][f-1]=='G' and t[i-2][f]=='R' and t[i-1][f]=='G'){
                add_edge(num[i][f-2],num2[i-2][f]);
            }
        }
    }

    while(true){
        tim++;
        flow=dfs(source,1);
        if(flow==0)break;
        maxflow+=flow;
    }

    cout<<total-maxflow<<"\n";

    return 0;
}

Compilation message

dango_maker.cpp: In function 'int dfs(int, int)':
dango_maker.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<edge>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<v[x].size();i++){
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 238420 KB Output is correct
2 Correct 53 ms 238672 KB Output is correct
3 Correct 49 ms 238416 KB Output is correct
4 Correct 50 ms 238468 KB Output is correct
5 Correct 51 ms 240520 KB Output is correct
6 Correct 50 ms 242572 KB Output is correct
7 Correct 50 ms 242512 KB Output is correct
8 Correct 51 ms 242780 KB Output is correct
9 Correct 50 ms 240468 KB Output is correct
10 Correct 51 ms 240464 KB Output is correct
11 Correct 52 ms 242512 KB Output is correct
12 Correct 50 ms 242568 KB Output is correct
13 Correct 50 ms 242508 KB Output is correct
14 Correct 50 ms 240472 KB Output is correct
15 Correct 50 ms 240308 KB Output is correct
16 Correct 51 ms 240476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 238420 KB Output is correct
2 Correct 53 ms 238672 KB Output is correct
3 Correct 49 ms 238416 KB Output is correct
4 Correct 50 ms 238468 KB Output is correct
5 Correct 51 ms 240520 KB Output is correct
6 Correct 50 ms 242572 KB Output is correct
7 Correct 50 ms 242512 KB Output is correct
8 Correct 51 ms 242780 KB Output is correct
9 Correct 50 ms 240468 KB Output is correct
10 Correct 51 ms 240464 KB Output is correct
11 Correct 52 ms 242512 KB Output is correct
12 Correct 50 ms 242568 KB Output is correct
13 Correct 50 ms 242508 KB Output is correct
14 Correct 50 ms 240472 KB Output is correct
15 Correct 50 ms 240308 KB Output is correct
16 Correct 51 ms 240476 KB Output is correct
17 Correct 51 ms 244572 KB Output is correct
18 Correct 52 ms 244560 KB Output is correct
19 Correct 50 ms 244564 KB Output is correct
20 Correct 51 ms 244564 KB Output is correct
21 Correct 51 ms 244564 KB Output is correct
22 Correct 51 ms 244408 KB Output is correct
23 Correct 51 ms 244572 KB Output is correct
24 Correct 50 ms 242376 KB Output is correct
25 Correct 50 ms 240468 KB Output is correct
26 Correct 49 ms 238412 KB Output is correct
27 Correct 53 ms 244440 KB Output is correct
28 Correct 50 ms 244628 KB Output is correct
29 Correct 51 ms 244560 KB Output is correct
30 Correct 50 ms 242512 KB Output is correct
31 Correct 50 ms 242516 KB Output is correct
32 Correct 51 ms 242464 KB Output is correct
33 Correct 52 ms 244696 KB Output is correct
34 Correct 51 ms 244572 KB Output is correct
35 Correct 51 ms 244560 KB Output is correct
36 Correct 51 ms 244556 KB Output is correct
37 Correct 51 ms 244564 KB Output is correct
38 Correct 52 ms 244560 KB Output is correct
39 Correct 51 ms 244564 KB Output is correct
40 Correct 50 ms 244628 KB Output is correct
41 Correct 51 ms 244524 KB Output is correct
42 Correct 51 ms 244560 KB Output is correct
43 Correct 50 ms 244424 KB Output is correct
44 Correct 53 ms 244564 KB Output is correct
45 Correct 50 ms 244464 KB Output is correct
46 Correct 51 ms 244560 KB Output is correct
47 Correct 51 ms 244572 KB Output is correct
48 Correct 52 ms 244564 KB Output is correct
49 Correct 52 ms 244564 KB Output is correct
50 Correct 51 ms 244624 KB Output is correct
51 Correct 50 ms 244624 KB Output is correct
52 Correct 51 ms 244824 KB Output is correct
53 Correct 50 ms 244628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 238420 KB Output is correct
2 Correct 53 ms 238672 KB Output is correct
3 Correct 49 ms 238416 KB Output is correct
4 Correct 50 ms 238468 KB Output is correct
5 Correct 51 ms 240520 KB Output is correct
6 Correct 50 ms 242572 KB Output is correct
7 Correct 50 ms 242512 KB Output is correct
8 Correct 51 ms 242780 KB Output is correct
9 Correct 50 ms 240468 KB Output is correct
10 Correct 51 ms 240464 KB Output is correct
11 Correct 52 ms 242512 KB Output is correct
12 Correct 50 ms 242568 KB Output is correct
13 Correct 50 ms 242508 KB Output is correct
14 Correct 50 ms 240472 KB Output is correct
15 Correct 50 ms 240308 KB Output is correct
16 Correct 51 ms 240476 KB Output is correct
17 Correct 51 ms 244572 KB Output is correct
18 Correct 52 ms 244560 KB Output is correct
19 Correct 50 ms 244564 KB Output is correct
20 Correct 51 ms 244564 KB Output is correct
21 Correct 51 ms 244564 KB Output is correct
22 Correct 51 ms 244408 KB Output is correct
23 Correct 51 ms 244572 KB Output is correct
24 Correct 50 ms 242376 KB Output is correct
25 Correct 50 ms 240468 KB Output is correct
26 Correct 49 ms 238412 KB Output is correct
27 Correct 53 ms 244440 KB Output is correct
28 Correct 50 ms 244628 KB Output is correct
29 Correct 51 ms 244560 KB Output is correct
30 Correct 50 ms 242512 KB Output is correct
31 Correct 50 ms 242516 KB Output is correct
32 Correct 51 ms 242464 KB Output is correct
33 Correct 52 ms 244696 KB Output is correct
34 Correct 51 ms 244572 KB Output is correct
35 Correct 51 ms 244560 KB Output is correct
36 Correct 51 ms 244556 KB Output is correct
37 Correct 51 ms 244564 KB Output is correct
38 Correct 52 ms 244560 KB Output is correct
39 Correct 51 ms 244564 KB Output is correct
40 Correct 50 ms 244628 KB Output is correct
41 Correct 51 ms 244524 KB Output is correct
42 Correct 51 ms 244560 KB Output is correct
43 Correct 50 ms 244424 KB Output is correct
44 Correct 53 ms 244564 KB Output is correct
45 Correct 50 ms 244464 KB Output is correct
46 Correct 51 ms 244560 KB Output is correct
47 Correct 51 ms 244572 KB Output is correct
48 Correct 52 ms 244564 KB Output is correct
49 Correct 52 ms 244564 KB Output is correct
50 Correct 51 ms 244624 KB Output is correct
51 Correct 50 ms 244624 KB Output is correct
52 Correct 51 ms 244824 KB Output is correct
53 Correct 50 ms 244628 KB Output is correct
54 Correct 50 ms 240468 KB Output is correct
55 Correct 57 ms 261712 KB Output is correct
56 Correct 54 ms 244724 KB Output is correct
57 Runtime error 38 ms 262144 KB Execution killed with signal 9
58 Halted 0 ms 0 KB -