Submission #465627

# Submission time Handle Problem Language Result Execution time Memory
465627 2021-08-16T14:58:46 Z myvaluska Patkice (COCI20_patkice) C++14
30 / 50
1 ms 204 KB
// palindromefree.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//long long int cifra[20]; 
vector<vector<char>>v;
bool dasa(pair<int,int>zac)
{
    int i = 0;
    for (;;i++)
    {
        if (v[zac.first][zac.second] == '.')
        {
            return false;
        }
        if (v[zac.first][zac.second] == 'o')
        {
            return false;
        }
        if (v[zac.first][zac.second] == 'x')
        {
            return true;
        }
        if (v[zac.first][zac.second] == '<')
        {
            zac.second -= 1;
            continue;
        }
        if (v[zac.first][zac.second] == '>')
        {
            zac.second += 1;
            continue;
        }
        if (v[zac.first][zac.second] == 'v')
        {
            zac.first += 1;
            continue;
        }
        if (v[zac.first][zac.second] == '^')
        {
            zac.first -= 1;
            continue;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    v.resize(n, vector<char>(m,'.'));
    pair<int, int>o;
    pair<int, int>x;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> v[i][j];
            if (v[i][j] == 'o')
            {
                o = { i,j };
            }
            else if (v[i][j] == 'x')
            {
                x = { i,j };
            }
        }
    }
    /*for (int i = 0; i < n + 2; i++)
    {
        for (int j = 0; j < m + 2; j++)
        {
            cout << v[i][j];
            if (j == m+1)
            {
                cout << endl;
            }
            else
            {
                //cout << " ";
            }
        }
    }*/
    /*pair<int, int>zac = {o.first - 1,o.second};
    cout << zac.first << ' ';
    cout << zac.second << endl;
    int i = 0;
    for (;; i++)
    {
        cout << zac.first << ' ';
        cout << zac.second << endl;
        if (v[zac.first][zac.second] == '.')
        {
            break;
        }
        if (v[zac.first][zac.second] == 'x')
        {
            cout << "YES" << endl;
            break;
        }
        if (v[zac.first][zac.second] == '<')
        {
            zac.second -= 1;
            continue;
        }
        if (v[zac.first][zac.second] == '>')
        {
            zac.second += 1;
            continue;
        }
        if (v[zac.first][zac.second] == 'v')
        {
            zac.first += 1;
            continue;
        }
        if (v[zac.first][zac.second] == '^')
        {
            zac.first -= 1;
            continue;
        }
    }*/
    if (dasa({o.first-1,o.second}) == true)
    {
        cout << ":)" << endl;
        cout << "N" << endl;
        return 0;
    }
    if (dasa({o.first+1,o.second}) == true)
    {
        cout << ":)" << endl;
        cout << "S" << endl;
        return 0;
    }
    if (dasa({o.first,o.second+1}) == true)
    {
        cout << ":)" << endl;
        cout << "E" << endl;
        return 0;
    }
    if (dasa({o.first,o.second-1}) == true)
    {
        cout << ":)" << endl;
        cout << "W" << endl;
        return 0;
    }
        cout << ":(" << endl;
    return 0;
    //std::cout << "Hello World!\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -