답안 #254585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
254585 2020-07-30T09:55:59 Z Atill83 Dango Maker (JOI18_dango_maker) C++14
13 / 100
1 ms 512 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e3+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, m;
char gr[MAXN][MAXN];

vector<int> adj[MAXN];
int name[MAXN][MAXN][2];
int ad = 0;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    cin>>n>>m;

    for(int i = 0; i < n; i++){
        cin>>gr[i];
    }

    for(int i = 0; i < n - 2; i++){
        for(int j = 0; j < m; j++){
            if(gr[i][j] == 'R' && gr[i + 1][j] == 'G' && gr[i + 2][j] == 'W'){
                name[i][j][0] = ++ad;
            }
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m - 2; j++){
            if(gr[i][j] == 'R' && gr[i][j + 1] == 'G' && gr[i][j + 2] == 'W'){
                name[i][j][1] = ++ad;
                if(name[i][j][0]){
                    adj[name[i][j][0]].push_back(name[i][j][1]);
                    adj[name[i][j][1]].push_back(name[i][j][0]);
                }
                if(i && name[i - 1][j + 1][0]){
                    adj[name[i - 1][j + 1][0]].push_back(name[i][j][1]);
                    adj[name[i][j][1]].push_back(name[i - 1][j + 1][0]);
                }

                if(i > 1 && name[i - 2][j + 2][0]){
                    adj[name[i - 2][j + 2][0]].push_back(name[i][j][1]);
                    adj[name[i][j][1]].push_back(name[i - 2][j + 2][0]);
                }
            }
        }
    }

    set<int> st;
    for(int i = 1; i <= ad; i++){
        st.insert(i);
    }
    int cnt = 0;

    while(!st.empty()){
        ll sim = *(st.begin());
        cnt++;
        for(int j: adj[sim]){
            st.erase(j);
        }
        st.erase(st.begin());
    }

    cout<<cnt<<endl;





    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 512 KB Output is correct
20 Incorrect 1 ms 512 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 512 KB Output is correct
20 Incorrect 1 ms 512 KB Output isn't correct
21 Halted 0 ms 0 KB -