제출 #1049600

#제출 시각아이디문제언어결과실행 시간메모리
1049600vjudge1T-Covering (eJOI19_covering)C++17
70 / 100
37 ms8792 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e3 + 2; vector<int> a[N], xet[N]; vector<bool> check[N], dem[N], red[N]; int n, m, q, x[N], y[N]; int ans = 0, tmp = 0, tmp1 = 0; int xx[] = {-1, -2, -1, 0, 1, 2, 1, 0, -1, 0, 1, 0}, yy[] = {-1, 0, 1, 2, 1, 0, -1, -2, 0, 1, 0, -1}; bool in(int u, int v) { if(u < 0 || v < 0 || u >= n || v >= m) return false; return true; } void dfs(int u, int v, int j) { tmp += a[u][v]; tmp1++; check[u][v] = true; for(int i = 8; i < 12; i++) { if(in(u + xx[i], v + yy[i]) && !dem[u + xx[i]][v + yy[i]] && !red[u + xx[i]][v + yy[i]]) { dem[u + xx[i]][v + yy[i]] = true; xet[j].push_back(a[u + xx[i]][v + yy[i]]); } } for(int i = 0; i < 8; i++) { if(in(u + xx[i], v + yy[i]) && !check[u + xx[i]][v + yy[i]] && red[u + xx[i]][v + yy[i]]) dfs(u + xx[i], v + yy[i], j); } } int main () { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) { a[i].resize(m + 2); check[i].resize(m + 2); dem[i].resize(m + 2); red[i].resize(m + 2); for(int j = 0; j < m; j++) { cin >> a[i][j]; check[i][j] = dem[i][j] = red[i][j] = false; } } cin >> q; for(int i = 1; i <= q; i++) { cin >> x[i] >> y[i]; if(red[x[i]][y[i]]) { cout << "No"; return 0; } red[x[i]][y[i]] = true; } for(int i = 1; i <= q; i++) { if(!check[x[i]][y[i]]) { tmp = tmp1 = 0; dfs(x[i], y[i], i); // cout << xet[i].size() << '\n'; if(xet[i].size() < 3 * tmp1) { cout << "No"; return 0; } ans += tmp; sort(xet[i].begin(), xet[i].end(), greater<int>()); for(int j = 0; j < 3 * tmp1; j++) ans += xet[i][j]; } } cout << ans; return 0; }

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

covering.cpp: In function 'int main()':
covering.cpp:75:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   75 |             if(xet[i].size() < 3 * tmp1)
      |                ~~~~~~~~~~~~~~^~~~~~~~~~
#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...