# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404048 | Dynamic_Cast | Patkice (COCI20_patkice) | C++98 | 1099 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#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);
short X,Y;
short x,y;
for(int i=0;i<r;i++){
for(int j=0;j<s;j++){
scanf(" %c",&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;
if (y + 1 < s)
{
x = X;
y = Y;
y = y + 1;
coun = 0;
while (1)
{
if (sea[x][y] == 'x')
{
if (mi > coun)
{
mi = coun;
last = 1;
}
break;
}
if (sea[x][y] == '.')
{
break;
}
if (sea[x][y] == '>')
{
y++;
coun++;
continue;
}
if (sea[x][y] == '<')
{
y--;
coun++;
continue;
}
if (sea[x][y] == '^')
{
x--;
coun++;
continue;
}
if (sea[x][y] == 'v')
{
x++;
coun++;
continue;
}
}
}
x = X;
y = Y;
if (x - 1 >= 0)
{
x = X;
y = Y;
x = x - 1;
coun = 0;
while (1)
{
if (sea[x][y] == 'x')
{
if (mi > coun)
{
mi = coun;
last = 2;
}
break;
}
if (sea[x][y] == '.')
{
break;
}
if (sea[x][y] == '>')
{
y++;
coun++;
continue;
}
if (sea[x][y] == '<')
{
y--;
coun++;
continue;
}
if (sea[x][y] == '^')
{
x--;
coun++;
continue;
}
if (sea[x][y] == 'v')
{
x++;
coun++;
continue;
}
}
}
x = X;
y = Y;
if (x + 1 < r)
{
x = X;
y = Y;
x = x + 1;
coun = 0;
while (1)
{
if (sea[x][y] == 'x')
{
if(mi>coun){
mi=coun;
last=3;
}
break;
}
if (sea[x][y] == '.')
{
break;
}
if (sea[x][y] == '>')
{
y++;
coun++;
continue;
}
if (sea[x][y] == '<')
{
y--;
coun++;
continue;
}
if (sea[x][y] == '^')
{
x--;
coun++;
continue;
}
if (sea[x][y] == 'v')
{
x++;
coun++;
continue;
}
}
}
x = X;
y = Y;
if (y - 1 >= 0)
{
x = X;
y = Y;
y = y - 1;
coun = 0;
while (1)
{
if (sea[x][y] == 'x')
{
if (mi > coun)
{
mi = coun;
last = 4;
}
break;
}
if (sea[x][y] == '.')
{
break;
}
if (sea[x][y] == '>')
{
y++;
coun++;
continue;
}
if (sea[x][y] == '<')
{
y--;
coun++;
continue;
}
if (sea[x][y] == '^')
{
x--;
coun++;
continue;
}
if (sea[x][y] == 'v')
{
x++;
coun++;
continue;
}
}
}
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;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |