Submission #1007364

# Submission time Handle Problem Language Result Execution time Memory
1007364 2024-06-24T17:24:04 Z Otalp Dango Maker (JOI18_dango_maker) C++14
33 / 100
400 ms 262192 KB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define pll pair<ll, ll>
#define pb push_back


const int MAXLS = 5000000;
int dq[3010][3010];
int a[3021][3021];
int kto[MAXLS];
int cnt[3];
int pos[MAXLS];
vector<int> q[MAXLS];
vector<int> ord;
int c[MAXLS];

void dfs(int v){
    pos[v] = 1;
    cnt[kto[v]] ++;
    ord.pb(v);
    for(int to: q[v]){
        if(pos[to]) continue;
        dfs(to);
    }
}

void add(int i, int j, int x){
    if(dq[i][j] != -1) q[dq[i][j]].pb(x), q[x].pb(dq[i][j]);
    dq[i][j] = x;
}


void solve(){   
    int n, m;
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            char c;
            cin>>c;
            a[i][j] = c;
            dq[i][j] = -1;
        }
    }
    int ls = 0;

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(j >= 3 and a[i][j] == 'W' and a[i][j-1] == 'G' and a[i][j - 2] == 'R'){
                ls ++;
                //cout<<i<<' '<<j<<' '<<ls<<"v\n";
                add(i, j, ls);
                add(i, j-1, ls);
                add(i, j-2, ls);
                kto[ls] = 1;
            }
            if(i >= 3 and a[i][j] == 'W' and a[i-1][j] == 'G' and a[i-2][j] == 'R'){
                ls ++;
                //cout<<i<<' '<<j<<' '<<ls<<"h\n";
                add(i, j, ls);
                add(i-1, j, ls);
                add(i-2, j, ls);
                kto[ls] = 2;
            }
        }
    }
    ll ans = 0;
    //cout<<ls<<'\n';
    for(int i=1; i<=ls; i++){
        if(pos[i]) continue;
        cnt[1] = cnt[2] = 0;
        ord.clear();
        dfs(i);
        int res = 0;
        for(int k=0; k<(1 << ord.size()); k++){
            for(int i=0; i<ord.size(); i++){
                if((k&(1<<i))){
                    c[ord[i]] = 1;
                }
                else c[ord[i]] = 0;
            }
            int ok = 1;
            for(int v: ord){
                for(int to: q[v]){
                    if(c[to] and c[v]){
                        ok = 0;
                        break;
                    }
                }
            }
            if(ok){
                res = max(res, __builtin_popcount(k));
            }
        }
        ans += res;
        //cout<<res<<'\n';

    }
    cout<<ans<<'\n';
}

int main(){
    solve();
}

Compilation message

dango_maker.cpp: In function 'void solve()':
dango_maker.cpp:79:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |             for(int i=0; i<ord.size(); i++){
      |                          ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 18 ms 123484 KB Output is correct
2 Correct 18 ms 123484 KB Output is correct
3 Correct 18 ms 123548 KB Output is correct
4 Correct 21 ms 123484 KB Output is correct
5 Correct 19 ms 123484 KB Output is correct
6 Correct 18 ms 125616 KB Output is correct
7 Correct 18 ms 125528 KB Output is correct
8 Correct 20 ms 125532 KB Output is correct
9 Correct 18 ms 125528 KB Output is correct
10 Correct 19 ms 125532 KB Output is correct
11 Correct 19 ms 125532 KB Output is correct
12 Correct 18 ms 125532 KB Output is correct
13 Correct 19 ms 125404 KB Output is correct
14 Correct 18 ms 125528 KB Output is correct
15 Correct 18 ms 125532 KB Output is correct
16 Correct 19 ms 125608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 123484 KB Output is correct
2 Correct 18 ms 123484 KB Output is correct
3 Correct 18 ms 123548 KB Output is correct
4 Correct 21 ms 123484 KB Output is correct
5 Correct 19 ms 123484 KB Output is correct
6 Correct 18 ms 125616 KB Output is correct
7 Correct 18 ms 125528 KB Output is correct
8 Correct 20 ms 125532 KB Output is correct
9 Correct 18 ms 125528 KB Output is correct
10 Correct 19 ms 125532 KB Output is correct
11 Correct 19 ms 125532 KB Output is correct
12 Correct 18 ms 125532 KB Output is correct
13 Correct 19 ms 125404 KB Output is correct
14 Correct 18 ms 125528 KB Output is correct
15 Correct 18 ms 125532 KB Output is correct
16 Correct 19 ms 125608 KB Output is correct
17 Correct 18 ms 125528 KB Output is correct
18 Correct 19 ms 125528 KB Output is correct
19 Correct 20 ms 125532 KB Output is correct
20 Correct 18 ms 125528 KB Output is correct
21 Correct 21 ms 125528 KB Output is correct
22 Correct 20 ms 125528 KB Output is correct
23 Correct 18 ms 125532 KB Output is correct
24 Correct 18 ms 125532 KB Output is correct
25 Correct 18 ms 123480 KB Output is correct
26 Correct 18 ms 123484 KB Output is correct
27 Correct 22 ms 125532 KB Output is correct
28 Correct 21 ms 125612 KB Output is correct
29 Correct 21 ms 125528 KB Output is correct
30 Correct 18 ms 125532 KB Output is correct
31 Correct 23 ms 125532 KB Output is correct
32 Correct 19 ms 125532 KB Output is correct
33 Correct 24 ms 125468 KB Output is correct
34 Correct 23 ms 125528 KB Output is correct
35 Correct 32 ms 125532 KB Output is correct
36 Correct 30 ms 125604 KB Output is correct
37 Correct 17 ms 125412 KB Output is correct
38 Correct 25 ms 125524 KB Output is correct
39 Correct 21 ms 125532 KB Output is correct
40 Correct 29 ms 125604 KB Output is correct
41 Correct 22 ms 125532 KB Output is correct
42 Correct 18 ms 125532 KB Output is correct
43 Correct 22 ms 125616 KB Output is correct
44 Correct 23 ms 125784 KB Output is correct
45 Correct 22 ms 125528 KB Output is correct
46 Correct 19 ms 125532 KB Output is correct
47 Correct 18 ms 125528 KB Output is correct
48 Correct 20 ms 125532 KB Output is correct
49 Correct 18 ms 125532 KB Output is correct
50 Correct 20 ms 125476 KB Output is correct
51 Correct 20 ms 125528 KB Output is correct
52 Correct 21 ms 125532 KB Output is correct
53 Correct 20 ms 125532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 123484 KB Output is correct
2 Correct 18 ms 123484 KB Output is correct
3 Correct 18 ms 123548 KB Output is correct
4 Correct 21 ms 123484 KB Output is correct
5 Correct 19 ms 123484 KB Output is correct
6 Correct 18 ms 125616 KB Output is correct
7 Correct 18 ms 125528 KB Output is correct
8 Correct 20 ms 125532 KB Output is correct
9 Correct 18 ms 125528 KB Output is correct
10 Correct 19 ms 125532 KB Output is correct
11 Correct 19 ms 125532 KB Output is correct
12 Correct 18 ms 125532 KB Output is correct
13 Correct 19 ms 125404 KB Output is correct
14 Correct 18 ms 125528 KB Output is correct
15 Correct 18 ms 125532 KB Output is correct
16 Correct 19 ms 125608 KB Output is correct
17 Correct 18 ms 125528 KB Output is correct
18 Correct 19 ms 125528 KB Output is correct
19 Correct 20 ms 125532 KB Output is correct
20 Correct 18 ms 125528 KB Output is correct
21 Correct 21 ms 125528 KB Output is correct
22 Correct 20 ms 125528 KB Output is correct
23 Correct 18 ms 125532 KB Output is correct
24 Correct 18 ms 125532 KB Output is correct
25 Correct 18 ms 123480 KB Output is correct
26 Correct 18 ms 123484 KB Output is correct
27 Correct 22 ms 125532 KB Output is correct
28 Correct 21 ms 125612 KB Output is correct
29 Correct 21 ms 125528 KB Output is correct
30 Correct 18 ms 125532 KB Output is correct
31 Correct 23 ms 125532 KB Output is correct
32 Correct 19 ms 125532 KB Output is correct
33 Correct 24 ms 125468 KB Output is correct
34 Correct 23 ms 125528 KB Output is correct
35 Correct 32 ms 125532 KB Output is correct
36 Correct 30 ms 125604 KB Output is correct
37 Correct 17 ms 125412 KB Output is correct
38 Correct 25 ms 125524 KB Output is correct
39 Correct 21 ms 125532 KB Output is correct
40 Correct 29 ms 125604 KB Output is correct
41 Correct 22 ms 125532 KB Output is correct
42 Correct 18 ms 125532 KB Output is correct
43 Correct 22 ms 125616 KB Output is correct
44 Correct 23 ms 125784 KB Output is correct
45 Correct 22 ms 125528 KB Output is correct
46 Correct 19 ms 125532 KB Output is correct
47 Correct 18 ms 125528 KB Output is correct
48 Correct 20 ms 125532 KB Output is correct
49 Correct 18 ms 125532 KB Output is correct
50 Correct 20 ms 125476 KB Output is correct
51 Correct 20 ms 125528 KB Output is correct
52 Correct 21 ms 125532 KB Output is correct
53 Correct 20 ms 125532 KB Output is correct
54 Correct 19 ms 125528 KB Output is correct
55 Correct 25 ms 193364 KB Output is correct
56 Correct 21 ms 125532 KB Output is correct
57 Correct 24 ms 172636 KB Output is correct
58 Correct 57 ms 152144 KB Output is correct
59 Correct 331 ms 217488 KB Output is correct
60 Correct 339 ms 217428 KB Output is correct
61 Correct 381 ms 217428 KB Output is correct
62 Correct 24 ms 125784 KB Output is correct
63 Correct 314 ms 216720 KB Output is correct
64 Runtime error 400 ms 262192 KB Execution killed with signal 9
65 Halted 0 ms 0 KB -