QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#266570#7733. Cool, It’s Yesterday Four Times MoreBoulevardDust#Compile Error//C++202.3kb2023-11-26 15:29:462023-11-26 15:29:46

Judging History

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

  • [2023-11-26 15:29:46]
  • 评测
  • [2023-11-26 15:29:46]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <vector>
#define N 1000

using namespace std;

int T, n, m;
int vis[1005][1005], nocan[2005][2005];
char s[1005][1005];4
2 5
.OO..
O..O.
1 3
O.O
1 3
.O.
2 3
OOO
OOO

vector<pair<int, int> > vec, kan;

void dfs(int x, int y) {
    vis[x][y] = 1;
    vec.push_back(make_pair(x, y));
    for(int i = -n; i <= n; ++i) {
        for(int j = -m; j <= m; ++j) {
            int xx = x + i, yy = y + j;
            if(xx < 1 || xx > n || yy < 1 || yy > m || s[xx][yy] == 'O') {
                nocan[i + N][j + N] = 1;
            }
        }
    }
    for(int i = 0; i < 4; ++i) {
        int xx = x + dir[i][0], yy = y + dir[i][1];
        if(xx >= 1 && xx <= n && yy >= 1 && yy <= m && !vis[xx][yy] && s[xx][yy] == '.')  {
            dfs(xx, yy);
        }
    }
}

int main() {
    scanf("%d", &T);
    while(T--) {
        scanf("%d%d", &n, &m);
        kan.clear();
        for(int i = 1; i <= n; ++i) {
            scanf("%s", s[i] + 1);
            for(int j = 1; j <= m; ++j) {
                vis[i][j] = 0;
                if(s[i][j] == '.') kan.push_back(make_pair(i, j));
            }
        }
        int ans = 0;
        for(int i = 1; i <= n; ++i) {
            for(int j = 1; j <= m; ++j) {
                if(s[i][j] == '.' && !vis[i][j]) {
                    for(int ii = -n; ii <= n; ++ii) {
                        for(int jj = -m; jj <= m; ++jj) {
                            nocan[ii + N][jj + N] = 0;
                        }
                    }
                    vec.clear();
                    dfs(i, j);
                    for(int k = 0; k < (int)vec.size(); ++k) {
                        int x0 = vec[k].first, y0 = vec[k].second;
                        int fl = 1;
                        for(int l = 0; l < (int)kan.size(); ++l) {
                            int x1 = kan[l].first, y1 = kan[l].second;
                            if((x1 != x0 || (y1 != y0)) && !nocan[x1 - x0 + N][y1 - y0 + N]) {
                                fl = 0; break;
                            }
                        }
                        if(fl) ++ans;
                    }   
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Details

answer.code:10:20: error: expected unqualified-id before numeric constant
   10 | char s[1005][1005];4
      |                    ^
answer.code: In function ‘void dfs(int, int)’:
answer.code:26:5: error: ‘vec’ was not declared in this scope
   26 |     vec.push_back(make_pair(x, y));
      |     ^~~
answer.code:36:22: error: ‘dir’ was not declared in this scope; did you mean ‘div’?
   36 |         int xx = x + dir[i][0], yy = y + dir[i][1];
      |                      ^~~
      |                      div
answer.code:37:34: error: ‘yy’ was not declared in this scope; did you mean ‘y’?
   37 |         if(xx >= 1 && xx <= n && yy >= 1 && yy <= m && !vis[xx][yy] && s[xx][yy] == '.')  {
      |                                  ^~
      |                                  y
answer.code: In function ‘int main()’:
answer.code:47:9: error: ‘kan’ was not declared in this scope
   47 |         kan.clear();
      |         ^~~
answer.code:64:21: error: ‘vec’ was not declared in this scope
   64 |                     vec.clear();
      |                     ^~~
answer.code:71:46: error: ‘y1’ was not declared in this scope; did you mean ‘x1’?
   71 |                             if((x1 != x0 || (y1 != y0)) && !nocan[x1 - x0 + N][y1 - y0 + N]) {
      |                                              ^~
      |                                              x1
answer.code:71:52: error: ‘y0’ was not declared in this scope; did you mean ‘x0’?
   71 |                             if((x1 != x0 || (y1 != y0)) && !nocan[x1 - x0 + N][y1 - y0 + N]) {
      |                                                    ^~
      |                                                    x0
answer.code:44:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   44 |     scanf("%d", &T);
      |     ~~~~~^~~~~~~~~~
answer.code:46:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |         scanf("%d%d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~
answer.code:49:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |             scanf("%s", s[i] + 1);
      |             ~~~~~^~~~~~~~~~~~~~~~