{"action":"opened","issue":{"url":"https://api.github.com/repos/danwenxuan/1001--/issues/1","repository_url":"https://api.github.com/repos/danwenxuan/1001--","labels_url":"https://api.github.com/repos/danwenxuan/1001--/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/danwenxuan/1001--/issues/1/comments","events_url":"https://api.github.com/repos/danwenxuan/1001--/issues/1/events","html_url":"https://github.com/danwenxuan/1001--/issues/1","id":223767393,"number":1,"title":"1001部落割据","user":{"login":"danwenxuan","id":9939468,"avatar_url":"https://avatars2.githubusercontent.com/u/9939468?v=3","gravatar_id":"","url":"https://api.github.com/users/danwenxuan","html_url":"https://github.com/danwenxuan","followers_url":"https://api.github.com/users/danwenxuan/followers","following_url":"https://api.github.com/users/danwenxuan/following{/other_user}","gists_url":"https://api.github.com/users/danwenxuan/gists{/gist_id}","starred_url":"https://api.github.com/users/danwenxuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danwenxuan/subscriptions","organizations_url":"https://api.github.com/users/danwenxuan/orgs","repos_url":"https://api.github.com/users/danwenxuan/repos","events_url":"https://api.github.com/users/danwenxuan/events{/privacy}","received_events_url":"https://api.github.com/users/danwenxuan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-24T10:06:06Z","updated_at":"2017-04-24T10:06:06Z","closed_at":null,"body":"#include<stdio.h>\r\nint map[101][101],temp[101][101];\r\nint vis[101][101],c[6],mark[101][101];\r\nint N,res,m;\r\nvoid dfs(int x,int y,int n){                                //遍历零周围的数\r\n    if(x < 0 || y < 0 || x >= N || y >= N || mark[x][y] == m ) return;\r\n    if(n != 0 && map[x][y] != n) return;\r\n    mark[x][y] = m;\r\n    if(n == 0 && map[x][y] == 0){\r\n        dfs(x-1,y,0);dfs(x+1,y,0);dfs(x,y-1,0);dfs(x,y+1,0);\r\n    }else if(n == 0 && map[x][y] != 0){\r\n        dfs(x-1,y,map[x][y]); dfs(x+1,y,map[x][y]); dfs(x,y-1,map[x][y]); dfs(x,y+1,map[x][y]);\r\n        c[map[x][y]]++;\r\n    }else{\r\n        dfs(x-1,y,n);dfs(x+1,y,n); dfs(x,y-1,n); dfs(x,y+1,n);\r\n        c[n]++;\r\n    }\r\n}\r\n  \r\nvoid fill(int x,int y,int l){                                         //修改值\r\n    if(x < 0 || y < 0 || x >= N || y >= N || map[x][y] != 0 || temp[x][y] == l) return;\r\n    temp[x][y] = l;\r\n    fill(x-1,y,l);fill(x+1,y,l); fill(x,y-1,l);fill(x,y+1,l);\r\n}\r\n  \r\nvoid count(int x,int y,int a){          //统计势力区域数\r\n    if(x < 0 || y < 0 || x >= N || y >= N || temp[x][y] != a || vis[x][y] == 1) return;\r\n    vis[x][y] = 1;\r\n    count(x-1,y,a); count(x,y-1,a);count(x+1,y,a); count(x,y+1,a);\r\n}\r\n  \r\nvoid test_main(int t)\r\n{\r\n   res=m=0;int x,y;int l;\r\n   scanf(\"%d\",&N);\r\n   for(int i=0;i<N;i++)\r\n       for(int j=0;j<N;j++){\r\n           scanf(\"%d\",&map[i][j]);\r\n           vis[i][j]=0;mark[i][j]=0; temp[i][j]=map[i][j];\r\n       } \r\n   for(int i=0;i<N;i++)\r\n       for(int j=0;j<N;j++)\r\n            if(map[i][j]==0 &&mark[i][j]==0){\r\n                c[1]=c[2]=c[3]=c[4]=c[5]=0;\r\n                m++;\r\n               x=i;y=j; dfs(x,y,0); l = 5;\r\n              for(int k = 4;k > 0;k--)\r\n                     if(c[k] > c[l])l = k;\r\n               fill(i,j,l);\r\n       }\r\n    for(int i = 0;i <N;i++)\r\n            for(int j = 0;j < N;j++)\r\n                if(vis[i][j]==0){\r\n                    count(i,j,temp[i][j]);\r\n                    res++;\r\n                    //printf(\"%d\\n\",res);\r\n                }\r\n    printf(\"#%d %d\\n\",t,res);\r\n}"}}
{"actor":{"display_login":"danwenxuan"}}