Submission #495375

#TimeUsernameProblemLanguageResultExecution timeMemory
495375uncriptedT-Covering (eJOI19_covering)C++11
0 / 100
3 ms332 KiB
#include<bits/stdc++.h> #define f first #define s second using namespace std; int main(){ int n,m; cin>>n>>m; int a[n][m]; int r[n][m]; int fix[n][m]; for(int i=0; i<n; i++){ for (int j=0; j<m; j++){ cin>>a[i][j]; r[i][j]=0; fix[i][j]=0; } } int k; cin>>k; pair<int,int> c[k]; for(int i=0; i<k; i++){ cin>>c[i].f>>c[i].s; r[c[i].f][c[i].s]=1; } int pas=0; pair<int,int> d[8]={{1,1}, {1,0}, {1,-1}, {0,1}, {0, -1}, {-1,1}, {-1, 0}, {-1,-1}}; for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ int p=0; for(int ii=0; ii<8; ii++){ int x=i+d[ii].f; int y=j+d[ii].s; if(r[i][j]==1 && r[x][y]==1){ p++; fix[i][j]=1; fix[i+1][j]=1; fix [i-1][j]=1; fix[i][j-1]=1; fix[i][j+1]=1; fix[x][y]; fix[x+1][y]; fix[x-1][y]; fix[x][y-1]; fix[x][y+1]; } } if(p>1){ cout<<"No"<<endl; return 0; } } } for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ if(fix[i][j]!=1 && r[i][j]==1){ int pas1=a[i][j]+a[i+1][j]+a[i][j-1]+a[i][j+1]; int pas2=a[i][j]+a[i-1][j]+a[i][j-1]+a[i][j+1]; int pas3=a[i][j]+a[i][j+1]+a[i+1][j]+a[i-1][j]; int pas4=a[i][j]+a[i][j+1]+a[i+1][j]+a[i-1][j]; pas+=max(max(pas1,pas2), max(pas3,pas4)); }else{ pas+=a[i][j]; } } } cout<<pas; }

Compilation message (stderr)

covering.cpp: In function 'int main()':
covering.cpp:43:14: warning: statement has no effect [-Wunused-value]
   43 |      fix[x][y];
      |      ~~~~~~~~^
covering.cpp:44:17: warning: statement has no effect [-Wunused-value]
   44 |       fix[x+1][y];
      |       ~~~~~~~~~~^
covering.cpp:45:18: warning: statement has no effect [-Wunused-value]
   45 |        fix[x-1][y];
      |        ~~~~~~~~~~^
covering.cpp:46:19: warning: statement has no effect [-Wunused-value]
   46 |         fix[x][y-1];
      |         ~~~~~~~~~~^
covering.cpp:47:20: warning: statement has no effect [-Wunused-value]
   47 |          fix[x][y+1];
      |          ~~~~~~~~~~^
#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...