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

ArcTan

dfs
隨筆 - 16, 文章 - 117, 評論 - 6, 引用 - 0
數據加載中……

SRM 500 DIV2 500PT(模擬)

Problem Statement

     NOTE: This problem statement contains images that may not display properly if viewed outside of the applet.

We had a rectangular grid that consisted of W x H square cells. We placed a robot on one of the cells. The robot then followed the rules given below.
  • Initially, the robot is facing east.
  • The robot moves in steps. In each step it moves to the adjacent cell in the direction it currently faces.
  • The robot may not leave the grid.
  • The robot may not visit the same cell twice. (This also means that it may not reenter the starting cell.)
  • If a step forward does not cause the robot to break the above rules, the robot takes the step.
  • Otherwise, the robot rotates 90 degrees to the left (counter-clockwise) and checks whether a step forward still breaks the above rules. If not, the robot takes the step and continues executing this program (still rotated in the new direction).
  • If the rotation left did not help, the robot terminates the execution of this program.
  • We can also terminate the execution of the program manually, at any moment.
For example, the following seven images show a series of moves made by the robot in a 12 x 11 board:



We forgot the dimensions of the grid and the original (x,y) coordinates of the cell on which the robot was originally placed, but we do remember its movement. You are given a vector <int> moves. This sequence of positive integers shall be interpreted as follows: The robot performed moves[0] steps eastwards, turned left, performed moves[1] steps northwards, turned left, and so on. After performing the last sequence of steps, the robot stopped. (Either it detected that it should terminate, or we stopped it manually.) We are not sure if the sequence of moves is valid. If the sequence of moves is impossible, return -1. Else, return the minimum area of a grid in which the sequence of moves is possible. (I.e., the return value is the smallest possible value of the product of W and H.).

Definition

    
Class: RotatingBot
Method: minArea
Parameters: vector <int>
Returns: int
Method signature: int minArea(vector <int> moves)
(be sure your method is public)
    

Constraints

- moves will contain between 1 and 50 elements, inclusive.
- Each element of moves will be between 1 and 50, inclusive.

Examples

0)
    
{15}
Returns: 16
The smallest valid board is a 16x1 board, with the robot starting on the west end of the board.
1)
    
{3,10}
Returns: 44
The smallest solution is to place the robot into the southwest corner of a 4 x 11 board.
2)
    
{1,1,1,1}
Returns: -1
This sequence of moves is not possible because the robot would return to its initial location which is forbidden.
3)
    
{9,5,11,10,11,4,10}
Returns: 132
These moves match the image from the problem statement.
4)
    
{12,1,27,14,27,12,26,11,25,10,24,9,23,8,22,7,21,6,20,5,19,4,18,3,17,2,16,1,15}
Returns: 420

5)
    
{8,6,6,1}
Returns: -1

6)
    
{8,6,6}
Returns: 63

7)
    
{5,4,5,3,3}
Returns: 30

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.



模擬題目,直接按照給定序列遍歷,如果遇到不合法的情況return -1。設定四個方向,mw,me,mn,ms,東北西南,初始為上下界。然后依次找到范圍。
初始點(100,100)。
最后的面積為(me-mw+1)*(ms-mn+1)

沒有考慮完全啊,思維還是不嚴謹不完整,就WA了一組數據,昨晚做就悲劇了!!!!
我是弱菜,繼續努力!

不錯的模擬題目,需要考慮的東西很多!
#include <cstdio>
#include 
<cstdlib>
#include 
<cstring>
#include 
<cmath>
#include 
<ctime>
#include 
<cassert>
#include 
<iostream>
#include 
<sstream>
#include 
<fstream>
#include 
<map>
#include 
<set>
#include 
<vector>
#include 
<queue>
#include 
<algorithm>
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define swap(t,x,y) (t=x,x=y,y=t)
#define clr(list) memset(list,0,sizeof(list))

using namespace std;
bool maps[205][205];
int go[4][2]={{1,0},{0,-1},{-1,0},{0,1}};
class RotatingBot{
public:
    
int minArea(vector <int> moves){
        
int n=moves.size();
        
int me=1000,mw=0,mn=0,ms=1000;
        
int tmp;
        
int dir;
        
int x,y,xx,yy;
        clr(maps);
        maps[
100][100]=1;
        x
=100,y=100,dir=0;
        
for (int i=0;i<n ;i++)
        {
            tmp
=moves[i];
            
for (int j=0;j<tmp;j++)
            {
                xx
=x+go[dir][0];yy=y+go[dir][1];
                
if (maps[xx][yy] || (xx<mw || xx>me || yy<mn || yy>ms))
                    
return -1;
                
else
                {
                    maps[xx][yy]
=1;
                    x
=xx;y=yy;
                }
            }
            xx
=x+go[dir][0];yy=y+go[dir][1];
            
if (!maps[xx][yy])
            {
                
if (dir==0)
                    
if (me==1000)
                        me
=x;
                    
else
                        
if (x<me && i<n-1)
                            
return -1;
                
if (dir==1)
                    
if (mn==0)
                        mn
=y;
                    
else if (y>mn && i<n-1)
                        
return -1;
                
if (dir==2)       //這里WA了testing 5 & 6
                    
if (mw==0 && x<=100)
                        mw
=x;
                    
else
                        
if (x>mw && i<n-1)
                            
return -1;
                
if (dir==3)            //最后栽在這里了
                    
if (ms==1000 && y>=100)  
                        ms
=y;
                    
else if ((y<ms || y<100&& i<n-1)
                        
return -1;
            }
            dir
=(dir+1% 4;
        }
     
//   return mw;
        if (mw==0)
            mw
=100;
        
if (mn==0)
            mn
=100;
        
if (ms==1000)
            ms
=100;
        
return (me-mw+1)*(ms-mn+1);
    }
};

posted on 2012-07-22 10:10 wangs 閱讀(232) 評論(0)  編輯 收藏 引用 所屬分類: Topcoder

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产一区二区三区日韩| 亚洲欧美国产一区二区三区| 午夜电影亚洲| av成人免费在线| 蜜桃伊人久久| 久久亚洲图片| 国产亚洲精品久久久| 国产精品99久久久久久久女警| 亚洲精选一区| 欧美黄色视屏| 亚洲国产1区| 国模私拍视频一区| 欧美一区二区啪啪| 久久国产精品一区二区三区四区 | 国产精品蜜臀在线观看| 日韩一区二区精品视频| 日韩午夜在线电影| 欧美激情综合色综合啪啪| 91久久久久久| 一区二区三区免费在线观看| 欧美成人按摩| 亚洲国产影院| 在线视频一区观看| 欧美日韩一区自拍| 亚洲夜晚福利在线观看| 亚洲综合激情| 国产日韩精品入口| 欧美在线免费视频| 欧美xart系列高清| 亚洲伦理网站| 国产精品www色诱视频| 亚洲欧美日韩爽爽影院| 久久精品最新地址| 在线精品亚洲一区二区| 欧美成人网在线| 亚洲色图综合久久| 久久久国产91| 亚洲三级免费电影| 欧美日韩国产精品| 午夜精品久久久久| 亚洲第一精品福利| 亚洲视频日本| 国产中文一区| 欧美激情视频一区二区三区在线播放| 亚洲老板91色精品久久| 欧美一区午夜精品| 红桃视频国产精品| 欧美激情按摩| 午夜国产欧美理论在线播放| 欧美77777| 亚洲欧美精品在线观看| 在线成人免费观看| 欧美特黄视频| 久久久久在线观看| 一区二区三区欧美成人| 老司机精品视频网站| 亚洲一区二区精品在线观看| 狠狠色狠狠色综合日日小说| 欧美精品久久99久久在免费线| 亚洲欧美日韩综合| 亚洲精美视频| 久久综合亚州| 香港成人在线视频| 亚洲精品视频免费观看| 国产一区二区三区不卡在线观看| 欧美激情精品久久久久久久变态| 午夜精品在线观看| 亚洲理伦电影| 欧美激情久久久久久| 午夜日韩视频| 一区二区三区四区精品| 亚洲国产欧美不卡在线观看| 国产色综合网| 国产精品国产三级国产普通话三级| 老色鬼精品视频在线观看播放| 中文日韩在线| 日韩一区二区免费高清| 欧美成人中文字幕| 久久久久久久久久久一区| 亚洲视频精选| 99re8这里有精品热视频免费| 国产一区二区三区久久精品| 国产精品久久91| 欧美日韩麻豆| 欧美精品在线播放| 欧美bbbxxxxx| 老司机精品导航| 久久久蜜桃一区二区人| 欧美一区二区免费视频| 午夜久久tv| 亚洲欧美综合v| 亚洲在线中文字幕| 亚洲精品一区二区三| 亚洲国产成人av好男人在线观看| 免费看黄裸体一级大秀欧美| 久久伊人精品天天| 久久青草欧美一区二区三区| 久久激情五月婷婷| 久久岛国电影| 久久国产精品久久久| 久久av红桃一区二区小说| 午夜精品久久久久久久蜜桃app| 亚洲女女女同性video| 亚洲综合精品自拍| 小黄鸭精品密入口导航| 欧美一区三区二区在线观看| 欧美一区二区三区在| 欧美一区二区三区免费视频| 欧美一区二区啪啪| 久久精品人人爽| 鲁鲁狠狠狠7777一区二区| 欧美aa国产视频| 亚洲国产日本| 制服诱惑一区二区| 亚洲免费在线| 久久久噜噜噜久久中文字免| 快射av在线播放一区| 欧美成人中文字幕在线| 欧美精品一区二区精品网| 欧美日韩国产一中文字不卡| 国产精品二区影院| 国产一区二区| 亚洲精品乱码久久久久久| 亚洲天堂av图片| 午夜精品偷拍| 免费短视频成人日韩| 亚洲日本久久| 欧美亚洲视频在线看网址| 久久久免费av| 欧美日韩午夜激情| 国产亚洲欧美另类中文| 亚洲精品国产精品乱码不99按摩| 狠狠色综合网站久久久久久久| 一区二区三区精品| 麻豆av一区二区三区| 亚洲激情欧美| 午夜亚洲一区| 欧美破处大片在线视频| 国产精品在线看| 亚洲国产高清aⅴ视频| 一区二区三区国产在线观看| 久久av资源网| 亚洲精品免费一二三区| 亚洲欧美综合精品久久成人| 欧美a级理论片| 国产深夜精品| 亚洲午夜一二三区视频| 美女精品国产| 亚洲欧美成人在线| 欧美理论电影网| 一区二区三区在线观看欧美| 亚洲系列中文字幕| 欧美电影在线观看| 欧美一级久久| 国产精品美女久久久久久久| 亚洲国产小视频| 久久久噜噜噜久久人人看| 一区二区三区欧美日韩| 欧美成人自拍视频| 1769国内精品视频在线播放| 午夜天堂精品久久久久| 亚洲人成网站精品片在线观看| 久久九九全国免费精品观看| 国产精品人人做人人爽人人添| 亚洲美女电影在线| 久久免费国产精品1| 亚洲深夜福利| 欧美三级小说| 99热这里只有精品8| 欧美二区乱c少妇| 久久九九国产精品怡红院| 国产欧美精品日韩精品| 亚洲一区二区精品在线| 亚洲韩国日本中文字幕| 久久久www成人免费无遮挡大片| 国产精品视频导航| 亚洲影院一区| 一区二区三区 在线观看视| 欧美jjzz| 91久久久久久| 亚洲国产精品999| 欧美成人一区二区三区片免费| 亚洲二区精品| 国产精品女主播| 日韩视频中文| 日韩视频―中文字幕| 欧美日本韩国| 亚洲一区二区三区四区视频| 99精品久久久| 欧美性片在线观看| 亚洲天堂成人在线观看| 一本久久综合亚洲鲁鲁五月天| 欧美精品在欧美一区二区少妇| 99这里只有久久精品视频| 亚洲美女视频在线免费观看| 欧美日韩精品综合在线| 亚洲自拍偷拍视频| 欧美一区成人| 在线观看精品视频| 亚洲激情婷婷|