제출 #466733

#제출 시각아이디문제언어결과실행 시간메모리
466733mtxasT-Covering (eJOI19_covering)C++14
0 / 100
1 ms460 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 **********************************************************************************/ const int maxk = 1001, inf = 1e9+10; int r[maxk], c[maxk]; int n, m; vector<vi> table, val; int dy[4] = {1, 0, -1, 0}; int dx[4] = {0, 1, 0, -1}; /********************************************************************************** FUNCTIONS **********************************************************************************/ bool validSpecCell(int r, int c){ bool valid = 1; valid &= (!(r == 1 && (c == 1 || c==m))); valid &= (!(r == n && (c==1 || c== m))); return valid; } /********************************************************************************** MAIN **********************************************************************************/ signed main(){ // _fre(); turbo(); cin>>n>>m; table.resize(n+2, vi(m+2, 0)); val.resize(n+2, vi(m+2, 0)); _foreq(i, 1, n)_foreq(j, 1, m) cin>>table[i][j]; int k; cin>>k; _for(i, 0, k) cin>>r[i]>>c[i], r[i]++, c[i]++; _for(i, 0, k) if(!validSpecCell(r[i], c[i])) {cout<<"No"; return 0;} ll ans = 0; _for(i, 0, k){ int rr = r[i], cc = c[i]; val[rr][cc] = 0; int minVal = inf; _for(dir, 0, 4){ int nr = rr + dy[dir], nc = cc + dx[dir]; val[rr][cc] += table[nr][nc]; minVal = min(minVal, table[nr][nc]); } val[rr][cc] -= minVal; ans += val[rr][cc]; } cout<<ans; }

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

covering.cpp: In function 'int main()':
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:53:5: note: in expansion of macro '_foreq'
   53 |     _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:53:20: note: in expansion of macro '_foreq'
   53 |     _foreq(i, 1, n)_foreq(j, 1, m) cin>>table[i][j];
      |                    ^~~~~~
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:55:5: note: in expansion of macro '_for'
   55 |     _for(i, 0, k) cin>>r[i]>>c[i], r[i]++, c[i]++;
      |     ^~~~
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:56:5: note: in expansion of macro '_for'
   56 |     _for(i, 0, k)
      |     ^~~~
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:59:5: note: in expansion of macro '_for'
   59 |     _for(i, 0, k){
      |     ^~~~
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:63:9: note: in expansion of macro '_for'
   63 |         _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...