Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
38003 申东铉 【S】T2 C++ Wrong Answer 0 340 MS 28568 KB 2082 2025-06-08 15:54:08

Tests(0/20):


#include <bits/stdc++.h> using namespace std; int n,X,Y; struct str { bool l,r,u,d; } a[1003][1003]; int ans[1003][1003]; inline bool e (int x,int y) { if (x < 1 || x > n) { return false; } if (y < 1 || y > n) { return false; } if (ans[x][y]) { return false; } return true; } int dfs (int x,int y) { ans[x][y] = 1; if (x == n && y == Y) { ans[x][y] = 1; return 1; } if (!a[x][y].d && e(x + 1,y)) { if (dfs(x + 1,y) == 1) { return 1; } } if ((!a[x][y].l && e(x,y - 1)) || (!a[x][y].r && e(x,y + 1))) { int r = 2; ans[x][y] = 2; if (!a[x][y].l && e(x,y - 1)) { r = min(r,dfs(x,y - 1)); ans[x][y] = min(ans[x][y],ans[x][y - 1]); } if (!a[x][y].r && e(x,y + 1)) { r = min(r,dfs(x,y + 1)); ans[x][y] = min(ans[x][y],ans[x][y + 1]); } if (r == 1) { return 1; } } ans[x][y] = 2; if (!a[x][y].u && e(x - 1,y)) { if (dfs(x - 1,y) == 1) { return 1; } } return 2; } signed main () { cin >> n >> X >> Y; for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) { cin >> a[i][j].u; } } for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) { cin >> a[i][j].l; } } for (int i = 1;i < n;i++) { for (int j = 1;j <= n;j++) { a[i][j].d = a[i + 1][j].u; } } for (int i = 1;i <= n;i++) { a[n][i].d = 1; } a[n][Y].d = 0; for (int i = 1;i <= n;i++) { for (int j = 1;j < n;j++) { a[i][j].r = a[i][j + 1].l; } } for (int i = 1;i <= n;i++) { a[n][i].r = 1; } dfs(1,X); for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) { cout << ans[i][j] << ' '; } cout << endl; } return 0; }


Judgement Protocol: