답안 #644962

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644962 2022-09-25T16:52:01 Z Iwanttobreakfree Dijamant (COCI22_dijamant) C++17
0 / 70
1 ms 340 KB
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> grid (n,vector<int>(m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            char c;
            cin >> c;
            if (c == '#') grid[i][j] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (grid[i][j]) {
                int to = i;
                for (int k = i+1; k < n; ++k) {
                    if (grid[k][j]) {
                        to = k;
                        break;
                    }
                }
                if (to-i<2)continue;
                bool ok = true;
                for (int k = 1; k <= (to-i)/2; ++k) {
                    //cout << j-k << ' ' << j+k << '\n';
                    //cout << grid[i+k][j-k] << ' ' << grid[i+k][j+k] << '\n';
                    if (j-k < 0 || j + k >= m) ok = false;
                    if (!grid[i+k][j-k] || !grid[i+k][j+k]) ok = false;
                    for (int t = j-k+1; t <= j+k-1 ; ++t) {
                        if (grid[i+k][t]) {
                            ok = false;
                            break;
                        }
                        //cout << grid[i+k][t] << ' ';
                    }
                    if (!ok) break;
                }
                if (!ok) continue;
                for (int k = (to-i)/2+1; k < to-i; ++k) {
                    int dif = (to - i)-k;
                    //cout << i+k << '\n';
                    //cout << j - dif << ' ' << j + dif << '\n';
                    if (j-dif < 0 || j + dif >= m) ok = false;
                    if (!grid[i+k][j-dif] || !grid[i+k][j+dif]) ok = false;
                    for (int t = j-dif+1; t <= j+dif-1 ; ++t) {
                        if (grid[i+k][t]) {
                            ok = false;
                            break;
                        }
                    }
                    //cout << j-dif << ' ' << j+dif << '\n';
                    if (!ok) break;
                }
                if (ok) ++ans;
            }
        }
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -