제출 #531183

#제출 시각아이디문제언어결과실행 시간메모리
531183zxcvbnmDango Maker (JOI18_dango_maker)C++14
33 / 100
11 ms460 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int nax = 15; char mat[nax][nax]; const string str = "RGW"; bool check_ok(int i, int j, int p) { string curr; if (p == 0) { for(int k = 0; k < 3 && j+k < nax; k++) { curr += mat[i][j+k]; } } else { for(int k = 0; k < 3 && i+k < nax; k++) { curr += mat[i+k][j]; } } return (curr == str); } void rem(int i, int j, int p) { if (p == 0) { for(int k = 0; k < 3; k++) { mat[i][j+k] = 'X'; } } else { for(int k = 0; k < 3; k++) { mat[i+k][j] = 'X'; } } } int cnt(int i, int j, int p) { if (p == 0) { for(int k = 0; k < 3; k++) { mat[i][j+k] = 'X'; } } else { for(int k = 0; k < 3; k++) { mat[i+k][j] = 'X'; } } int cnt = 0; for(int x = 0; x < nax; x++) { for(int y = 0; y < nax; y++) { cnt += check_ok(x, y, 0); cnt += check_ok(x, y, 1); } } if (p == 0) { for(int k = 0; k < 3; k++) { mat[i][j+k] = str[k]; } } else { for(int k = 0; k < 3; k++) { mat[i+k][j] = str[k]; } } return cnt; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> mat[i][j]; } } int ans = 0; while(1) { bool ok = false; int best = -1, x = -1, y = -1, p = -1; for(int i = 0; i < nax; i++) { for(int j = 0; j < nax; j++) { if (check_ok(i, j, 0)) { ok = true; int curr = cnt(i, j, 0); if (curr > best) { best = curr; x = i, y = j, p = 0; } } if (check_ok(i, j, 1)) { ok = true; int curr = cnt(i, j, 1); if (curr > best) { best = curr; x = i, y = j, p = 1; } } } } if (!ok) break; rem(x, y, p); // cout << x << " " << y << " " << p << "\n"; ans++; } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...