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

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

這題花了不少時(shí)間,題目沒看清,只看示例以為只要從第一種方案轉(zhuǎn)換成第二種,沒想到還有從第二種轉(zhuǎn)換成第一種
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()    //數(shù)字情況 
{
     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描述轉(zhuǎn)換成坐標(biāo)
{
     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 田兵 閱讀(366) 評(píng)論(0)  編輯 收藏 引用 所屬分類: URAL

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

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

留言簿(2)

隨筆分類(65)

隨筆檔案(65)

文章檔案(2)

ACM

搜索

積分與排名

最新隨筆

最新評(píng)論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            久久精品电影| 99国内精品| 六十路精品视频| 久久久久久网站| 久久精品官网| 久久亚洲国产精品一区二区| 久久精品成人| 欧美r片在线| 欧美精品二区| 国产精品免费久久久久久| 欧美视频在线一区二区三区| 欧美韩国一区| 欧美日韩日日骚| 国产精品一区2区| 国产一级一区二区| 亚洲丰满少妇videoshd| 亚洲精品欧美日韩专区| 中文在线不卡| 欧美在线日韩在线| 欧美mv日韩mv国产网站| 亚洲精品123区| aa级大片欧美| 久久久国产精彩视频美女艺术照福利 | 欧美经典一区二区三区| 亚洲电影免费在线| 亚洲人体大胆视频| 亚洲欧美电影院| 美女诱惑一区| 一区二区欧美日韩| 久久亚洲精品网站| 欧美午夜剧场| 亚洲二区视频在线| 欧美一区国产在线| 欧美成人午夜77777| 亚洲中午字幕| 欧美日韩国产首页在线观看| 国内自拍一区| 亚洲欧美制服中文字幕| 久久综合色影院| 亚洲手机视频| 欧美理论电影在线观看| 在线电影国产精品| 亚洲欧美成人综合| 亚洲三级网站| 久久精品视频免费| 国产伦精品一区二区三区四区免费| 一区二区三区亚洲| 欧美一区2区视频在线观看| 麻豆精品视频在线观看| 一本大道久久a久久综合婷婷| 欧美成人亚洲成人| 亚洲欧美资源在线| 欧美视频精品一区| 亚洲精品一二三| 久久精品国产亚洲aⅴ| 欧美大片va欧美在线播放| 亚洲欧美国产另类| 欧美日韩一区二区三| 欧美一区二区播放| 在线视频亚洲| 欧美日韩精品综合在线| 永久555www成人免费| 午夜精品视频在线观看| 亚洲精品美女久久久久| 久久综合国产精品| 国产自产高清不卡| 亚洲风情在线资源站| 亚洲国产欧洲综合997久久| 久久久久国产精品麻豆ai换脸| 国产精品女主播| 亚洲综合日韩在线| 久久综合网hezyo| 欧美一区二区黄| 国产精品美女久久久久aⅴ国产馆| 日韩视频一区二区三区| 欧美黑人在线观看| 欧美fxxxxxx另类| 一区二区三区在线免费播放| 亚洲欧美国产制服动漫| 欧美日韩在线观看一区二区| 亚洲免费在线精品一区| 一区二区日本视频| 一区二区亚洲欧洲国产日韩| 久久久久久久久久看片| 亚洲色无码播放| 亚洲欧洲一区二区三区在线观看| 久久亚洲国产精品日日av夜夜| 黄色一区二区在线| 欧美国产第二页| 欧美人成在线| 亚洲欧美一区二区原创| 亚洲欧美成人一区二区三区| 欧美视频中文字幕| 亚洲一区3d动漫同人无遮挡| 欧美电影免费观看大全| 好看不卡的中文字幕| 久久国产一区二区| 久久国产99| 亚洲国产视频一区二区| 亚洲国产女人aaa毛片在线| 欧美高清在线视频观看不卡| 99国产一区| 亚洲综合精品四区| 国产精品综合视频| 中文亚洲字幕| 裸体丰满少妇做受久久99精品| 亚洲片在线观看| 一级成人国产| 国产一区二区三区在线观看精品| 久久亚洲免费| 欧美另类久久久品 | 国产一区三区三区| 欧美99在线视频观看| 欧美成人精品在线视频| 亚洲视频欧美视频| 久久精品国产亚洲5555| 日韩视频一区二区三区| 欧美成人视屏| 免费欧美日韩| 香蕉国产精品偷在线观看不卡| 久久久91精品国产一区二区三区 | 欲色影视综合吧| 亚洲毛片在线看| 国产亚洲激情在线| 亚洲欧洲一区| 国产一区二区黄色| 亚洲人线精品午夜| 国产一区二区精品| 亚洲精品裸体| 亚洲国产精品一区二区尤物区| 一区二区三区视频在线播放| 国产在线精品二区| aa级大片欧美| 亚洲毛片在线看| 久久国产欧美日韩精品| 红桃av永久久久| 一区二区三区四区国产| 男女精品网站| 麻豆久久精品| 国产日韩高清一区二区三区在线| 亚洲国产精品第一区二区| 狠狠入ady亚洲精品| 亚洲欧美国产制服动漫| 亚洲视频综合| 欧美日韩一区二区免费视频| 欧美在线观看视频| 久热精品视频在线免费观看 | 美女精品网站| 久久九九精品99国产精品| 欧美日韩一区二区在线| 亚洲高清不卡在线观看| 国产精品国码视频| 午夜精品久久久久久久久久久久久 | av成人福利| 欧美成人dvd在线视频| 你懂的国产精品| 国产精品99免费看 | 国产精品久久午夜夜伦鲁鲁| 亚洲国产清纯| 99视频一区二区| 欧美精品久久久久久久| 亚洲国产专区校园欧美| 欧美亚洲视频| 午夜精品国产更新| 国产乱码精品1区2区3区| 亚洲欧美制服另类日韩| 欧美一区二区三区婷婷月色| 国产精品自拍三区| 欧美一区午夜视频在线观看| 久久久久久久久一区二区| 国产亚洲制服色| 欧美在线综合| 亚洲国产高清一区| 亚洲永久免费视频| 国产亚洲欧美在线| 久久字幕精品一区| 亚洲黄色av一区| 亚洲一线二线三线久久久| 国产欧美日韩视频在线观看| 久久精品123| 亚洲精品一区二区三区福利| 亚洲综合电影| 欧美日韩四区| 蜜桃av久久久亚洲精品| 夜夜爽av福利精品导航| 久久久久在线| 中国日韩欧美久久久久久久久| 国产精品久在线观看| 欧美伊人久久| 亚洲精品1区2区| 午夜久久久久| 亚洲国内欧美| 国产伦精品一区二区三| 蜜臀91精品一区二区三区| 亚洲天堂成人在线观看| 免费成人在线观看视频| 亚洲一区三区电影在线观看| 在线观看国产欧美| 国产精品美女午夜av| 欧美aaaaaaaa牛牛影院|