QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87165#3002. Busy BoardMaraschinoCompile Error//C++172.0kb2023-03-11 20:44:472023-03-11 20:44:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-11 20:44:48]
  • 评测
  • [2023-03-11 20:44:47]
  • 提交

answer

#include <bits/stdc++.h>
FILE *fin, *fout, *ferr;
static const int N = 1005;
int n, m;
char map1[N][N], map2[N][N];
int vr[N], vc[N], cr[N], cc[N];
bool equal()
{
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (map1[i][j] != map2[i][j])
                return false;
    return true;
}
void solve(int i, int j)
{
    vr[i] = vc[j] = true;
    for (int k = 1; k <= m; ++k)
    {
        cr[i] -= map2[i][k] == 'X';
        cc[k] -= map2[i][k] == 'X';
        map2[i][k] = '?';
    }
    for (int k = 1; k <= n; ++k)
    {
        cr[k] -= map2[k][j] == 'X';
        cc[j] -= map2[k][j] == 'X';
        map2[k][j] = '?';
    }
}
bool check1()
{
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (map1[i][j] == 'O' && vr[i] && vc[j])
                return true;
    return false;
}
bool check2()
{
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (map2[i][j] != '?' && map1[i][j] != map2[i][j])
                return false;
    return true;
}
signed main()
{
    fin = stdin;
    fout = stdout;
    ferr = stderr;
    fscanf(fin, "%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
        fscanf(fin, "%s", map1[i] + 1);
    for (int i = 1; i <= n; ++i)
        fscanf(fin, "%s", map2[i] + 1);
    if (equal())
        return fputs("1\n", fout), 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (map2[i][j] == 'X')
                ++cr[i], ++cc[j];
    while (1)
    {
        bk = false;
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j)
            {
                if (map2[i][j] == 'X' && cr[i] == 1 && cc[j] == 1)
                    solve(i, j), bk = true;
                if (map2[i][j] == '?' && cr[i] == 0 && cc[j] == 0 && (!vr[i] || !vc[j]))
                    solve(i, j), bk = true;
            }
        if (!bk)
            break;
    }
    return fprintf(fout, "%d\n", check1() && check2()), 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:65:9: error: ‘bk’ was not declared in this scope
   65 |         bk = false;
      |         ^~
answer.code:52:11: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   52 |     fscanf(fin, "%d%d", &n, &m);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~
answer.code:54:15: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   54 |         fscanf(fin, "%s", map1[i] + 1);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:56:15: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   56 |         fscanf(fin, "%s", map2[i] + 1);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~