Submission #465580

# Submission time Handle Problem Language Result Execution time Memory
465580 2021-08-16T12:21:17 Z myvaluska Patkice (COCI20_patkice) C++14
0 / 50
1000 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] == '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+2, vector<char>(m+2,'.'));
    pair<int, int>o;
    pair<int, int>x;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; 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";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -