# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916441 | svaz | Patkice (COCI20_patkice) | C++14 | 1 ms | 348 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>
using namespace std;
int main(){
int r,s,inx,iny;
cin>>r>>s;
char matriz[r][s];
for(int i=0;i<r;i++){
for(int j=0;j<s;j++){
cin>>matriz[i][j];
if(matriz[i][j]=='o'){
inx=i;
iny=j;
}
}
}
int x,y,cp,ans=(r*s)+10;
char opt='Z';
x=inx;
y=iny+1;
cp=0;
while(matriz[x][y]!='.' && matriz[x][y]!='x' && matriz[x][y]!='o' && x>=0 && x<r && y>=0 && y<s){
// cout<<x<<" "<<y<<endl;
cp++;
if(matriz[x][y]=='>')y++;
else if(matriz[x][y]=='<')y--;
else if(matriz[x][y]=='^')x--;
else if(matriz[x][y]=='v')x++;
}
if(x>=0 && x<r && y>=0 && y<s){
if(matriz[x][y]=='x'){
if(cp<ans){
ans=cp;
opt='E';
// cout<<"e:"<<cp<<endl;
}
}
}
x=inx-1;
y=iny;
cp=0;
while(matriz[x][y]!='.' && matriz[x][y]!='x' && matriz[x][y]!='o' && x>=0 && x<r && y>=0 && y<s){
cp++;
if(matriz[x][y]=='>')y++;
else if(matriz[x][y]=='<')y--;
else if(matriz[x][y]=='^')x--;
else if(matriz[x][y]=='v')x++;
}
if(x>=0 && x<r && y>=0 && y<s){
if(matriz[x][y]=='x'){
if(cp<ans){
ans=cp;
opt='N';
// cout<<"n:"<<cp<<endl;
}
}
}
x=inx+1;
y=iny;
cp=0;
while(matriz[x][y]!='.' && matriz[x][y]!='x' && matriz[x][y]!='o' && x>=0 && x<r && y>=0 && y<s){
// cout<<x<<" "<<y<<endl;
cp++;
if(matriz[x][y]=='>')y++;
else if(matriz[x][y]=='<')y--;
else if(matriz[x][y]=='^')x--;
else if(matriz[x][y]=='v')x++;
}
if(x>=0 && x<r && y>=0 && y<s){
if(matriz[x][y]=='x'){
if(cp<ans){
ans=cp;
opt='S';
//cout<<"s:"<<cp<<endl;
}
}
}
x=inx;
y=iny-1;
cp=0;
while(matriz[x][y]!='.' && matriz[x][y]!='x' && matriz[x][y]!='o' && x>=0 && x<r && y>=0 && y<s){
cp++;
if(matriz[x][y]=='>')y++;
else if(matriz[x][y]=='<')y--;
else if(matriz[x][y]=='^')x--;
else if(matriz[x][y]=='v')x++;
}
if(x>=0 && x<r && y>=0 && y<s){
if(matriz[x][y]=='x'){
if(cp<ans){
ans=cp;
opt='W';
// cout<<"w:"<<cp<<endl;
}
}
}
if(opt=='Z')cout<<":(\n";
else{
cout<<":)\n";
cout<<opt<<"\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |