QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#485752#1819. Cleaning RobotXC220477Compile Error//C++172.6kb2024-07-21 05:23:212024-07-21 05:23:22

Judging History

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

  • [2024-07-21 05:23:22]
  • 评测
  • [2024-07-21 05:23:21]
  • 提交

answer

#include <queue>
#include <iostream>
using namespace std;

int n, m, k;
int a[5000001][5000001];
int ps[5000001][5000001];
int visited[5000001][5000001];
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};

bool bfs(int size)
{
    queue<pair<int, int>> q;
        
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j] == 0 && q.empty())
            {
                if (j > m - size || i > n - size ||
                    ps[i + size - 1][j + size - 1] - ps[i + size - 1][j - 1] -
                    ps[i - 1][j + size - 1] + ps[i - 1][j - 1] > 0)
                {
                    return false;
                }
                
                q.push({i, j});
            }
            visited[i][j] = 0;
        }
    }
    
    while (!q.empty())
    {
        int r = q.front().first;
        int c = q.front().second;
        q.pop();
        
        visited[r][c]++;
        visited[r + size][c]--;
        visited[r][c + size]--;
        visited[r + size][c + size]++;
                
        for (int i = 0; i < 4; i++)
        {
            int newr = r + dr[i];
            int newc = c + dc[i];
            
            if (newr > 0 && newc > 0 && newr <= n + 1 - size && newc <= m + 1 - size && visited[newr][newc] <= 0 &&
                ps[newr + size - 1][newc + size - 1] - ps[newr + size - 1][newc - 1] -
                ps[newr - 1][newc + size - 1] + ps[newr - 1][newc - 1] == 0)
            {
                q.push({newr, newc});
            }
        }
    }
    
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            visited[i][j] += visited[i - 1][j] + visited[i][j - 1] - visited[i - 1][j - 1];
            
            if (a[i][j] == 0 && visited[i][j] <= 0) return false;
        }
    }
    
    return true;
}

int main()
{
    cin >> n >> m >> k;
    
    for (int i = 0; i < k; i++)
    {
        int r, c;
        cin >> r >> c;
        
        a[r][c] = 1;
    }
    
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            ps[i][j] = ps[i - 1][j] + ps[i][j - 1] - ps[i - 1][j - 1] + a[i][j];
        }
    }
    
    if (!bfs(1))
    {
        cout << -1 << endl;
        return 0;
    }
    
    int l = 1;
    int r = n;
    
    if (m < n) r = m;
    
    while (l < r)
    {
        int mid = (l + r + 1) / 2;
        bool valid = bfs(mid);
        
        if (valid) l = mid;
        else r = mid - 1;
    }
    
    cout << l << endl;
    
    return 0;
}

详细

/tmp/ccrRrIgW.o: in function `bfs(int)':
answer.code:(.text+0x38c): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x3da): relocation truncated to fit: R_X86_64_PC32 against symbol `ps' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x3ec): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x40f): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x487): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x4f9): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x50a): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x5fc): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x61d): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x686): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccrRrIgW.o
answer.code:(.text+0x6a9): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status