QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245797#5476. Remodeling the DungeonFireball0424#WA 1ms3640kbC++142.3kb2023-11-10 12:40:192023-11-10 12:40:20

Judging History

你现在查看的是最新测评结果

  • [2023-11-10 12:40:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2023-11-10 12:40:19]
  • 提交

answer

#pragma GCC optimizer("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#define int long long 
#define ld long double
#define ull unsigned long long 
#define fr first
#define fi first
#define sc second
#define se second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
using namespace std;

#ifndef fireball
#define tofu ios::sync_with_stdio(0); cin.tie(0);
#else
#define tofu freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif 

void db() {cout << '\n';}
template <typename T, typename ...U> void db(T a, U ...b) {cout << a << ' ', db(b...);}

const int N = 1002;
int dis[N][N][2], n, m;
string s[N];

void dfs(int i, int j, int tp){
    if (i + 2 <= n * 2 and s[i + 1][j] == '.' and !dis[i + 2][j][tp]) {
        dis[i + 2][j][tp] = dis[i][j][tp] + 1;
        dfs(i + 2, j, tp);
    }
    if (i - 2 >= 0 and s[i - 1][j] == '.' and !dis[i - 2][j][tp]) {
        dis[i - 2][j][tp] = dis[i][j][tp] + 1;
        dfs(i - 2, j, tp);
    }
    if (j + 2 <= m * 2 and s[i][j + 1] == '.' and !dis[i][j + 2][tp]) {
        dis[i][j + 2][tp] = dis[i][j][tp] + 1;
        dfs(i, j + 2, tp);
    }
    if (j - 2 >= 0 and s[i][j - 1] == '.' and !dis[i][j - 2][tp]) {
        dis[i][j - 2][tp] = dis[i][j][tp] + 1;
        dfs(i, j - 2, tp);
    }
}

signed main(){
    tofu;
    //int n, m;
    cin >> n >> m;
    for (int i = 0; i < n * 2 + 1; i++){
        cin >> s[i];
    }
    dis[1][1][0] = 1;
    dis[n * 2 - 1][m * 2 - 1][1] = 1;
    dfs(1, 1, 0);
    dfs(n * 2 - 1, m * 2 - 1, 1);
    int ans = dis[n * 2 - 1][m * 2 - 1][0];
    //db(ans);
    for (int i = 1; i <= n * 2; i += 2){
        for (int j = 1; j <= m * 2; j += 2){
            //db(i, j, dis[i][j][0], dis[i][j][1], "ya");
            if (i < n * 2 - 1 and s[i + 1][j] != '.'){
                //db(i, j, min(dis[i][j][0] + dis[i + 2][j][1], dis[i][j][1] + dis[i + 2][j][0]));
                ans = max(ans, min(dis[i][j][0] + dis[i + 2][j][1], dis[i][j][1] + dis[i + 2][j][0]));
            }
            if (j < m * 2 - 1 and s[i][j + 1] != '.'){
                //db(i, j, min(dis[i][j][0] + dis[i][j + 2][1], dis[i][j + 2][1] + dis[i][j][0]));
                ans = max(ans, min(dis[i][j][0] + dis[i][j + 2][1], dis[i][j + 2][1] + dis[i][j][0]));
            }
        }
    }
    //db("ya");
    db(ans);
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3428kb

input:

2 3
+-+-+-+
|.....|
+.+.+.+
|.|.|.|
+-+-+-+

output:

6 

result:

ok single line: '6 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

2 3
+-+-+-+
|...|.|
+.+.+.+
|.|...|
+-+-+-+

output:

4 

result:

ok single line: '4 '

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3640kb

input:

5 5
+-+-+-+-+-+
|...|...|.|
+-+.+.+.+.+
|...|.|.|.|
+.+.+.+-+.+
|.|...|.|.|
+.+.+-+.+.+
|.|.....|.|
+-+.+.+-+.+
|...|.....|
+-+-+-+-+-+

output:

17 

result:

wrong answer 1st lines differ - expected: '15', found: '17 '