QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641742#8236. Snake Movesnow_mikuCompile Error//C++172.7kb2024-10-14 22:58:302024-10-14 22:58:31

Judging History

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

  • [2024-10-14 22:58:31]
  • 评测
  • [2024-10-14 22:58:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned long long;
const int N = 3001;
const int M = 3001;
uint dis[N][M];
int ff[4];
int tt[4];
int py[N][M];
int vis[N][M];
struct node{
    int x;
    int y;
    // uint w;
    uint step;
    int len;
    bool operator<(const node& b) const {
        return step > b.step;
    }
};

char s[N][N];
void solve(){
    int n, m, k;
    cin >> n >> m >> k;
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            py[i][j] = k + 1;
        }
    }
    // vector<vector<int>> py(n + 1, vector<int> (m + 1, k + 1));
    int xx, yy;
    cin >> xx >> yy;
    py[xx][yy] = 1;
    for(int i = 2; i <= k; i++){
        int a, b;
        cin >> a >> b;
        py[a][b] = i;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++)
        cin >> s[i][j];
    }
    // vector<vector<uint>> dis(n + 1, vector<uint> (m + 1));
    auto bfs = [&](){
        priority_queue<node> q;
        ff[0] = -1;
        ff[1] = 1;
        tt[2] = 1;
        tt[3] = -1;
        // vector<vector<int>> vis(n + 1, vector<int> (m + 1));
        q.push({xx, yy, 0, k});
        while(!q.empty()){
            auto [x, y, step, len] = q.top();
            q.pop();
            if(vis[x][y])continue;
            vis[x][y] = 1;
            dis[x][y] = step;
            for(int p = 0; p < 4; p++){
                int u = x + ff[p];
                int v = y + tt[p];
                if(u <= n && u >= 1 && v <= m && v >= 1){
                    if(s[u][v] == '.' && vis[u][v] == 0){
                        if(py[u][v] + step < len){//py + step 代表现在蛇的位置
                            int cnt = len - py[u][v] - step;
                            q.push({u, v, dis[x][y] + cnt + 1, len - cnt});
                        }
                        else q.push({u, v, dis[x][y] + 1, len});
                    }
                }
            }
        }
    };
    bfs();
    uint ans = 0;
    // for(int i = 1; i <= n; i++){
    //     for(int j = 1; j <= m; j++){
    //         cout << py[i][j] << " ";
    //     }
    //     cout << '\n';
    // }
    // cout << "---------------" << endl;
    // for(int i = 1; i <= n; i++){
    //     for(int j = 1; j <= m; j++){
    //         cout << dis[i][j] << " ";
    //     }
    //     cout << '\n';
    // }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            ans += dis[i][j] * dis[i][j];
        }
    }
    cout << ans << '\n';

}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

詳細信息

answer.code:4:7: error: conflicting declaration ‘using uint = long long unsigned int’
    4 | using uint = unsigned long long;
      |       ^~~~
In file included from /usr/include/stdlib.h:394,
                 from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/sys/types.h:150:22: note: previous declaration as ‘typedef unsigned int uint’
  150 | typedef unsigned int uint;
      |                      ^~~~