Submission #466820

#TimeUsernameProblemLanguageResultExecution timeMemory
466820mtxasT-Covering (eJOI19_covering)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define fi first #define se second #define pll pair<ll, ll> #define mii map<int, int> #define vi vector<int> #define vll vector<ll> #define pb push_back #define all(a) a.begin(), a.end() #define sz(x) ((int)x.size()) #define turbo() cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false) #define _fre() freopen("input.txt", "r", stdin) #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++) #define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++) #define _forneq(a, b, c) for(int (a) = (b); (a) >= (c); (a)--) #define _forn(a, b, c) for(int (a) = (b); (a) > (c); (a)--) using namespace std; #define int ll /********************************************************************************** STRUCTS **********************************************************************************/ /********************************************************************************** VARIABLES **********************************************************************************/ int n, m, k, ans = 0; vector<vi> table; vector<pii> specials; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; /********************************************************************************** FUNCTIONS **********************************************************************************/ bool isEdge(int r, int c){ return (r==1 or r==n) and (c==1 or c==m); } void prepTable(){ table.resize(n+2, vi(m+2, 0)); _foreq(i, 1, n) _foreq(j, 1, m) cin>>table[i][j]; } void getSpecialCells(){ cin>>k; _for(i, 0, k) { int r, c; cin>>r>>c; r++, c++; specials.pb({r, c}); } } void readInput(){ cin>>n>>m; prepTable(); getSpecialCells(); } bool haveEdge(){ for(auto p: specials) if(isEdge(p.fi, p.se)) return true; return false; } /********************************************************************************** MAIN **********************************************************************************/ signed main(){ // _fre(); turbo(); readInput(); if(haveEdge()){cout<<"No"; return 0;} for(auto [r, c]: specials){ int mn = 10000; _for(dir, 0, 4){ int rr = r + dy[dir], cc = c + dx[dir]; ans += table[rr][cc]; mn = min(mn, table[rr][cc]); } ans-= mn; } cout<<ans; }

Compilation message (stderr)

covering.cpp: In function 'void prepTable()':
covering.cpp:17:33: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   17 | #define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++)
      |                                 ^
covering.cpp:43:5: note: in expansion of macro '_foreq'
   43 |     _foreq(i, 1, n) _foreq(j, 1, m) cin>>table[i][j];
      |     ^~~~~~
covering.cpp:17:33: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   17 | #define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++)
      |                                 ^
covering.cpp:43:21: note: in expansion of macro '_foreq'
   43 |     _foreq(i, 1, n) _foreq(j, 1, m) cin>>table[i][j];
      |                     ^~~~~~
covering.cpp: In function 'void getSpecialCells()':
covering.cpp:16:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   16 | #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++)
      |                               ^
covering.cpp:47:5: note: in expansion of macro '_for'
   47 |     _for(i, 0, k) {
      |     ^~~~
covering.cpp: In function 'int main()':
covering.cpp:70:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   70 |     for(auto [r, c]: specials){
      |              ^
covering.cpp:16:31: warning: unnecessary parentheses in declaration of 'dir' [-Wparentheses]
   16 | #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++)
      |                               ^
covering.cpp:72:9: note: in expansion of macro '_for'
   72 |         _for(dir, 0, 4){
      |         ^~~~
#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...