Submission #464520

#TimeUsernameProblemLanguageResultExecution timeMemory
464520kilikumaT-Covering (eJOI19_covering)C++14
0 / 100
25 ms588 KiB
#include <bits/stdc++.h> using namespace std; int maxi=0; int m, n; bool dans(int lig, int col) { if (lig<0||col<0||lig>=m||col>=n) return false; else return true; } int main() { scanf("%d%d", &m,&n); int grille[m+5][n+5]; for (int lig=0;lig<m;lig++) { for (int col=0;col<n;col++) { cin >> grille[lig][col]; } } int k; cin >> k ; for (int i=0;i<k;i++) { int x, y; cin >> x >> y; int maxiCur = -1; // premier cas if(x-1>=0&&y+1<m&&y-1>=0){ maxiCur=max(maxiCur,grille[x-1][y]+grille[x][y+1]+grille[x][y-1]); } if(x-1>=0&&y-1>=0&&x+1<n){ maxiCur=max(maxiCur,grille[x-1][y]+grille[x+1][y]+grille[x][y-1]); } if(x-1>=0&&x+1<n&&y+1<m){ maxiCur=max(maxiCur,grille[x-1][y]+grille[x+1][y]+grille[x][y+1]); } if(y+1<m&&y-1>=0&&x+1<n){ maxiCur=max(maxiCur,grille[x][y+1]+grille[x][y-1]+grille[x+1][y]); } if(maxiCur==-1){ cout<<"No"<<endl; return 0; } // 2 // 3 // 4 maxi += grille[x][y]; maxi += maxiCur; } printf("%ld\n", maxi); }

Compilation message (stderr)

covering.cpp: In function 'int main()':
covering.cpp:46:13: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
   46 |   printf("%ld\n", maxi);
      |           ~~^     ~~~~
      |             |     |
      |             |     int
      |             long int
      |           %d
covering.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d%d", &m,&n);
      |   ~~~~~^~~~~~~~~~~~~~~
#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...