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

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>
            亚洲在线中文字幕| 久久久亚洲国产美女国产盗摄| 亚洲一区二区三区精品在线观看 | 欧美日韩国产欧| 欧美国产日本韩| 欧美全黄视频| 欧美日韩国产小视频| 欧美大片在线观看| 欧美三级午夜理伦三级中视频| 欧美另类专区| 国产精品男gay被猛男狂揉视频| 国产精品一区二区女厕厕| 国产手机视频精品| 在线精品一区| 亚洲系列中文字幕| 久久久久.com| 亚洲精品国产精品国自产观看| 欧美1区3d| 一级成人国产| 久久久久久国产精品mv| 欧美精品不卡| 韩国精品一区二区三区| 99av国产精品欲麻豆| 久久成人在线| 亚洲区欧美区| 性久久久久久久久| 欧美日韩精品二区| 永久域名在线精品| 亚洲欧美精品在线观看| 免费成人性网站| 亚洲一区二区三区成人在线视频精品| 久久九九热re6这里有精品| 欧美另类高清视频在线| 国内一区二区三区在线视频| 亚洲无玛一区| 欧美国产一区二区| 香蕉免费一区二区三区在线观看| 欧美不卡一卡二卡免费版| 亚洲人www| 久久亚洲精选| 国产欧美一级| 亚洲男人av电影| 亚洲激情欧美激情| 久久久一区二区| 国产一区二区黄色| 欧美亚洲三区| 亚洲午夜电影| 国产精品久久| 亚洲在线黄色| 亚洲少妇在线| 欧美日韩成人一区| 日韩视频在线免费| 欧美成人一区二区三区| 久久精品国产视频| 国内成人精品2018免费看 | 欧美jjzz| 在线观看欧美激情| 久久婷婷激情| 久久九九有精品国产23| 一区二区三区在线观看视频| 久久久一区二区| 久久精品一区二区三区不卡| 国内精品一区二区| 美女脱光内衣内裤视频久久影院 | 久久美女性网| 久久www成人_看片免费不卡| 国产日韩在线亚洲字幕中文| 欧美一区二区三区四区在线| 亚洲一区二区三区在线看| 国产精品久久久一区麻豆最新章节 | 亚洲人成人77777线观看| 欧美va亚洲va香蕉在线| 亚洲国产日韩欧美| 欧美黄在线观看| 欧美精品999| 亚洲一区视频在线| 亚洲欧美日韩中文在线制服| 国产日韩精品视频一区| 老司机成人网| 欧美激情在线观看| 亚洲自拍偷拍视频| 久久精品国产99国产精品澳门| 好看的日韩视频| 欧美电影免费观看大全| 欧美日韩精品免费观看视一区二区| 亚洲一区二区精品在线| 新67194成人永久网站| 在线观看欧美激情| aa国产精品| 久久综合九色欧美综合狠狠| 亚洲国产一区二区三区高清| 亚洲人成人一区二区三区| 国产精品国码视频| 久久亚洲国产精品日日av夜夜| 欧美成va人片在线观看| 亚洲免费一区二区| 久久亚洲综合色一区二区三区| 一区二区三欧美| 久久成人这里只有精品| 一区二区三区免费观看| 久久九九热免费视频| 亚洲婷婷国产精品电影人久久| 午夜精品成人在线视频| 亚洲人成小说网站色在线| 亚洲综合欧美日韩| 亚洲美女中文字幕| 欧美在线视频二区| 亚洲午夜久久久久久尤物| 久久婷婷影院| 午夜视频在线观看一区| 欧美成人日韩| 久久久精品一区二区三区| 欧美午夜视频一区二区| 亚洲高清自拍| 精品1区2区| 亚洲欧美日韩综合国产aⅴ| 一区二区三区 在线观看视频| 久久人体大胆视频| 久久精品国产69国产精品亚洲| 欧美日韩美女在线| 亚洲国产精品va在看黑人| 国产精品一区在线观看| 亚洲精品国久久99热| 亚洲国产另类久久精品| 久久疯狂做爰流白浆xx| 欧美在线视频观看免费网站| 欧美涩涩视频| 日韩一区二区精品葵司在线| 亚洲伦理在线免费看| 美女免费视频一区| 美日韩在线观看| 国内一区二区三区| 久久成人这里只有精品| 久久人人爽人人爽| 国产一区二区在线观看免费播放 | 久久久噜噜噜| 久久天堂av综合合色| 国产综合一区二区| 久久aⅴ国产欧美74aaa| 久久久人成影片一区二区三区观看| 国产日韩精品久久| 欧美在线播放| 久久综合综合久久综合| 影音先锋亚洲电影| 蜜臀va亚洲va欧美va天堂| 亚洲国产精品久久久久| 亚洲精品一区二区三区婷婷月| 欧美成人午夜免费视在线看片| 亚洲动漫精品| 中文日韩在线视频| 国产精品视频免费| 久久激情视频久久| 欧美韩日一区二区| 亚洲免费视频网站| 欧美日韩精品免费看| 亚洲一区网站| 久热精品视频在线| 91久久线看在观草草青青| 欧美经典一区二区三区| 中文精品视频一区二区在线观看| 欧美日韩国产成人精品| 亚洲综合激情| 欧美大片免费观看在线观看网站推荐| 亚洲激情另类| 国产精品福利网| 久久精品免费电影| 亚洲区欧美区| 久久久久在线观看| 亚洲精品老司机| 国产精品夜色7777狼人| 久久久九九九九| 亚洲伦理中文字幕| 久久久久国产精品一区| 亚洲人妖在线| 国产嫩草影院久久久久| 欧美成人精品不卡视频在线观看 | 女人天堂亚洲aⅴ在线观看| 亚洲精品在线二区| 欧美一区免费视频| 亚洲日本成人网| 国产精品综合| 欧美另类69精品久久久久9999| 午夜亚洲福利| 9l视频自拍蝌蚪9l视频成人| 久久综合网络一区二区| 9久re热视频在线精品| 国模精品娜娜一二三区| 欧美亚州一区二区三区| 久久免费偷拍视频| 午夜精品久久久久久久白皮肤| 亚洲黄色av| 国产欧美精品日韩精品| 欧美激情精品久久久久久黑人 | 亚洲一区影音先锋| 宅男在线国产精品| 久久手机精品视频| 国产精品久久影院| 91久久中文| 亚洲蜜桃精久久久久久久| 久久久久久久高潮|