Submission #29716734


Source Code Expand

// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,k,n) for (int i = (k); i < (n); ++i)
using namespace std;
using ll = long long;
// using P = pair<ll,ll>;
using P = pair<int,int>;
using vint = vector<int>;
using vll = vector<ll>;
using vvint = vector<vector<int>>;
using vvll = vector<vector<ll>>;

// const ll INF = (ll)2e18+9;
const int INF = (int)2e9+7;
// const ll MOD = (ll)1e9+9;
template<typename T>
void chmin(T &a, T b) { a = min(a, b); }
template<typename T>
void chmax(T &a, T b) { a = max(a, b); }

template<typename T>
void print(vector<T> v) {
    int n = v.size();
    rep(i,n) {
        if (i == 0) cout << v[i];
        else cout << ' ' << v[i];
    }
    cout << endl;
}

vector<string> grid;
int n;

bool search(int i, int j, int di, int dj) {
    // (i, j): start point
    // (fi, fj): final point
    int fi = i + di * 5;
    int fj = j + dj * 5;
    if (fi < 0 || fi >= n || fj < 0 || fj >= n) return false;

    int rem = 6;
    int r = i, c = j;
    int numwhite = 0;
    rep(i,rem) {
        numwhite += grid[r][c] == '.';
        r += di;
        c += dj;
    }

    if (numwhite <= 2) {
        return true;
    }
    return false;
}

void solve() {
    cin >> n;
    grid.resize(n);
    rep(i,n) cin >> grid[i];

    rep(i,n) {
        rep(j,n) {
            // direction
            rep2(di,-1,2) rep2(dj,-1,2) {
                if (di == 0 && dj == 0) continue;
                if (search(i, j, di, dj)) {
                    cout << "Yes" << endl;
                    return;
                };
            }
        }
    }

    cout << "No" << endl;
}

int main() {
    solve();
    return 0;
}

Submission Info

Submission Time
Task C - Connect 6
User goropikari
Language C++ (GCC 9.2.1)
Score 300
Code Size 1953 Byte
Status AC
Exec Time 85 ms
Memory 5528 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 33
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt
Case Name Status Exec Time Memory
example_00.txt AC 7 ms 3560 KiB
example_01.txt AC 2 ms 3492 KiB
example_02.txt AC 5 ms 3496 KiB
hand_00.txt AC 24 ms 5352 KiB
hand_01.txt AC 19 ms 5420 KiB
hand_02.txt AC 82 ms 5528 KiB
hand_03.txt AC 83 ms 5412 KiB
hand_04.txt AC 24 ms 5292 KiB
hand_05.txt AC 84 ms 5404 KiB
hand_06.txt AC 23 ms 5468 KiB
hand_07.txt AC 83 ms 5488 KiB
hand_08.txt AC 83 ms 5416 KiB
hand_09.txt AC 19 ms 5484 KiB
hand_10.txt AC 84 ms 5468 KiB
hand_11.txt AC 2 ms 3364 KiB
random_00.txt AC 63 ms 5508 KiB
random_01.txt AC 28 ms 5416 KiB
random_02.txt AC 26 ms 5400 KiB
random_03.txt AC 58 ms 5392 KiB
random_04.txt AC 31 ms 5440 KiB
random_05.txt AC 2 ms 3420 KiB
random_06.txt AC 84 ms 5412 KiB
random_07.txt AC 82 ms 5476 KiB
random_08.txt AC 82 ms 5280 KiB
random_09.txt AC 84 ms 5392 KiB
random_10.txt AC 84 ms 5404 KiB
random_11.txt AC 83 ms 5396 KiB
random_12.txt AC 82 ms 5480 KiB
random_13.txt AC 83 ms 5484 KiB
random_14.txt AC 82 ms 5408 KiB
random_15.txt AC 80 ms 5456 KiB
random_16.txt AC 85 ms 5344 KiB
random_17.txt AC 2 ms 3600 KiB