QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#844730#8236. Snake MoveaxujlsWA 153ms294780kbC++141.2kb2025-01-06 10:38:192025-01-06 10:38:25

Judging History

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

  • [2025-01-06 10:38:25]
  • 评测
  • 测评结果:WA
  • 用时:153ms
  • 内存:294780kb
  • [2025-01-06 10:38:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std; 

const int DX[4] = {1, 0, -1, 0}; 
const int DY[4] = {0, 1, 0, -1}; 

int main() {
    int N = 3005; 
    char a[N][N]; 
    int b[N][N], d[N][N];
    memset(d, -1, N*N);
    vector<pair<int, int>> coords(N);
    vector<pair<int, int>> q[N * N]; 
    int n, m, k; cin >> n >> m >> k;
    for(int i = 1; i <= k; i++){ 
		cin >> coords[i].first >> coords[i].second;
		b[coords[i].first][coords[i].second] += k - i; 
	}
    for(int i = 1; i <= n; i++){
        string row; cin >> row;
        for(int j = 1; j <= m; j++){
            a[i][j] = row[j - 1];
        }
    }
    d[coords[1].first][coords[1].second] = 0;
    q[0].emplace_back(coords[1].first, coords[1].second); 
    unsigned long long ans = 0; 
    for(int i = 0; i < N*N - 1; i++){
        for(auto [x, y] : q[i]){
            ans += i * 1LL * i; 
            for(int j = 0; j < 4; j++){
                int xx = x + DX[j]; int yy = y + DY[j]; 
                if(xx < 1 || yy < 1 || xx > n || yy > m || a[xx][yy] == '#' || d[xx][yy] != -1){
                    continue;
                }
                q[d[xx][yy] = max(i, b[xx][yy]) + 1].emplace_back(xx, yy); 
            }
        }
    }

    cout << ans << "\n"; 
}

詳細信息

Test #1:

score: 100
Accepted
time: 67ms
memory: 294604kb

input:

4 5 5
3 5
3 4
3 3
3 2
4 2
.....
.....
.....
.....

output:

293

result:

ok single line: '293'

Test #2:

score: 0
Accepted
time: 89ms
memory: 294780kb

input:

2 2 4
1 1
1 2
2 2
2 1
..
..

output:

14

result:

ok single line: '14'

Test #3:

score: 0
Accepted
time: 76ms
memory: 294600kb

input:

5 5 3
1 2
1 1
2 1
.....
.###.
.#.#.
.###.
.....

output:

407

result:

ok single line: '407'

Test #4:

score: -100
Wrong Answer
time: 153ms
memory: 294596kb

input:

3000 2900 1
1882 526
........................................................................................................#................................................................................................................................................................#................

output:

0

result:

wrong answer 1st lines differ - expected: '35141960580077', found: '0'