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

Ural 1008 Image encoding


1008. Image encoding

Time Limit: 2.0 second
Memory Limit: 16 MB
Problem illustration
There are several ways to encode an image. In this problem we will consider two representations of an image. We assume that the image consists of black and white pixels. There is at least one black pixel and all black pixels are connected with their sides. Coordinates of black pixels are not less than 1 and not greater than 10. An example of such an image is at the figure.
Both representations describe arrangement of black pixels only.
At the first representation we specify in the first line number of black pixels and coordinates of each black pixel in the following lines. Pixels are listed in order of increasing X. In case of equality of X they are listed in order of increasing Y. Image at the figure is encoded as follows:
6
2 3
2 4
3 3
3 4
4 2
4 3
At the second representation we specify in the first line coordinates of the lowest left black pixel. Each of the following lines contains a description of neighbors for one of the pixels. At first, neighbors of the lowest left pixel are specified, then neighbors of its first neighbor (if it exists) are specified, then neighbors of its second neighbor (if it also exists) follow. When all its neighbors are described the description of the neighbors of its first neighbor follows. The description of the neighbors of its second neighbor follows then and so on.
Each descriptive line contains at most one letter for each neighbor: R for the right, T for the top, L for the left, B for the bottom. If the neighbor was already specified it is not included into the descriptive line and vice-versa. Also there is only one descriptive line for each pixel. Neighbors are listed counter-clockwise starting with the right. Each descriptive line except the last ends with a comma. The last line ends with a full stop. Image at the figure is encoded as follows:
2 3
RT,
RT,
,
B,
,
.
There are no leading or tailing spaces in any representation. There is exactly one space between X and Y coordinates.

Input

One representation of the image will be given to your program in the input.

Output

Your program has to write other representation of the image to the output.

Sample

input output
6
            2 3
            2 4
            3 3
            3 4
            4 2
            4 3
            
2 3
            RT,
            RT,
            ,
            B,
            ,
            .
            
Problem Source: Third Open USTU Collegiate Programming Contest (PhysTech Cup), March 18, 2000

這題花了不少時間,題目沒看清,只看示例以為只要從第一種方案轉換成第二種,沒想到還有從第二種轉換成第一種
BFS:
Accepted     
0.015        217 KB

#include<iostream>
#include
<queue>
#include
<string.h>
#include
<string>
using  namespace std;

typedef 
struct point
{
int x,y; } point;

bool graph[12][12]={0};
bool f[12][12]={0};
bool print[12][12]={0};

int n;
int lbx=10,lby=10;
              
void input()
{
     
int x,y;
     
for(int i=1; i<=n; i++)
         {
              cin
>>x>>y; graph[x][y]=1;
              
if(x<lbx){ lbx=x; lby=y; }
              
else if(x==lbx&&y<lby)
                    lby
=y;
         }
}

void BFS1()    //數字情況 
{
     queue
<point> q;
     point temp; temp.x
=lbx; temp.y=lby;
     cout
<<lbx<<' '<<lby<<endl;
     q.push(temp);
     
int x,y; int cnt=0;
     print[lbx][lby]
=1;
     
while(q.size())
     {
              temp
=q.front(); q.pop();
              x
=temp.x; y=temp.y;
              
if(f[x][y]==1)continue;
              f[x][y]
=1;
              
if(graph[x+1][y]==1&&!f[x+1][y])
{
if(!print[x+1][y]) cout<<'R'; print[x+1][y]=1; temp.x=x+1;temp.y=y; q.push(temp);}
              
if(graph[x][y+1]==1&&!f[x][y+1])
{
if(!print[x][y+1]) cout<<'T'; print[x][y+1]=1; temp.x=x;temp.y=y+1; q.push(temp);}
              
if(graph[x-1][y]==1&&!f[x-1][y])
{
if(!print[x-1][y]) cout<<'L'; print[x-1][y]=1; temp.x=x-1;temp.y=y; q.push(temp);}
              
if(graph[x][y-1]==1&&!f[x][y-1])
{
if(!print[x][y-1]) cout<<'B'; print[x][y-1]=1; temp.x=x;temp.y=y-1; q.push(temp);}
              
++cnt;
              
if(cnt==n) cout<<'.'<<endl;
               
else  cout <<','<<endl;
     }
}

void BFS2()  // 從R T L B描述轉換成坐標
{
     lbx
=n; cin>>lby;
     queue
<point>q;
     point temp; temp.x
=lbx; temp.y=lby;
     q.push(temp);
     
string str; int x,y;
     graph[lbx][lby]
=1;
     
while(q.size())
     {
       
        temp
=q.front(); q.pop();
        x
=temp.x; y=temp.y;
        
if(f[x][y])continue;
        f[x][y]
=1;
        cin
>>str;
        
for(int i=0; i<str.size()-1; i++)
        {
                
if(str[i]=='R')     {graph[x+1][y]=1if(!f[x+1][y]){ temp.x=x+1; temp.y=y; q.push(temp);} }
                
else if(str[i]=='T'){graph[x][y+1]=1if(!f[x][y+1]){ temp.x=x; temp.y=y+1; q.push(temp);} }
                
else if(str[i]=='L'){graph[x-1][y]=1if(!f[x-1][y]){ temp.x=x-1; temp.y=y; q.push(temp);} }
                
else if(str[i]=='B'){graph[x][y-1]=1;if(!f[x][y-1]){ temp.x=x; temp.y=y-1; q.push(temp);} }
        }
        
if(str[str.size()-1]=='.')break;
     }
     
int cnt=0;
     
for(int i=1; i<=10; i++)
     
for(int j=1; j<=10; j++)
     
if(graph[i][j])cnt++;
     cout
<<cnt<<endl;
     
for(int i=1; i<=10; i++)
     
for(int j=1; j<=10; j++)
     
if(graph[i][j])cout<<i<<' '<<j<<endl;   
}

int main()
{
    cin
>>n;
    
if(getchar()=='\n')
    {
    input(); 
    BFS1();
    }
    
else BFS2();
    system(
"pause");
    
return 0;
}

posted on 2010-06-26 22:38 田兵 閱讀(373) 評論(0)  編輯 收藏 引用 所屬分類: URAL

<2010年6月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

導航

統計

常用鏈接

留言簿(2)

隨筆分類(65)

隨筆檔案(65)

文章檔案(2)

ACM

搜索

積分與排名

最新隨筆

最新評論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲三级影院| 在线一区二区三区做爰视频网站| 国产欧美日韩视频一区二区三区 | 亚欧成人在线| 久久精品九九| 欧美丰满少妇xxxbbb| 亚洲国产精品第一区二区三区| 亚洲国产精品久久久| 亚洲精品永久免费精品| 亚洲一区成人| 久久亚洲国产精品日日av夜夜| 免费欧美在线| 国产精品剧情在线亚洲| 国产原创一区二区| 亚洲精品一区二区三区99| 在线视频亚洲| 久久婷婷国产综合精品青草| 欧美激情一区二区三区全黄 | 亚洲欧美激情一区| 毛片一区二区三区| 99精品视频免费观看视频| 小嫩嫩精品导航| 欧美精品首页| 国产亚洲网站| 亚洲图片欧美午夜| 欧美成人综合一区| 午夜电影亚洲| 欧美精品一区在线| 一区二区在线免费观看| 亚洲一区二区三区中文字幕| 蜜臀av性久久久久蜜臀aⅴ| 99精品热视频| 欧美激情 亚洲a∨综合| 影视先锋久久| 欧美在线免费观看| 一区二区三区精密机械公司| 欧美第十八页| 亚洲国产精品美女| 久久久久久香蕉网| 亚洲一区二区三区三| 欧美激情一区二区三区蜜桃视频| 国产视频欧美| 校园春色国产精品| 亚洲视频1区| 欧美精品一区二区三区高清aⅴ| 狠狠色丁香久久婷婷综合_中| 亚洲欧美在线另类| 一本一本久久| 欧美日韩在线免费| 99热这里只有精品8| 亚洲第一福利视频| 欧美成人一区二区三区片免费| 亚洲成色777777女色窝| 鲁鲁狠狠狠7777一区二区| 午夜国产精品视频| 国产精品一区二区久久精品| 亚洲在线观看免费| 亚洲在线观看视频网站| 欧美三区美女| 亚洲欧美日韩第一区| 在线一区欧美| 国产精品夜夜夜| 久久成人精品视频| 午夜精品亚洲| 好吊色欧美一区二区三区视频| 久久久亚洲高清| 久久久综合免费视频| 亚洲黄色在线| 日韩亚洲欧美一区| 国产精品午夜电影| 久久久久国色av免费观看性色| 欧美一区二区视频观看视频| 一区二区三区在线视频播放| 欧美电影在线观看完整版| 欧美激情亚洲一区| 午夜久久资源| 久久精品免费| 中文在线不卡视频| 午夜久久久久| 亚洲欧洲视频| 亚洲制服av| 一区二区三区在线不卡| 亚洲欧洲久久| 国产日韩欧美三级| 亚洲二区精品| 国产精品你懂的在线| 久久综合网络一区二区| 欧美喷水视频| 久久精品麻豆| 欧美精品一区二区三区很污很色的 | 欧美中文字幕精品| 91久久国产自产拍夜夜嗨| 夜夜爽www精品| 狠狠狠色丁香婷婷综合久久五月| 亚洲国产精品999| 国产午夜精品一区二区三区视频| 欧美成人午夜视频| 国产精品一二一区| 亚洲精品视频免费在线观看| 国产日本欧美在线观看| 亚洲日本va午夜在线电影| 国产欧美精品| 亚洲精品视频在线| 亚洲第一福利视频| 亚洲制服丝袜在线| 日韩天堂av| 久久久久亚洲综合| 欧美一区二区三区视频在线观看| 欧美激情精品久久久久久免费印度| 欧美一区91| 欧美日韩中文在线| 亚洲国产精品久久精品怡红院| 国产色爱av资源综合区| 在线中文字幕一区| 亚洲最新合集| 欧美国产精品久久| 欧美高清在线视频| 一区二区三区在线视频播放| 欧美一级专区| 篠田优中文在线播放第一区| 欧美午夜视频在线| 日韩视频久久| 日韩午夜中文字幕| 欧美www在线| 亚洲福利视频免费观看| 在线观看日韩一区| 久久久久久婷| 蜜臀av一级做a爰片久久| 国产视频在线观看一区| 亚洲欧美999| 午夜视频久久久久久| 欧美性大战久久久久| 亚洲美女免费视频| 一区二区日韩| 欧美婷婷久久| 亚洲一区欧美激情| 久久精品成人一区二区三区蜜臀 | 欧美大香线蕉线伊人久久国产精品| 久久全国免费视频| 狠狠色狠狠色综合日日五| 久久国产欧美日韩精品| 免费观看久久久4p| 91久久午夜| 欧美日韩一级黄| 在线亚洲伦理| 久久精品一本| 1769国产精品| 欧美精品日韩三级| 亚洲视频第一页| 久久精品在线| 亚洲第一伊人| 欧美日韩国产bt| 亚洲一区在线看| 美女国内精品自产拍在线播放| 亚洲国产精品久久精品怡红院| 欧美精品导航| 香蕉av777xxx色综合一区| 另类天堂视频在线观看| 99国产精品一区| 国产精品一区二区久久久久| 欧美一区二区三区在线视频| 欧美成人福利视频| 亚洲欧美视频在线| 黄色亚洲大片免费在线观看| 欧美成人dvd在线视频| 一本色道久久综合亚洲精品高清 | 欧美不卡三区| 一区二区成人精品| 国产亚洲精品久久飘花| 美日韩在线观看| 亚洲一区二区黄| 亚洲国内自拍| 久久高清国产| 99视频精品免费观看| 国内精品亚洲| 欧美日韩亚洲视频| 久久久久在线| 亚洲一二三级电影| 亚洲电影观看| 久久精品一区二区| 亚洲亚洲精品三区日韩精品在线视频 | 最新亚洲一区| 久久久人成影片一区二区三区| 亚洲精品国产精品国自产观看浪潮| 国产精品免费观看视频| 欧美国产免费| 久久一区二区视频| 香蕉国产精品偷在线观看不卡| 亚洲国产另类精品专区 | 国产一区二区剧情av在线| 欧美日韩国产一区二区| 另类av一区二区| 午夜精品久久久久久久久久久久| 亚洲精品美女在线观看| 欧美不卡视频一区| 久久视频免费观看| 欧美一级专区| 欧美一区二区三区视频免费播放| 一本大道久久a久久综合婷婷| 在线欧美电影|