Submission #1030936

#TimeUsernameProblemLanguageResultExecution timeMemory
1030936fv3Rectangles (IOI19_rect)C++14
0 / 100
83 ms50000 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; using namespace std; typedef long long ll; int N, M; int l, r, t, d, cnt; vector<vector<int>> grid, visited; void DFS(int x, int y) { visited[y][x] = 1; cnt++; l < min(l, x); r = max(r, x); t < min(t, y); d = max(d, y); if (x && !grid[y][x-1] && !visited[y][x-1]) DFS(x-1, y); if (y && !grid[y-1][x] && !visited[y-1][x]) DFS(x, y-1); if (x+1!=M && !grid[y][x+1] && !visited[y][x+1]) DFS(x+1, y); if (y+1!=N && !grid[y+1][x] && !visited[y+1][x]) DFS(x, y+1); } ll count_rectangles(vector<vector<int>> a) { N = a.size(); M = a[0].size(); if (N < 3 || M < 3) return 0; grid = a; visited = vector<vector<int>>(N, vector<int>(M)); ll res = 0; for (int y = 1; y < N-1; y++) { for (int x = 1; x < M-1; x++) { if (visited[y][x] || grid[y][x]) continue; l = r = x; t = d = y; cnt = 0; DFS(x, y); if (cnt == (r - l + 1) * (d - t + 1) && l && t && d < N-1 && r < M-1) res++; } } return res; }

Compilation message (stderr)

rect.cpp: In function 'void DFS(int, int)':
rect.cpp:15:4: warning: value computed is not used [-Wunused-value]
   15 |  l < min(l, x); r = max(r, x);
      |  ~~^~~~~~~~~~~
rect.cpp:16:4: warning: value computed is not used [-Wunused-value]
   16 |  t < min(t, y); d = max(d, y);
      |  ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...