Submission #447833

#TimeUsernameProblemLanguageResultExecution timeMemory
447833bigoT-Covering (eJOI19_covering)C++14
0 / 100
4 ms332 KiB
#include <bits/stdc++.h> #include <cmath> typedef unsigned long long ll; #define pii pair<int,int> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>>vec(n, vector<int>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> vec[i][j]; } } int k; cin >> k; vector<pii>spe(k); for (int i = 0; i < k; i++) cin >> spe[i].first >> spe[i].second; ll ans = 0; bool flag1 = false; for (int i = 0; i < k; i++) { vector<int>vec1; vec1.push_back(vec[spe[i].first][spe[i].second]); if (spe[i].first < n - 1) vec1.push_back(vec[spe[i].first + 1][spe[i].second]); if (spe[i].first > 0) vec1.push_back(vec[spe[i].first - 1][spe[i].second]); if (spe[i].second < m - 1) vec1.push_back(vec[spe[i].first][spe[i].second + 1]); if (spe[i].second > 0) vec1.push_back(vec[spe[i].first][spe[i].second - 1]); if (vec1.size() < 4) { cout << "No"; flag1 = true; break; } sort(vec1.begin(), vec1.end()); int j = vec1.size() - 1; int tmp = 4; while (tmp--) { ans += vec1[j]; j--; } vec1.resize(0); } if(!flag1) cout << ans; }
#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...