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

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年5月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

導航

統計

常用鏈接

留言簿(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>
            国产精品麻豆欧美日韩ww| 亚洲免费观看高清完整版在线观看熊 | 欧美r片在线| 嫩模写真一区二区三区三州| 欧美在线免费观看视频| 老司机午夜精品视频在线观看| 欧美精品少妇一区二区三区| 欧美视频在线看| 在线观看欧美黄色| 亚洲欧美日韩国产成人精品影院| 在线精品视频免费观看 | 欧美日韩一区二区三区| 国内精品久久久久影院色| 亚洲人成艺术| 久久国产精彩视频| 亚洲国产成人精品女人久久久| 亚洲福利国产| 欧美一区二区女人| 亚洲精品国产系列| 欧美专区中文字幕| 亚洲精品美女在线观看播放| 久久激情五月丁香伊人| 日韩亚洲国产欧美| 国产无遮挡一区二区三区毛片日本| 亚洲另类视频| 噜噜噜躁狠狠躁狠狠精品视频 | 欧美高清成人| 性伦欧美刺激片在线观看| 欧美日产国产成人免费图片| 亚洲福利视频一区| 亚洲特级毛片| 欧美激情一区二区三区在线| 亚洲欧美www| 免费av成人在线| 一区二区在线观看av| 久久久欧美一区二区| 亚洲视频在线播放| 亚洲电影有码| 亚洲欧美精品在线| 国产亚洲一区二区在线观看| 久久精品理论片| 欧美日韩国产综合视频在线观看 | 欧美在线看片| 欧美日韩一级黄| 亚洲国产精品一区| 欧美精品一区二区三区在线看午夜| 亚洲日本va午夜在线电影| 亚洲欧美乱综合| 亚洲视频视频在线| 制服丝袜激情欧洲亚洲| 国产精品国产一区二区| 亚洲欧美影院| 久久久久久黄| 91久久国产综合久久蜜月精品 | 亚洲国产欧美一区二区三区久久| 国产精品永久入口久久久| 香蕉久久夜色精品| 欧美综合国产精品久久丁香| 午夜一区在线| 国产精品久久久久久一区二区三区| 亚洲国产精品一区二区www| 在线观看一区欧美| 久久久亚洲精品一区二区三区| 欧美专区中文字幕| 国产精品亚洲精品| 欧美韩国一区| 欧美福利精品| 欧美在线不卡| 国产亚洲一区在线播放| 午夜在线一区二区| 久久久噜噜噜久久中文字免| 国产视频一区二区在线观看 | 久久精品99国产精品| 一本色道久久加勒比88综合| 在线一区免费观看| 亚洲欧美怡红院| 国产欧美午夜| 亚洲人妖在线| 亚洲特级毛片| 国产欧美日韩视频一区二区| 欧美在线观看www| 免费亚洲一区| 国产欧美精品一区二区色综合 | 亚洲男女自偷自拍| 久久人人爽人人爽爽久久| 国内揄拍国内精品久久| 一本色道久久综合亚洲精品高清| 一区在线影院| 欧美国产大片| 亚洲午夜女主播在线直播| 久久av一区二区| 亚洲国产婷婷香蕉久久久久久| 亚洲专区欧美专区| 久久久久久久一区| 国产精品一区=区| 欧美中文字幕在线观看| 亚洲第一在线| 午夜精品久久久久久久99樱桃| 国内成人精品2018免费看| 麻豆精品在线观看| 亚洲视频一区二区免费在线观看| 久久成人综合网| 亚洲精品在线免费| 国产午夜精品久久久久久免费视| 可以看av的网站久久看| 中国成人在线视频| 欧美va天堂在线| 亚洲欧美视频在线观看| 伊人成人开心激情综合网| 欧美日产一区二区三区在线观看| 性欧美办公室18xxxxhd| 亚洲精品美女免费| 久久婷婷久久| 激情婷婷亚洲| 国产精品高清一区二区三区| 久久久亚洲国产美女国产盗摄| 亚洲最新视频在线| 亚洲免费在线精品一区| 亚洲国内自拍| 国产一区二区高清视频| 欧美日韩视频在线| 你懂的国产精品| 亚洲精品日产精品乱码不卡| av成人动漫| 亚洲国产精品va在线看黑人| 国产欧美va欧美不卡在线| 欧美日韩精品一区视频| 蜜桃伊人久久| 久久精品视频播放| 亚洲欧洲另类国产综合| 亚洲无毛电影| 国产日产欧美一区| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ入口 | 亚洲欧美一区在线| 在线一区二区三区四区五区| 国产精品高潮呻吟| 欧美人与禽性xxxxx杂性| 免费日韩精品中文字幕视频在线| 欧美在线免费| 欧美一区1区三区3区公司| 欧美va亚洲va国产综合| 美腿丝袜亚洲色图| 能在线观看的日韩av| 欧美成人精品在线观看| 久久亚洲欧美| 免费一区二区三区| 免费日韩av电影| 亚洲高清电影| 亚洲美女一区| 一区二区国产日产| 亚洲一二三区精品| 亚洲免费影视| 久久久久国产精品厨房| 嫩模写真一区二区三区三州| 欧美xart系列高清| 性欧美长视频| 久久久精品国产免大香伊 | 亚洲裸体俱乐部裸体舞表演av| 欧美激情国产精品| 亚洲狠狠丁香婷婷综合久久久| 亚洲国产经典视频| 亚洲视频免费在线| 欧美一级黄色网| 麻豆av一区二区三区| 欧美日本国产一区| 国产精品视频免费| 精品av久久707| 亚洲久久一区| 香蕉久久夜色精品国产使用方法| 久久久久久久久久久久久久一区| 男人的天堂亚洲| 亚洲美洲欧洲综合国产一区| 亚洲午夜电影网| 欧美影院午夜播放| 欧美国产日韩一区二区三区| 欧美午夜片在线免费观看| 欧美福利视频一区| 欧美色大人视频| 狠狠色丁香久久综合频道| 亚洲精品国产欧美| 香蕉久久久久久久av网站| 农夫在线精品视频免费观看| 9i看片成人免费高清| 久久国产黑丝| 欧美日韩中文字幕综合视频| 国内精品国产成人| 亚洲视频在线二区| 欧美.日韩.国产.一区.二区| 99精品国产99久久久久久福利| 香蕉久久夜色精品国产使用方法| 欧美a级片网| 激情久久久久| 欧美影院午夜播放| 日韩午夜电影av| 久久野战av| 欧美成人在线网站| 国产在线视频欧美| 亚洲在线免费| 久久疯狂做爰流白浆xx| 亚洲免费av网站|