제출 #495383

#제출 시각아이디문제언어결과실행 시간메모리
495383uncriptedT-Covering (eJOI19_covering)C++11
15 / 100
203 ms15832 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=-1; int pas2=-1; int pas3=-1; int pas4=-1; if(j-1>=0 && j+1<m && i+1<n){ pas1=a[i][j]+a[i+1][j]+a[i][j-1]+a[i][j+1]; } if(j-1>=0 && j+1<m && i-1>=0){ pas2=a[i][j]+a[i-1][j]+a[i][j-1]+a[i][j+1]; } if(j+1<m && i+1<n && i-1>=0 ){ pas3=a[i][j]+a[i][j+1]+a[i+1][j]+a[i-1][j]; } if(j-1>=0 && i+1<n && i-1>=0 ){ 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 if(fix[i][j]==1){ pas+=a[i][j]; } } } cout<<pas; }

컴파일 시 표준 에러 (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...