Submission #404051

# Submission time Handle Problem Language Result Execution time Memory
404051 2021-05-13T17:32:02 Z Dynamic_Cast Patkice (COCI20_patkice) C++
0 / 50
1000 ms 204 KB
//#include <bits/stdc++.h> C++11
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <time.h>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <stack>
#include <queue>
#include <climits>
#include <map>
#include <set>
#include<sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r,s;
    char sea[101][101];
    //scanf("%d%d",&r,&s);
    cin>>r>>s;
    short X,Y;
    X=0;
    Y=0;
    short x,y;
    for(int i=0;i<r;i++){
        for(int j=0;j<s;j++){
            //scanf(" %c",&sea[i][j]);
            cin>>sea[i][j];
            if (sea[i][j]=='o'){
                X=i;
                Y=j;
            }
        }
    }
    x=X;
    y=Y;
    int coun=0;
    x = X;
    y = Y;
    int mi=100000;
    int last=-1;
    x = X;
    y = Y;
    bool f=0;
    if (y + 1 < s)
    {
        x = X;
        y = Y;
        y = y + 1;
        coun = 0;
        while (f==0)
        {
            if (sea[x][y] == 'x')
            {
                if (mi > coun)
                {
                    mi = coun;
                    last = 1;
                }
                f=1;
            }
            if (sea[x][y] == '.')
            {
                f=1;
            }
            if (sea[x][y] == '>')
            {
                y++;
                coun++;
            }
            if (sea[x][y] == '<')
            {
                y--;
                coun++;
            }
            if (sea[x][y] == '^')
            {
                x--;
                coun++;
            }
            if (sea[x][y] == 'v')
            {
                x++;
                coun++;
            }
        }
    }
    x = X;
    y = Y;
    if (x - 1 >= 0)
    {
        x = X;
        y = Y;
        x = x - 1;
        coun = 0;
        f=0;
        while (f==0)
        {
            if (sea[x][y] == 'x')
            {
                if (mi > coun)
                {
                    mi = coun;
                    last = 2;
                }
                f=1;
            }
            if (sea[x][y] == '.')
            {
                f=1;
            }
            if (sea[x][y] == '>')
            {
                y++;
                coun++;
            }
            if (sea[x][y] == '<')
            {
                y--;
                coun++;
            }
            if (sea[x][y] == '^')
            {
                x--;
                coun++;
            }
            if (sea[x][y] == 'v')
            {
                x++;
                coun++;
            }
        }
    }
    x = X;
    y = Y;
    if (x + 1 < r)
    {
        x = X;
        y = Y;
        x = x + 1;
        coun = 0;
        f=0;
        while (f==0)
        {
            if (sea[x][y] == 'x')
            {
                if(mi>coun){
                    mi=coun;
                    last=3;
                }
                f=1;
            }
            if (sea[x][y] == '.')
            {
                f=1;
            }
            if (sea[x][y] == '>')
            {
                y++;
                coun++;
            }
            if (sea[x][y] == '<')
            {
                y--;
                coun++;
            }
            if (sea[x][y] == '^')
            {
                x--;
                coun++;
            }
            if (sea[x][y] == 'v')
            {
                x++;
                coun++;
            }
        }
    }
    x = X;
    y = Y;
    if (y - 1 >= 0)
    {
        x = X;
        y = Y;
        y = y - 1;
        coun = 0;
        f=0;
        while (f==0)
        {
            if (sea[x][y] == 'x')
            {
                if (mi > coun)
                {
                    mi = coun;
                    last = 4;
                }
                f=1;
            }
            if (sea[x][y] == '.')
            {
                f=1;
            }
            if (sea[x][y] == '>')
            {
                y++;
                coun++;
            }
            if (sea[x][y] == '<')
            {
                y--;
                coun++;
            }
            if (sea[x][y] == '^')
            {
                x--;
                coun++;
            }
            if (sea[x][y] == 'v')
            {
                x++;
                coun++;
            }
        }
    }

    if(last==-1){
        printf(":(\n");
        return 0;
    }
    if (last == 1)
    {
        printf(":)\nE\n");
        return 0;
    }
    if (last == 2)
    {
        printf(":)\nN\n");
        return 0;
    }
    if (last == 3)
    {
        printf(":)\nS\n");
        return 0;
    }
    if (last == 4)
    {
        printf(":)\nW\n");
        return 0;
    }
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -