Submission #465660

# Submission time Handle Problem Language Result Execution time Memory
465660 2021-08-16T15:51:11 Z myvaluska Patkice (COCI20_patkice) C++14
0 / 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;
vector<pair<vector<int>, char>>vys;
void dasa(pair<int,int>zac,char smer)
{
    int i = 0;
    vector<int>cesta;
    for (;;i++)
    {
        if (v[zac.first][zac.second] == '.')
        {
            return;
        }
        if (v[zac.first][zac.second] == 'o')
        {
            return;
        }
        if (v[zac.first][zac.second] == 'x')
        {
            vys.push_back({ cesta,smer });
            return;
        }
        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 };
            }
        }
    }
    dasa({ o.first - 1,o.second }, 'N');
    dasa({ o.first + 1,o.second }, 'S');
    dasa({ o.first,o.second + 1 }, 'E');
    dasa({ o.first,o.second - 1 }, 'W');
    if (vys.size() == 0)
    {
        cout << ":(" << endl;
        return 0;
   }
    vector<pair<int, int>>ktory;
    for (int i = 0; i < vys.size(); i++)
    {
        if (vys[i].second == 'E')
        {
            ktory.push_back({ vys[i].first.size(),1 });
        }
        if (vys[i].second == 'N')
        {
            ktory.push_back({ vys[i].first.size(),2 });
        }
        if (vys[i].second == 'S')
        {
            ktory.push_back({ vys[i].first.size(),3 });
        }
        if (vys[i].second == 'W')
        {
            ktory.push_back({ vys[i].first.size(),4 });
        }
    }
    sort(ktory.begin(), ktory.end());
    if (ktory[0].second == 1)
    {
        cout << ":)" << endl;
        cout << "E" << endl;
    }
    if (ktory[0].second == 2)
    {
        cout << ":)" << endl;
        cout << "S" << endl;
    }
    if (ktory[0].second == 3)
    {
        cout << ":)" << endl;
        cout << "N" << endl;
    }
    if (ktory[0].second == 4)
    {
        cout << ":)" << endl;
        cout << "W" << endl;
    }
    return 0;
    //std::cout << "Hello World!\n";
}

Compilation message

patkice.cpp: In function 'int main()':
patkice.cpp:88:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::vector<int>, char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     for (int i = 0; i < vys.size(); i++)
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -