답안 #465719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465719 2021-08-16T17:00:30 Z myvaluska Patkice (COCI20_patkice) C++14
50 / 50
1 ms 332 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;
            cesta.push_back('<');
            continue;
        }
        if (v[zac.first][zac.second] == '>')
        {
            zac.second += 1;
            cesta.push_back('>');
            continue;
        }
        if (v[zac.first][zac.second] == 'v')
        {
            zac.first += 1;
            cesta.push_back('v');
            continue;
        }
        if (v[zac.first][zac.second] == '^')
        {
            zac.first -= 1;
            cesta.push_back('^');
            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 << "N" << endl;
    }
    if (ktory[0].second == 3)
    {
        cout << ":)" << endl;
        cout << "S" << 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:92: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]
   92 |     for (int i = 0; i < vys.size(); i++)
      |                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 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 0 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 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 312 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 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 312 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 308 KB Output is correct