# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340188 | lohacho | Sandwich (JOI16_sandwich) | C++14 | 5802 ms | 4068 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(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
vector<string> a(N);
for(int i = 0; i < N; ++i){
cin >> a[i];
}
vector<vector<int>> chk(N, vector<int>(M, 0));
vector<vector<int>> ans(N, vector<int>(M, (int)1e9));
vector<int> NN = {0, 0, 1, 1}, ZZ = {0, 1, 1, 0};
vector<int> wx = {-1, 0, 1, 0}, wy = {0, 1, 0, -1};
function<int(int, int, int)> dfs = [&](int x, int y, int dir){
if(chk[x][y] == 1){
return (int)1e9;
}
if(chk[x][y] == 2){
return 0;
}
int rv = 1;
chk[x][y] = 1;
for(int i = 0; i < 4; ++i){
if((a[x][y] == 'N' && NN[i] == dir) || (a[x][y] == 'Z' && ZZ[i] == dir)){
int nx = x + wx[i], ny = y + wy[i];
if(nx >= 0 && ny >= 0 && nx < N && ny < M){
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |