# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115018 | onjo0127 | Sandwich (JOI16_sandwich) | C++11 | 3649 ms | 8056 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;
char A[409][409];
int R, C, chk[409][409], s, ans[409][409];
const int INF = 1e9;
/*
0 - up
1 - down
2 - left
3 - right
*/
void go(int x, int y, int d) {
if(x < 1 || x > R || y < 1 || y > C) return;
if(chk[x][y] == 2) return;
if(chk[x][y] == 1) {
s = INF;
return;
}
chk[x][y] = 1; s += 2;
if(A[x][y] == 'N') {
if(d == 0 || d == 3) {go(x-1, y, 0); go(x, y+1, 3);}
if(d == 1 || d == 2) {go(x+1, y, 1); go(x, y-1, 2);}
}
if(A[x][y] == 'Z') {
if(d == 0 || d == 2) {go(x-1, y, 0); go(x, y-1, 2);}
if(d == 1 || d == 3) {go(x+1, y, 1); go(x, y+1, 3);}
}
chk[x][y] = 2;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |