제출 #1049628

#제출 시각아이디문제언어결과실행 시간메모리
1049628vjudge1T-Covering (eJOI19_covering)C++17
100 / 100
61 ms20052 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second vector<vector<int>> a,check,dp; int m,n,k,x,y,ketqua; int dx[]={0,0,-1,1}; int dy[]={1,-1,0,0}; int soluong,minn,tong,soluongx; void dfs(int u,int v) { check[u][v]=1; soluongx+=dp[u][v]; tong+=a[u][v]; if (dp[u][v]==0) minn=min(minn,a[u][v]),soluong++; for (int i=0;i<4;++i) { int u1=u+dx[i]; int v1=v+dy[i]; if (u1==0 || u1==m+1 || v1==0 || v1==n+1 || dp[u1][v1]==dp[u][v] || check[u1][v1]) continue; dfs(u1,v1); } } main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>m>>n; a.resize(m+1); dp.resize(m+1); check.resize(m+1); for (int i=1;i<=m;++i) { a[i].resize(n+1); check[i].resize(n+1); dp[i].resize(n+1); } for (int i=1;i<=m;++i) { for (int j=1;j<=n;++j) cin>>a[i][j]; } cin>>k; for (int i=1;i<=k;++i) { cin>>x>>y; x++; y++; dp[x][y]=1; } for (int i=1;i<=m;++i) { for (int j=1;j<=n;++j) { if (check[i][j] || dp[i][j]==0) continue; minn=10000000; tong=0; soluong=0; soluongx=0; dfs(i,j); if (soluong!=3*soluongx && soluong!=3*soluongx+1) { cout<<"No"; return 0; } ketqua+=tong; if (soluong==soluongx*3+1) ketqua-=minn; } } cout<<ketqua; }

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

covering.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main()
      | ^~~~
#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...