Submission #41544846


Source Code Expand

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}

void solve(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(auto&c : s) cin >> c;
    int dx[] = {1, 1, 1, 0, -1, -1, -1, 0};
    int dy[] = {-1, 0, 1, 1, -1, 0, 1, -1};
    auto ok = [&](int x, int y){
        return 0 <= x and x < h and 0 <= y and y < w;
    };
    string snuke = "snuke";
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(s[i][j] != 's') continue;
            for (int k = 0; k < 8; k++)
            {
                bool f = true;
                int x = i, y = j;
                for (int l = 1; l < 5; l++)
                {
                    x += dx[k], y += dy[k];
                    if(!ok(x, y) or s[x][y] != snuke[l])
                    {
                        f = false;
                    }
                }
                if(f)
                {
                    x = i + 1, y = j + 1;
                    for (int l = 0; l < 5; l++)
                    {
                        cout << x << " " << y << '\n';
                        x += dx[k], y += dy[k];
                    }
                    return;
                }
            }
            
        }
        
    }
    
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
}

Submission Info

Submission Time
Task B - Find snuke
User Motsu_xe
Language C++ (GCC 9.2.1)
Score 250
Code Size 1637 Byte
Status AC
Exec Time 7 ms
Memory 3604 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
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, 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, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 7 ms 3476 KiB
example_01.txt AC 2 ms 3584 KiB
example_02.txt AC 2 ms 3552 KiB
random_00.txt AC 3 ms 3572 KiB
random_01.txt AC 2 ms 3600 KiB
random_02.txt AC 2 ms 3604 KiB
random_03.txt AC 3 ms 3504 KiB
random_04.txt AC 2 ms 3424 KiB
random_05.txt AC 2 ms 3552 KiB
random_06.txt AC 2 ms 3600 KiB
random_07.txt AC 2 ms 3508 KiB
random_08.txt AC 2 ms 3500 KiB
random_09.txt AC 2 ms 3548 KiB
random_10.txt AC 2 ms 3496 KiB
random_11.txt AC 2 ms 3540 KiB
random_12.txt AC 3 ms 3480 KiB
random_13.txt AC 2 ms 3496 KiB
random_14.txt AC 2 ms 3500 KiB
random_15.txt AC 2 ms 3600 KiB
random_16.txt AC 2 ms 3544 KiB
random_17.txt AC 2 ms 3508 KiB
random_18.txt AC 2 ms 3580 KiB
random_19.txt AC 2 ms 3476 KiB
random_20.txt AC 2 ms 3600 KiB
random_21.txt AC 2 ms 3496 KiB
random_22.txt AC 2 ms 3496 KiB
random_23.txt AC 2 ms 3512 KiB
random_24.txt AC 2 ms 3424 KiB
random_25.txt AC 7 ms 3548 KiB
random_26.txt AC 2 ms 3588 KiB
random_27.txt AC 2 ms 3604 KiB
random_28.txt AC 2 ms 3496 KiB
random_29.txt AC 2 ms 3420 KiB