답안 #719462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
719462 2023-04-06T01:35:35 Z safaricola Dango Maker (JOI18_dango_maker) C++17
13 / 100
1 ms 448 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ii pair <int, int>
#define rep(i,n) for(int i = 0; i <n; i++)
#define pb push_back
#define f first
#define s second
#define debug(x) cout<<#x<<' '<<x<<endl;
int n,m;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m;
    char a[n+5][m+5];
    rep(i,n)rep(j,m){
        cin>>a[i][j];
    }
    vector<int> adj[(n*m/3+5)],vs[n+5][m+5];
    bool vis[(n*m/3+5)]={};
    int nd=0;
    rep(i,n)rep(j,m){
        if(a[i][j]!='R')continue;
        if(i<n-2&&a[i+1][j]=='G'&&a[i+2][j]=='W'){
            for(auto it: vs[i][j]){
                adj[it].pb(nd);
                adj[nd].pb(it);
            }
            vs[i][j].pb(nd);
            for(auto it: vs[i+1][j]){
                adj[it].pb(nd);
                adj[nd].pb(it);
            }
            for(auto it: vs[i+2][j]){
                adj[it].pb(nd);
                adj[nd].pb(it);
            }
            vs[i+1][j].pb(nd);
            vs[i+2][j].pb(nd);
            nd++;
        }
        if(j<m-2&&a[i][j+1]=='G'&&a[i][j+2]=='W'){
            for(auto it: vs[i][j]){
                adj[it].pb(nd);
                adj[nd].pb(it);
            }
            vs[i][j].pb(nd);
            for(auto it: vs[i][j+1]){
                adj[it].pb(nd);
                adj[nd].pb(it);
            }
            for(auto it: vs[i][j+2]){
                adj[it].pb(nd);
                adj[nd].pb(it);
            }
            vs[i][j+1].pb(nd);
            vs[i][j+2].pb(nd);
            nd++;
        }
        //cout<<i<<' '<<j<<' '<<nd<<endl;
    }
    vector<ii> v; 
    rep(i,nd){
        v.pb({adj[i].size(),i});
    }
    sort(v.begin(), v.end());
    int ans=0;
    for(auto it: v){
        if(vis[it.s])continue;
        //cout<<it.s<<endl;
        for(auto tt: adj[it.s]){
            vis[tt]=true;
            //debug(tt);
        }
        ans++;
    }
    //cout<<nd<<endl;
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 0 ms 272 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 0 ms 272 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Runtime error 1 ms 448 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 0 ms 272 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Runtime error 1 ms 448 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -