Submission #1053187

#TimeUsernameProblemLanguageResultExecution timeMemory
1053187NickpapadakT-Covering (eJOI19_covering)C++14
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define XX first #define YY second const unsigned int MAXK = 1e+6 + 10; vector<vector<int> > grid; vector<vector<bool> > sgrid; vector<pair<int,int> > special; int N,M, K; int firsSub(){ int ans = 0; // totalinc = 0/; for(int i = 0; i<K; ++i){ int c = 0; int x = special[i].XX, y = special[i].YY; int u = 0,r=0,l=0,d=0; r += grid[x+1][y]; r += grid[x][y+1]; r += grid[x][y-1]; l += grid[x-1][y]; l += grid[x][y+1]; l += grid[x][y-1]; d += grid[x-1][y]; d += grid[x+1][y]; d += grid[x][y+1]; u += grid[x-1][y]; u += grid[x+1][y]; u += grid[x][y-1]; // int x = special[i].X, y = special[i].Y; ans += grid[x][y]; if(x == 1 || sgrid[x-1][y]){ ans += r; c++; } if(x == M || sgrid[x+1][y]){ ans += l; c++; } if(y == 1 || sgrid[x][y-1]){ ans += d; c++; } if(y == N || sgrid[x][y+1]){ ans += u; c++; } if(c>=2) return -1; if(c==1) continue; int best = max(l, r); best = max(best, u); ans += max(best, d); } return ans; } int main(){ scanf("%d%d", &N,&M);// N = y M = x grid.resize(M+2, vector<int>(N+2, 0)); sgrid.resize(M+2, vector<bool>(N+2,0)); for(int y = 1; y <=N;++y){ for(int x = 1; x <=M; ++x){ scanf("%d", &grid[x][y]); // printf("done\n"); } } scanf("%d", &K); for(int i = 1; i<=K; ++i){ int a,b; scanf("%d%d", &a,&b); special.push_back({a+1,b+1}); sgrid[a+1][b+1] = 1; // printf("%d\n", grid[a+1][b+1]); } int sol = firsSub(); if(sol == -1) printf("No"); else printf("%d\n", sol); return 0; }

Compilation message (stderr)

covering.cpp: In function 'int main()':
covering.cpp:61:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     scanf("%d%d", &N,&M);// N = y M = x
      |     ~~~~~^~~~~~~~~~~~~~~
covering.cpp:66:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |             scanf("%d", &grid[x][y]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~
covering.cpp:70:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |     scanf("%d", &K);
      |     ~~~~~^~~~~~~~~~
covering.cpp:73:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         scanf("%d%d", &a,&b);
      |         ~~~~~^~~~~~~~~~~~~~~
#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...