제출 #464099

#제출 시각아이디문제언어결과실행 시간메모리
464099CyberCowT-Covering (eJOI19_covering)C++17
0 / 100
2 ms716 KiB
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <string> #include <cmath> #include <map> #include <unordered_map> #include <fstream> #include <iomanip> #include <iterator> #include <stack> using namespace std; using ll = long long; int v[1002][1002]; int a[1002][1002]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, i, j, x, y, k, asn; ll ans = 0; cin >> n >> m; for ( i = 1; i <= n; i++) { for ( j = 1; j <= m; j++) { cin >> v[i][j]; } } cin >> k; for ( i = 0; i < k; i++) { cin >> x >> y; a[x][y] = 1; } if (a[1][1] == 1 || a[1][m] == 1 || a[n][1] == 1 || a[n][m] == 1) { cout << "No"; exit(0); } for ( i = 1; i <= n; i++) { for ( j = 1; j < m; j++) { if (a[i][j] == 1 && a[i - 1][j] == 1) { if (i + 1 <= n && i - 2 >= 1 && j > 1 && j < m) { ans += a[i][j] + a[i][j + 1] + a[i][j - 1] + a[i + 1][j]; } else { cout << "No"; exit(0); } } else if (a[i][j] == 1 && a[i + 1][j] == 1) { if (i + 2 <= n && i - 1 >= 1 && j > 1 && j < m) { ans += a[i][j] + a[i][j + 1] + a[i][j - 1] + a[i - 1][j]; } else { cout << "No"; exit(0); } } else if (a[i][j] == 1 && a[i][j + 1] == 1) { if (i + 1 <= n && i - 1 >= 1 && j - 1 >= 1 && j + 2 <= m) { ans += a[i][j] + a[i][j - 1] + a[i + 1][j] + a[i - 1][j]; } else { cout << "No"; exit(0); } } else if (a[i][j] == 1 && a[i][j - 1] == 1) { if (i + 1 <= n && i - 1 >= 1 && j - 2 >= 1 && j + 1 <= m) { ans += a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i - 1][j]; } else { cout << "No"; exit(0); } } else { ans += a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i - 1][j] + a[i][j - 1] - min(min(a[i][j - 1], a[i - 1][j]), min(a[i][j + 1], a[i + 1][j])); } } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

covering.cpp: In function 'int main()':
covering.cpp:23:30: warning: unused variable 'asn' [-Wunused-variable]
   23 |     int n, m, i, j, x, y, k, asn;
      |                              ^~~
#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...