QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#483672#1819. Cleaning RobotSubstantialFarOffAppletWA 1015ms410704kbC++144.2kb2024-07-19 00:28:222024-07-19 00:28:23

Judging History

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

  • [2024-07-19 00:28:23]
  • 评测
  • 测评结果:WA
  • 用时:1015ms
  • 内存:410704kb
  • [2024-07-19 00:28:22]
  • 提交

answer

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

int rows, columns, obstructions;
#define build(rows, columns) vector<vector<int>> (rows, vector<int>(columns, 0))
vector<vector<int>> stuff;
vector<vector<int>> visited;
vector<vector<int>> obstacles;
int currents = 0;

void dfs(int xfirst, int yfirst, int xsecond, int ysecond){
    if(xfirst < 0 || yfirst < 0 || xsecond >= rows || ysecond >= columns || visited[xfirst][yfirst] == 1){
        return;
    }
    int howmany = 0;
    if (xfirst > 0 && yfirst > 0){
        howmany = stuff[xsecond][ysecond] - stuff[xfirst-1][ysecond] - stuff[xsecond][yfirst-1] + stuff[xfirst-1][yfirst-1];
    }else if(xfirst == 0 && yfirst == 0){
        howmany = stuff[xsecond][ysecond];
    }else if(xfirst > 0){
        howmany = stuff[xsecond][ysecond] - stuff[xfirst-1][ysecond];
    }else if(yfirst > 0){
        howmany = stuff[xsecond][ysecond] - stuff[xsecond][yfirst-1];
    }
    if (howmany > 0){
        return;
    }
    visited[xfirst][yfirst] = 1;
    dfs(xfirst-1, yfirst, xsecond-1, ysecond);
    dfs(xfirst+1, yfirst, xsecond+1, ysecond);
    dfs(xfirst, yfirst-1, xsecond, ysecond-1);
    dfs(xfirst, yfirst+1, xsecond, ysecond+1);
}

int checks(int which){
    visited = build(rows, columns);
    int checkers = 0;
    for (int a = 0; a <= rows-which; ++a){
        for (int b = 0; b <= columns-which; ++b){
            int xfirst = a;
            int yfirst = b;
            int xsecond = a+which-1;
            int ysecond = b+which-1;
            int howmany = 0;
            if (xfirst > 0 && yfirst > 0){
                howmany = stuff[xsecond][ysecond] - stuff[xfirst-1][ysecond] - stuff[xsecond][yfirst-1] + stuff[xfirst-1][yfirst-1];
            }else if(xfirst == 0 && yfirst == 0){
                howmany = stuff[xsecond][ysecond];
            }else if(xfirst > 0){
                howmany = stuff[xsecond][ysecond] - stuff[xfirst-1][ysecond];
            }else if(yfirst > 0){
                howmany = stuff[xsecond][ysecond] - stuff[xsecond][yfirst-1];
            }
            if (howmany == 0){
                dfs(xfirst, yfirst, xsecond, ysecond);
                checkers = 1;
                break;
            }
        }
        if (checkers == 1){
            break;
        }
    }
    if (checkers == 0){
        return 0;
    }
    checkers = 1;
    for (int c = 0; c < rows; ++c){
        for (int d = 0; d < columns; ++d){
            if (visited[c][d] != 1 && obstacles[c][d] != 1){
                checkers = 0;
                break;
            }
        }
        if (checkers == 0){
            break;
        }
    }
    return checkers;
}

int main(){
    cin >> rows >> columns >> obstructions;
    stuff = build(rows, columns);
    visited = build(rows, columns);
    obstacles = build(rows, columns);
    for (int a = 0; a < obstructions; ++a){
        int xpos, ypos;
        cin >> xpos >> ypos;
        xpos -= 1;
        ypos -= 1;
        stuff[xpos][ypos] = 1;
        obstacles[xpos][ypos] = 1;
    }
    for (int a = 0; a < rows; ++a){
        for (int b = 0; b < columns; ++b){
            if (a == 0 || b == 0){
                if (a == 0 && b == 0){
                    //
                }else if(a == 0){
                    stuff[a][b] += stuff[a][b-1];
                }else{
                    stuff[a][b] += stuff[a-1][b];
                }
            }else{
                stuff[a][b] += stuff[a-1][b];
                stuff[a][b] += stuff[a][b-1];
                stuff[a][b] -= stuff[a-1][b-1];
            }
        }
    }
    int l = 0;
    int r = min(rows, columns)+1;
    while (l<r){
        //cout << l << " " << r << endl;
        int mids = (l+r)/2;
        if (checks(mids) == 1){
            l = mids+1;
        }else{
            r = mids;
        }
    }
    cout << l;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

10 7 1
8 3

output:

2

result:

ok answer is '2'

Test #2:

score: -100
Wrong Answer
time: 1015ms
memory: 410704kb

input:

2236 2236 2214
28 1255
389 2175
730 592
1360 977
1225 752
1403 1798
1518 1381
147 745
659 249
951 1475
1826 1951
691 1033
81 1458
1487 1946
2106 1395
1995 629
470 891
1902 822
2210 2001
441 2130
1198 1539
2027 1101
215 1149
205 420
379 2104
308 1225
859 109
1417 2078
1764 376
1772 5
335 1113
917 118...

output:

2

result:

wrong answer expected '1', found '2'