# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
870183 | aeg | Patkice (COCI20_patkice) | C++14 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
vector<string> a;
int r,s;
int f(int x, int y) {
if(a[y][x] == 'x') return 0;
if(a[y][x] == '.' || a[y][x] == 'o') return INT_MIN;
int chx=0, chy=0;
if(a[y][x]=='<') chx--;
else if(a[y][x]=='>') chx++;
else if(a[y][x]=='^') chy--;
else chy++;
int ans = f(x+chx, y+chy);
if(ans < 0) return INT_MIN;
return ans+1;
}
int main () {
cin>>r>>s;
a.assign(r,"");
for(int i=0; i<r; i++) cin>>a[i];
int x, y;
for(int i=0; i<r; i++) for(int j=0; j<s; j++) {
if(a[i][j]=='o') {
y=i;
x=j;
}
}
int N = f(x,y-1), S = f(x,y+1), W = f(x-1,y), E = f(x+1, y);
int maxi = max(max(S,N),max(W,E));
int mini = INT_MAX;
if(S >= 0) mini = min(mini, S);
if(N >= 0) mini = min(mini, N);
if(W >= 0) mini = min(mini, W);
if(E >= 0) mini = min(mini, E);
if(maxi < 0) {
cout << ":(\n";
return 0;
}
cout << ":)\n";
if(E == mini) cout<<"E\n";
else if(N == mini) cout<<"N\n";
else if(S == mini) cout<<"S\n";
else cout<<"W\n";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |