답안 #1087429

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087429 2024-09-12T17:17:05 Z dpsaveslives Dango Maker (JOI18_dango_maker) C++17
13 / 100
112 ms 211976 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3001;
char grid[MAXN][MAXN];
int mp[MAXN][MAXN][2];
vector<int> adj[MAXN*MAXN];
vector<bool> vis;
int side1 = 0, side2 = 0;
void dfs(int u, int s){
    vis[u] = true;
    if(s == 1){
        ++side1;
    }
    else{
        ++side2;
    }
    for(auto v : adj[u]){
        if(!vis[v]){
            dfs(v,3-s);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int N,M; cin >> N >> M;
    for(int i = 0;i<N;++i){
        for(int j = 0;j<M;++j){
            cin >> grid[i][j];
        }
    }
    int n = 0;
    for(int i = 0;i<N;++i){
        for(int j = 0;j<M;++j){
            if(grid[i][j] == 'R'){
                if(i+2 < N && grid[i+1][j] == 'G' && grid[i+2][j] == 'W'){
                    ++n;
                    mp[i][j][1] = n;
                    //cout << i << " " << j << " " << 1 << "\n";
                }
                if(j+2 < M && grid[i][j+1] == 'G' && grid[i][j+2] == 'W'){
                    ++n;
                    mp[i][j][0] = n;
                    //cout << i << " " << j << " " << 0 << "\n";
                    if(mp[i][j][1]){
                        adj[n].push_back(mp[i][j][1]);
                        adj[mp[i][j][1]].push_back(n);
                    }
                    if(i-1 >= 0 && mp[i-1][j+1][1]){
                        adj[n].push_back(mp[i-1][j+1][1]);
                        adj[mp[i-1][j+1][1]].push_back(n);
                    }
                    if(i-2 >= 0 && mp[i-2][j+2][1]){
                        adj[n].push_back(mp[i-2][j+2][1]);
                        adj[mp[i-2][j+2][1]].push_back(n);
                    }
                }

            }
        }
    }
    vis = vector<bool>(n+1,false);
    int ans = 0;
    for(int i = 1;i<=n;++i){
        if(!vis[i]){
            side1 = 0; side2 = 0;
            dfs(i,1);
            ans += max(side1,side2);
        }
    }
    cout << ans << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 211796 KB Output is correct
2 Correct 112 ms 211792 KB Output is correct
3 Correct 84 ms 211780 KB Output is correct
4 Correct 107 ms 211876 KB Output is correct
5 Correct 85 ms 211844 KB Output is correct
6 Correct 83 ms 211796 KB Output is correct
7 Correct 96 ms 211932 KB Output is correct
8 Correct 83 ms 211796 KB Output is correct
9 Correct 81 ms 211812 KB Output is correct
10 Correct 84 ms 211704 KB Output is correct
11 Correct 82 ms 211796 KB Output is correct
12 Correct 98 ms 211792 KB Output is correct
13 Correct 81 ms 211796 KB Output is correct
14 Correct 81 ms 211776 KB Output is correct
15 Correct 90 ms 211932 KB Output is correct
16 Correct 85 ms 211792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 211796 KB Output is correct
2 Correct 112 ms 211792 KB Output is correct
3 Correct 84 ms 211780 KB Output is correct
4 Correct 107 ms 211876 KB Output is correct
5 Correct 85 ms 211844 KB Output is correct
6 Correct 83 ms 211796 KB Output is correct
7 Correct 96 ms 211932 KB Output is correct
8 Correct 83 ms 211796 KB Output is correct
9 Correct 81 ms 211812 KB Output is correct
10 Correct 84 ms 211704 KB Output is correct
11 Correct 82 ms 211796 KB Output is correct
12 Correct 98 ms 211792 KB Output is correct
13 Correct 81 ms 211796 KB Output is correct
14 Correct 81 ms 211776 KB Output is correct
15 Correct 90 ms 211932 KB Output is correct
16 Correct 85 ms 211792 KB Output is correct
17 Correct 83 ms 211792 KB Output is correct
18 Correct 83 ms 211832 KB Output is correct
19 Correct 84 ms 211836 KB Output is correct
20 Correct 93 ms 211792 KB Output is correct
21 Correct 89 ms 211796 KB Output is correct
22 Correct 83 ms 211796 KB Output is correct
23 Correct 83 ms 211792 KB Output is correct
24 Correct 85 ms 211796 KB Output is correct
25 Correct 82 ms 211792 KB Output is correct
26 Correct 89 ms 211700 KB Output is correct
27 Correct 85 ms 211792 KB Output is correct
28 Correct 94 ms 211864 KB Output is correct
29 Correct 83 ms 211792 KB Output is correct
30 Correct 83 ms 211976 KB Output is correct
31 Correct 87 ms 211792 KB Output is correct
32 Correct 101 ms 211964 KB Output is correct
33 Correct 86 ms 211792 KB Output is correct
34 Incorrect 82 ms 211796 KB Output isn't correct
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 211796 KB Output is correct
2 Correct 112 ms 211792 KB Output is correct
3 Correct 84 ms 211780 KB Output is correct
4 Correct 107 ms 211876 KB Output is correct
5 Correct 85 ms 211844 KB Output is correct
6 Correct 83 ms 211796 KB Output is correct
7 Correct 96 ms 211932 KB Output is correct
8 Correct 83 ms 211796 KB Output is correct
9 Correct 81 ms 211812 KB Output is correct
10 Correct 84 ms 211704 KB Output is correct
11 Correct 82 ms 211796 KB Output is correct
12 Correct 98 ms 211792 KB Output is correct
13 Correct 81 ms 211796 KB Output is correct
14 Correct 81 ms 211776 KB Output is correct
15 Correct 90 ms 211932 KB Output is correct
16 Correct 85 ms 211792 KB Output is correct
17 Correct 83 ms 211792 KB Output is correct
18 Correct 83 ms 211832 KB Output is correct
19 Correct 84 ms 211836 KB Output is correct
20 Correct 93 ms 211792 KB Output is correct
21 Correct 89 ms 211796 KB Output is correct
22 Correct 83 ms 211796 KB Output is correct
23 Correct 83 ms 211792 KB Output is correct
24 Correct 85 ms 211796 KB Output is correct
25 Correct 82 ms 211792 KB Output is correct
26 Correct 89 ms 211700 KB Output is correct
27 Correct 85 ms 211792 KB Output is correct
28 Correct 94 ms 211864 KB Output is correct
29 Correct 83 ms 211792 KB Output is correct
30 Correct 83 ms 211976 KB Output is correct
31 Correct 87 ms 211792 KB Output is correct
32 Correct 101 ms 211964 KB Output is correct
33 Correct 86 ms 211792 KB Output is correct
34 Incorrect 82 ms 211796 KB Output isn't correct
35 Halted 0 ms 0 KB -