青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

我要啦免费统计
#include <stdio.h>
#include 
<stdlib.h>
#include 
<assert.h>

#define NAME "starry"
/* MAXSTAR is the largest a cluster can be */
#define MAXSTAR 160

/* the board */
char board[100][100];
int w, h;

/* clusters already lettered */
int stars[26][MAXSTAR]; /* stars are stored as xval + yval*1000 */
int count[26]; /* number of stars */
int size[26][2]; /* the x & y dimensions */
int nstart; /* number of clusters */

/* the current cluster */
int current[MAXSTAR][2]; /* y, x */
int ncurrent; /* number of stars in current cluster */

/* int_comp is integer comparison, used for bsearch and qsort */
int
int_comp(
const void *pa, const void *pb)
 {
  
int a = *(int*)pa;
  
int b = *(int*)pb;
  
if (a > b) return 1;
  
else if (a < b) return -1;
  
else return 0;
 }

/* find the boundary (in my,mx,My, and Mx.. m is minimum, M is maximum */
/* also fills in current */
int
find_boundary(
int y, int x, int *my, int *mx, int *My, int *Mx)
 {
  
int rv = 0;
  
if (board[y][x] != '1'return 0/* not a star or already visited */
  rv
++/* one more star */
  board[y][x] 
= '2'/* mark as visited */

  
/* put in current cluster */
  current[ncurrent][
0= y;
  current[ncurrent][
1= x;
  ncurrent
++;

  
/* update boundary */
  
if (y < *my) *my = y;
  
if (y > *My) *My = y;
  
if (x < *mx) *mx = x;
  
if (x > *Mx) *Mx = x;

  
/* check all adjacent stars */
  
if (x > 0
   {
    x
--;
    rv 
+= find_boundary(y, x, my, mx, My, Mx);
    
if (y > 0) rv += find_boundary(y-1, x, my, mx, My, Mx);
    
if (y+1 < h) rv += find_boundary(y+1, x, my, mx, My, Mx);
    x
++;
   }
  
if (y > 0) rv += find_boundary(y-1, x, my, mx, My, Mx);
  
if (y+1 < h) rv += find_boundary(y+1, x, my, mx, My, Mx);
  
if (x+1 < w)
   {
    x
++;
    rv 
+= find_boundary(y, x, my, mx, My, Mx);
    
if (y > 0) rv += find_boundary(y-1, x, my, mx, My, Mx);
    
if (y+1 < h) rv += find_boundary(y+1, x, my, mx, My, Mx);
    x
--;
   }
  
return rv;
 }

/* this is a very basic flood fillfill ch everywhere there's not a '0' */
void
mark_shape(
int y, int x, char ch)
 {
  
if (board[y][x] == ch) return/* done already */
  
if (board[y][x] == '0'return/* nothing to do */

  board[y][x] 
= ch;

  
/* recurse on all boundary stars */
  
if (x > 0
   {
    x
--;
    mark_shape(y, x, ch);
    
if (y > 0) mark_shape(y-1, x, ch);
    
if (y+1 < h) mark_shape(y+1, x, ch);
    x
++;
   }
  
if (y > 0) mark_shape(y-1, x, ch);
  
if (y+1 < h) mark_shape(y+1, x, ch);
  
if (x+1 < w) 
   {
    x
++;
    mark_shape(y, x, ch);
    
if (y > 0) mark_shape(y-1, x, ch);
    
if (y+1 < h) mark_shape(y+1, x, ch);
   }
 }

/* is shape id the same as the current shape */
/* specify the orientation with dy/dx and by/bx */
/* dy/dx is the difference value to associate with y and x changes */
/* by/bx is the upper right corner of the bounding box with respect
   to the current orientation 
*/
/* NOTE: assumes that the number of stars are the same */
int
check_shape(
int id, int dy, int dx, int by, int bx)
 {
  
int lv;
  
int pval;

  
for (lv = 0; lv < ncurrent; lv++)
   {
    pval 
= (current[lv][0]-by)*dy + (current[lv][1]-bx)*dx;
    
if (!bsearch(&pval, stars[id], count[id], sizeof(stars[id][0]), int_comp))
      
return 0/* found a star that didn't match */
   }
  
return 1;
 }

/* we found a star here, make it a cluster */
void
fix_board(
int y, int x)
 {
  
int mx, my, Mx, My;
  
int cnt;
  
int lv;
  
int pw, ph;
  
int f;

/* gather the cluster information */
  mx 
= Mx = x;
  my 
= My = y;

  ncurrent 
= 0;
  cnt 
= find_boundary(y, x, &my, &mx, &My, &Mx);

  pw 
= Mx - mx + 1;
  ph 
= My - my + 1;

  f 
= 0;
  
/* check each cluster */
  
for (lv = 0; lv < nstart; lv++)
    
if (cnt == count[lv]) /* the cluster must have the same # of stars */
     {
      
if (pw == size[lv][1&& ph == size[lv][0])
       { 
/* the bounding box sizes match */
 f 
+= check_shape(lv, 10001, my, mx);
 f 
+= check_shape(lv, 1000-1, my, Mx);
 f 
+= check_shape(lv, -10001, My, mx);
 f 
+= check_shape(lv, -1000-1, My, Mx);
       }
      
if (pw == size[lv][0&& ph == size[lv][1])
       { 
/* the bounding box sizes match */
 f 
+= check_shape(lv, 11000, my, mx);
 f 
+= check_shape(lv, 1-1000, my, Mx);
 f 
+= check_shape(lv, -11000, My, mx);
 f 
+= check_shape(lv, -1-1000, My, Mx);
       }
      
if (f) break;
     }
  
if (f) mark_shape(y, x, 'a' + lv); /* found match */
  
else { /* new cluster! */
    count[nstart] 
= 0;
    mark_shape(y, x, 
'a' + nstart);
    
for (lv = 0; lv < ncurrent; lv++)
      stars[nstart][lv] 
= (current[lv][0]-my)*1000 + (current[lv][1]-mx);
    count[nstart] 
= ncurrent;
    
/* we need the stars in increasing order */
    qsort(stars[nstart], count[nstart], 
sizeof(stars[nstart][0]), int_comp);
    size[nstart][
0= ph;
    size[nstart][
1= pw;
    nstart
++;
   }
 }

int
main(
int argc, char **argv)
 {
  
//FILE *fin, *fout;
  int lv, lv2;

  
//fin = fopen(NAME ".in", "r");
  
//fout = fopen(NAME ".out", "w");
  
//assert(fin);
 
// assert(fout);

/* read in the data */
  scanf (
"%d %d"&w, &h);

  
for (lv = 0; lv < h; lv++) scanf ("%s", board[lv]);
 
// fclose(fin);

/* everywhere there's a star not in a cluster, make it into one */
  
for (lv = 0; lv < h; lv++)
    
for (lv2 = 0; lv2 < w; lv2++)
      
if (board[lv][lv2] == '1')
        fix_board(lv, lv2);

/* output data */
  
for (lv = 0; lv < h; lv++)
   {
    printf (
"%c", board[lv][0]);
    
for (lv2 = 1; lv2 < w; lv2++)
      printf (
"%c", board[lv][lv2]);
     printf ( 
"\n");
   }

 
// fclose(fout);
  return 0;
 }


修改 usaco 分析的代碼
floodfill找出1的區域  在和以前找出的區域 旋轉匹配 如果找到則用前面那個編號 找不到則編號加1

posted on 2008-10-11 15:58 閱讀(447) 評論(0)  編輯 收藏 引用 所屬分類: pku
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲欧洲一区二区在线播放| 欧美在线不卡视频| 亚洲午夜激情网页| 在线午夜精品| 一区二区三区导航| 亚洲私人影院在线观看| 一区二区不卡在线视频 午夜欧美不卡在 | 久久乐国产精品| 久久先锋资源| 欧美成年人网站| 欧美日韩久久| 国产精品入口夜色视频大尺度| 国产精品视频一区二区高潮| 国产香蕉97碰碰久久人人| 一色屋精品视频在线看| 最新国产精品拍自在线播放| 一区二区免费在线播放| 亚洲女优在线| 噜噜噜91成人网| 艳妇臀荡乳欲伦亚洲一区| 亚洲综合精品一区二区| 久久久91精品国产| 欧美无乱码久久久免费午夜一区| 国产午夜精品理论片a级探花| 亚洲国产成人在线视频| 亚洲永久在线观看| 欧美电影美腿模特1979在线看 | 欧美人交a欧美精品| 亚洲欧美在线观看| 久久久久高清| 亚洲男人的天堂在线观看 | 国内精品免费在线观看| 欧美三级第一页| 亚洲欧美影音先锋| 久久这里有精品视频| 亚洲国产99| 亚洲精品中文字幕女同| 欧美激情视频在线免费观看 欧美视频免费一 | 中国女人久久久| 欧美一进一出视频| 久久视频一区| 亚洲一区精彩视频| 国产精品激情av在线播放| 免费不卡亚洲欧美| 国内外成人免费激情在线视频| 欧美成人激情视频| 亚洲日本中文| 久久这里有精品15一区二区三区| 久久精品日韩欧美| 久久久久久精| 亚洲伦理一区| 欧美www视频在线观看| 欧美在线在线| 欧美激情视频一区二区三区免费 | 麻豆精品91| 亚洲国产成人高清精品| 亚洲一区二区av电影| 亚洲一区二区免费视频| 亚洲第一精品夜夜躁人人躁| 国产一区二区0| 亚洲国产日韩综合一区| 免费看精品久久片| 国内成人精品视频| 久久精品人人做人人爽| 99视频精品全国免费| 欧美亚洲免费| 国产一区二区黄色| 欧美成人国产| 性欧美8khd高清极品| 美女国产精品| 亚洲精品久久久久久久久| 亚洲欧美中日韩| 日韩亚洲精品视频| 亚洲剧情一区二区| 在线观看亚洲视频| 在线观看亚洲一区| 亚洲麻豆视频| 亚洲国产欧美精品| 老司机精品视频一区二区三区| 久久国产天堂福利天堂| 欧美美女福利视频| 在线视频日本亚洲性| 久久成人资源| 国产精品久久久久久久久久直播| 国产视频一区免费看| 日韩视频免费观看高清在线视频 | 99日韩精品| 亚洲激精日韩激精欧美精品| 免费看亚洲片| 亚洲综合色激情五月| 国产一区二区三区高清在线观看 | 亚洲欧美国产77777| 日韩亚洲视频| 欧美大片免费观看| 亚洲一区二区三区国产| 亚洲视频一二三| 亚洲一区二区三区三| 欧美激情中文字幕一区二区| 国产精品久久久久久久久搜平片 | 开元免费观看欧美电视剧网站| 久久久久久久一区| 激情欧美一区二区三区| 久久色在线播放| 久久成人免费| 欧美日韩视频在线一区二区观看视频| 日韩亚洲欧美成人一区| 国产精品欧美日韩一区| 亚洲天天影视| 午夜日本精品| 亚洲国产裸拍裸体视频在线观看乱了中文 | 午夜精彩视频在线观看不卡| 欧美精品日韩综合在线| 久久爱www| 免费在线观看成人av| 久久九九国产精品| 久久人人看视频| 国产亚洲欧美在线| 一区二区三区不卡视频在线观看 | 欧美精品99| 亚洲精品一区二区三区在线观看 | 欧美日韩日本国产亚洲在线 | 久久精品91| 亚洲国产精品久久久久婷婷老年 | 久久久久久久综合日本| 亚洲午夜一二三区视频| 国产精品大片免费观看| 牛牛精品成人免费视频| 在线精品一区| 亚洲国产视频a| 亚洲三级影片| 亚洲一区二区黄| 久久久久综合网| 亚洲网站在线播放| 国产亚洲激情在线| 欧美一区二区三区视频免费| 99视频热这里只有精品免费| 欧美日韩高清免费| 欧美一区二区三区另类 | 欧美激情aⅴ一区二区三区| 亚洲女ⅴideoshd黑人| 激情另类综合| 午夜精品久久久久久久久久久久久| 一本色道久久综合精品竹菊| 亚洲精品日韩久久| 久久午夜精品一区二区| 国产免费亚洲高清| 午夜国产不卡在线观看视频| 亚洲综合色视频| 久久国产加勒比精品无码| 亚洲狠狠丁香婷婷综合久久久| 一本到高清视频免费精品| 影院欧美亚洲| 在线观看日韩专区| 欧美色123| 欧美jizzhd精品欧美喷水| 一本色道久久综合亚洲91| 欧美精品久久久久a| 久久噜噜噜精品国产亚洲综合| 老牛国产精品一区的观看方式| 99在线热播精品免费| 亚洲黄色成人| 国产精品高潮呻吟久久av黑人| 欧美另类视频在线| 午夜伦欧美伦电影理论片| 亚洲一区二区三区中文字幕在线 | 久久视频在线看| 久久视频在线视频| 午夜视频在线观看一区二区| 亚洲天堂久久| 亚洲欧美一区二区视频| 久久精品免费看| 欧美激情第五页| 亚洲国产另类久久精品| 一区二区三区欧美成人| 在线视频日韩精品| 国产一区二区黄| 国产精品亚洲欧美| 久久成年人视频| 日韩午夜在线| 欧美在线亚洲| 玖玖视频精品| 国产精品国产三级国产专播精品人 | 午夜精品三级视频福利| 国产专区一区| 在线不卡欧美| 午夜久久久久久| 亚洲第一网站| 亚洲一区二区三区高清| 久久夜色精品国产亚洲aⅴ| 国产一区二区三区的电影| 亚洲免费视频一区二区| 欧美14一18处毛片| 亚洲少妇在线| 免费久久99精品国产自| 国产精品久久久一区二区| 在线成人小视频| 亚洲人www| 欧美激情精品久久久六区热门| 欧美国产日韩亚洲一区| 欧美激情第二页|