标签:nes number icp strong eve types img equal typedef
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1958 Accepted Submission(s): 1223
1 #include <iostream> 2 #include <string> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 #include <climits> 7 #include <cmath> 8 #include <vector> 9 #include <queue> 10 #include <stack> 11 #include <set> 12 #include <map> 13 using namespace std; 14 typedef long long LL ; 15 typedef unsigned long long ULL ; 16 const int maxn = 1e3 + 10 ; 17 const int inf = 0x3f3f3f3f ; 18 const int npos = -1 ; 19 const int mod = 1e9 + 7 ; 20 const int mxx = 100 + 5 ; 21 const double eps = 1e-6 ; 22 const double PI = acos(-1.0) ; 23 24 int T, n, m, a[maxn][maxn]; 25 LL ans; 26 int main(){ 27 // freopen("in.txt","r",stdin); 28 // freopen("out.txt","w",stdout); 29 while(~scanf("%d",&T)){ 30 while(T--){ 31 ans=0; 32 memset(a,0,sizeof(a)); 33 scanf("%d %d",&n,&m); 34 for(int i=1;i<=n;i++) 35 for(int j=1;j<=m;j++) 36 scanf("%d",&a[i][j]); 37 for(int i=1;i<=n;i++) 38 for(int j=1;j<=m;j++) 39 if(a[i][j]) 40 ans+=(4*a[i][j]+1) 41 -min(a[i][j],a[i-1][j])-min(a[i][j],a[i+1][j]) 42 -min(a[i][j],a[i][j-1])-min(a[i][j],a[i][j+1]); 43 printf("%lld\n",ans); 44 } 45 } 46 return 0; 47 }
标签:nes number icp strong eve types img equal typedef
原文地址:http://www.cnblogs.com/edward108/p/7638661.html