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

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 田兵 閱讀(364) 評論(0)  編輯 收藏 引用 所屬分類: URAL

<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

導航

統計

常用鏈接

留言簿(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>
            亚洲欧美日韩久久精品| 午夜久久tv| 9色国产精品| 美女爽到呻吟久久久久| 国产欧美日韩一区二区三区在线观看 | 狂野欧美性猛交xxxx巴西| 正在播放亚洲| 欧美视频国产精品| 亚洲视频在线观看一区| 亚洲精品欧洲精品| 欧美精品18| 9色精品在线| 99国产精品国产精品久久| 欧美激情视频一区二区三区免费 | 久久综合精品一区| 久久免费观看视频| 亚洲国产91精品在线观看| 久久天天狠狠| 久久精品成人一区二区三区 | 久久先锋资源| 久久久777| 91久久国产综合久久蜜月精品| 欧美成人有码| 欧美国产一区二区在线观看| 亚洲精品国精品久久99热一| 亚洲第一综合天堂另类专| 欧美主播一区二区三区美女 久久精品人 | 99国产精品私拍| 亚洲午夜一级| 亚洲性视频h| 狠狠色狠狠色综合日日小说| 美女成人午夜| 欧美高潮视频| 亚洲一区二区三区视频| 亚洲欧美中文在线视频| 永久免费精品影视网站| 亚洲黄一区二区| 欧美三级电影一区| 欧美中文在线字幕| 卡通动漫国产精品| 亚洲视频欧美视频| 欧美亚洲综合在线| 亚洲精品少妇| 亚洲自拍偷拍福利| 亚洲狠狠丁香婷婷综合久久久| 日韩一级精品视频在线观看| 国产欧美在线观看| 欧美黄色一区| 国产女人精品视频| 亚洲国产一区二区三区青草影视 | 国产欧美视频一区二区| 亚洲二区视频在线| 国产欧美日韩视频| 一区二区三区视频免费在线观看| 亚洲午夜一区| 亚洲激情欧美激情| 亚洲欧美日韩直播| 亚洲精品色图| 久久亚洲精品视频| 久久se精品一区精品二区| 欧美14一18处毛片| 欧美专区亚洲专区| 欧美午夜精品久久久| 欧美国产丝袜视频| 国产一区二区三区网站| 一本在线高清不卡dvd | 久久久久国产成人精品亚洲午夜| 欧美成人一区二区| 久久人人九九| 国产精品福利网站| 亚洲欧洲精品一区二区| 1769国内精品视频在线播放| 亚洲资源在线观看| 亚洲字幕在线观看| 欧美美女视频| 亚洲国产一区在线| 亚洲国产精品成人精品| 久久国产欧美日韩精品| 欧美一区二区三区啪啪| 欧美日韩在线综合| 亚洲区第一页| 亚洲精品小视频在线观看| 久久激情视频久久| 久久久久久婷| 国产视频一区在线| 欧美一区二区女人| 久久久夜精品| 精品二区视频| 久久青草欧美一区二区三区| 久久精品亚洲乱码伦伦中文| 国产农村妇女毛片精品久久莱园子 | 亚洲美女啪啪| av不卡在线| 欧美日韩国产精品| 99精品国产福利在线观看免费| 一本色道久久综合狠狠躁篇怎么玩| 欧美凹凸一区二区三区视频| 亚洲国产婷婷| 亚洲在线免费| 国产欧美日韩不卡免费| 欧美一区二区免费| 男女精品网站| 亚洲精品男同| 欧美日韩日本国产亚洲在线| 99精品99| 久久久久久久久久码影片| 一区二区三区在线视频免费观看| 久久免费99精品久久久久久| 亚洲国产日韩欧美在线动漫| 亚洲精品一区二区三区樱花| 欧美日韩亚洲一区| 亚洲午夜视频在线| 久久婷婷色综合| 亚洲精品一区二区三区婷婷月| 欧美午夜精品| 久久久久久久久一区二区| 亚洲二区在线观看| 亚洲欧美日产图| 国产综合香蕉五月婷在线| 欧美激情1区2区| 中国日韩欧美久久久久久久久| 国产精品久久77777| 欧美一区二区三区免费观看| 欧美h视频在线| 一区二区三区视频观看| 国产亚洲激情视频在线| 欧美成人高清| 午夜精品999| 亚洲国产免费看| 欧美自拍丝袜亚洲| 亚洲精品国久久99热| 国产伦精品一区二区三区高清版| 快she精品国产999| 亚洲午夜精品一区二区三区他趣 | 在线视频日韩精品| 久久婷婷人人澡人人喊人人爽| 99xxxx成人网| 狠狠色2019综合网| 国产精品美女久久久免费| 久久亚洲影音av资源网| 在线综合亚洲| 亚洲黄色一区| 久热精品在线视频| 午夜亚洲一区| av成人激情| 亚洲国产三级网| 国产亚洲网站| 国产精品高潮视频| 牛人盗摄一区二区三区视频| 亚洲欧美区自拍先锋| 亚洲精品久久久久久下一站| 亚洲视频国产视频| 亚洲全部视频| 影音国产精品| 国产一区二区三区电影在线观看| 欧美片在线观看| 欧美不卡视频一区发布| 久久久免费观看视频| 亚洲欧美另类在线| 亚洲一区二区在线| 一区二区三区欧美日韩| 最新高清无码专区| 欧美成人精品影院| 免费人成精品欧美精品| 久久午夜精品一区二区| 久久久精彩视频| 欧美诱惑福利视频| 亚洲欧洲av一区二区三区久久| 91久久综合亚洲鲁鲁五月天| 小处雏高清一区二区三区| 日韩一区二区精品在线观看| 亚洲国内精品在线| 亚洲激情另类| 亚洲精品在线一区二区| 亚洲欧洲精品一区二区三区波多野1战4| 国产视频观看一区| 国产亚洲综合精品| 国产一区二区三区日韩欧美| 国产精品一区二区久久久久| 国产精品高潮呻吟久久av黑人| 国产精品国产亚洲精品看不卡15| 欧美日韩在线视频一区| 国产精品国产三级国产普通话99| 欧美日韩专区| 欧美性大战久久久久久久蜜臀| 欧美午夜性色大片在线观看| 欧美视频在线视频| 国产精品乱码妇女bbbb| 国产精品高清网站| 国产精品一区久久| 韩日成人av| 亚洲人成网站色ww在线| 99精品国产99久久久久久福利| 国产精品99久久久久久久vr | 亚洲精品四区| 99热精品在线| 亚洲欧美日韩一区二区三区在线观看 | 亚洲精品视频在线观看免费| 亚洲视频在线观看免费| 欧美一二三区在线观看|