제출 #529718

#제출 시각아이디문제언어결과실행 시간메모리
529718zxcvbnmDango Maker (JOI18_dango_maker)C++14
13 / 100
1 ms312 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const string str = "RGW"; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; char mat[n][m]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> mat[i][j]; } } bool ok[n][m][2]; memset(ok, false, sizeof ok); int thru[n][m][2]; memset(thru, -1, sizeof thru); for(int i = 0; i < n; i++) { for(int j = 0; j < m-2; j++) { string curr; for(int k = 0; k < 3; k++) { curr += mat[i][j+k]; } if (curr == str) { ok[i][j][0] = true; } } } for(int j = 0; j < m; j++) { for(int i = 0; i < n-2; i++) { string curr; for(int k = 0; k < 3; k++) { curr += mat[i+k][j]; } if (curr == str) { ok[i][j][1] = true; } } } priority_queue<array<int, 4>, vector<array<int, 4>>, greater<array<int, 4>>> q; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if (ok[i][j][0]) { int cnt = 0; cnt += ok[i][j][1]; if (i-1 >= 0) { cnt += ok[i-1][j+1][1]; } if (i-2 >= 0) { cnt += ok[i-2][j+2][1]; } q.push({cnt, i, j, 0}); // cout << i << " " << j << " " << 0 << " " << cnt << "\n"; } if (ok[i][j][1]) { int cnt = 0; cnt += ok[i][j][0]; if (j-1 >= 0) { cnt += ok[i+1][j-1][0]; } if (j-2 >= 0) { cnt += ok[i+2][j-2][0]; } q.push({cnt, i, j, 1}); // cout << i << " " << j << " " << 1 << " " << cnt << "\n"; } } } int ans = 0; while(!q.empty()) { auto v = q.top(); q.pop(); if (v[3] == 0) { string curr; for(int k = 0; k < 3; k++) { curr += mat[v[1]][v[2]+k]; } if (curr != str) continue; ans++; for(int k = 0; k < 3; k++) { mat[v[1]][v[2]+k] = 'X'; } } else { string curr; for(int k = 0; k < 3; k++) { curr += mat[v[1]+k][v[2]]; } if (curr != str) continue; ans++; for(int k = 0; k < 3; k++) { mat[v[1]+k][v[2]] = 'X'; } } // cout << v[0] << "\n"; } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...