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

我要啦免费统计
#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>
            亚洲片在线观看| 欧美特黄a级高清免费大片a级| 欧美制服丝袜第一页| 在线中文字幕一区| av成人国产| 亚洲视频久久| 午夜国产不卡在线观看视频| 欧美一级片一区| 久久精品亚洲乱码伦伦中文 | 国产精品视频男人的天堂| 国产精品麻豆欧美日韩ww| 国产精品一区二区男女羞羞无遮挡| 欧美婷婷久久| 国产亚洲欧洲997久久综合| 国内精品嫩模av私拍在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 亚洲国产清纯| 亚洲性夜色噜噜噜7777| 久久久青草青青国产亚洲免观| 欧美成人69| 一区二区久久| 久久久精品2019中文字幕神马| 久久不见久久见免费视频1| 亚洲一区二区三区激情| 亚洲国产精品久久久久久女王 | 午夜亚洲激情| 蜜臀av在线播放一区二区三区| 亚洲福利专区| 午夜在线电影亚洲一区| 欧美精品色综合| 国语对白精品一区二区| 一区二区欧美国产| 美脚丝袜一区二区三区在线观看| 亚洲精品激情| 久久一区亚洲| 国产原创一区二区| 亚洲一级二级| 亚洲激情偷拍| 久久久久久久综合色一本| 国产精品亚洲аv天堂网| 亚洲精品欧美日韩专区| 久久精品视频一| 国产精品99久久久久久久vr| 麻豆精品视频| 有坂深雪在线一区| 久久久www成人免费无遮挡大片| 99国产精品久久久久老师| 欧美ab在线视频| 一区二区三区在线观看视频| 欧美中在线观看| 亚洲综合国产| 国产九区一区在线| 亚洲欧美日韩一区在线| 99国产精品久久久久久久| 欧美人交a欧美精品| 亚洲欧洲日产国码二区| 欧美成人午夜剧场免费观看| 久久久国产亚洲精品| 国产亚洲欧美日韩日本| 久久久久久久久伊人| 午夜日韩激情| 国产一区二区精品久久91| 羞羞色国产精品| 亚洲摸下面视频| 国产精品系列在线播放| 久久久99精品免费观看不卡| 久久精品成人| 在线欧美视频| 欧美激情一区| 欧美精品一区二区三区高清aⅴ| 亚洲精品国产精品国自产在线| 欧美国产日本| 欧美日韩免费看| 亚洲欧美视频在线| 午夜久久电影网| 在线观看日韩| 亚洲美女少妇无套啪啪呻吟| 欧美视频网址| 久久九九有精品国产23| 久久久人人人| 亚洲视频网站在线观看| 欧美福利视频网站| 欧美日韩成人综合天天影院| 今天的高清视频免费播放成人| 久久久久久久尹人综合网亚洲 | 久久综合九色综合久99| 亚洲激情影视| 一区二区三区欧美在线观看| 国产欧美一区二区精品性色| 另类综合日韩欧美亚洲| 欧美激情综合色综合啪啪| 亚洲综合第一页| 久久精品亚洲精品国产欧美kt∨| 亚洲高清在线| 亚洲天堂成人| 在线精品一区二区| 这里只有精品丝袜| 精品动漫一区| 一本久久综合| 亚洲成人在线免费| 一区二区三区毛片| 在线观看精品一区| 亚洲欧美日韩人成在线播放| 亚洲黄色三级| 午夜精品理论片| 99国产精品久久久久久久| 香蕉成人久久| 亚洲视频在线看| 麻豆精品国产91久久久久久| 欧美一区91| 欧美日韩成人在线观看| 欧美xxx成人| 国产精品一区二区三区观看| 亚洲福利小视频| 国内揄拍国内精品少妇国语| 一区二区日韩免费看| 亚洲精品美女在线观看播放| 久久精品一区蜜桃臀影院| 亚洲免费一在线| 欧美日本亚洲韩国国产| 欧美大片免费看| 国产精品亚洲一区二区三区在线| 亚洲欧洲视频| 亚洲欧洲免费视频| 欧美a级在线| 欧美成人一区二区在线| 红桃视频国产精品| 欧美在线视频免费| 欧美一区二区三区免费视频| 欧美日韩在线高清| 亚洲狼人综合| 亚洲网站在线观看| 欧美日韩一区二区三区免费| 亚洲国产免费看| 亚洲日本电影| 欧美激情亚洲精品| 亚洲看片免费| 亚洲欧美国产高清va在线播| 欧美日韩喷水| 在线午夜精品自拍| 午夜精品美女久久久久av福利| 欧美三级视频在线| 一区二区三区欧美激情| 欧美一区永久视频免费观看| 国产欧美一区二区精品仙草咪| 欧美伊人久久久久久午夜久久久久| 欧美一区二区啪啪| 亚洲欧美日韩一区二区| 国产精品一级久久久| 亚洲一区精品视频| 欧美一区二区私人影院日本 | 国产精品女人久久久久久| 亚洲毛片在线观看.| 亚洲精品免费电影| 欧美性一区二区| 亚洲欧美激情在线视频| 久久久精彩视频| 在线成人www免费观看视频| 麻豆成人在线观看| 99国产精品国产精品久久| 欧美在线视频a| 亚洲大胆女人| 欧美吻胸吃奶大尺度电影| 亚洲综合色噜噜狠狠| 蜜桃精品久久久久久久免费影院| 亚洲第一区色| 欧美新色视频| 久久精品国产99| 亚洲黄色免费| 欧美在线精品免播放器视频| 在线观看欧美日韩国产| 欧美色精品天天在线观看视频| 亚洲视频999| 免费观看亚洲视频大全| 亚洲一区二区三区四区五区午夜| 国产一区二区三区自拍| 乱人伦精品视频在线观看| 亚洲免费福利视频| 久久青青草原一区二区| 在线视频一区二区| 激情五月***国产精品| 欧美揉bbbbb揉bbbbb| 久久久午夜视频| 亚洲一区二区三区精品在线| 亚洲高清在线播放| 久久九九国产| 亚洲欧美国产制服动漫| 亚洲国产欧美一区二区三区丁香婷| 欧美日韩精品福利| 可以看av的网站久久看| 亚洲欧美国产精品桃花| 亚洲日本中文| 欧美成人免费播放| 欧美在线一二三四区| 一区二区三区久久精品| 亚洲国产成人av在线| 国产视频久久久久| 国产精品videosex极品| 欧美精品午夜视频| 欧美激情va永久在线播放|