Problem A: Pac-Man

Problem A: Pac-Man

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 1048576K,其他语言2097152K
Special Judge, 64bit IO Format: %lld

题目描述 

Problem Description

Pac-Man is a maze-chase video game developed in 1980s. The player controls the character “Pac-Man” to eat dots in a maze while avoiding enemy characters “ghosts.” All characters may move in four directions: up, down, left, right. The game ends when one of the following two conditions is met: 

1.Pac-Man eats all dots in the maze. In this case, the player wins. 

2.A ghost catches Pac-Man. In this case, the player loses. 

                           

                Figure 1: Pac-Man gameplay (image from Wikipedia) 

 Adam is learning how to create games with modern programming tools. To practice the skills,he tries to reproduce the Pac-Man game with some modification. In Adam’s game, the playable character is a “ghost,” and the enemy character is “Pac-Man.” Since he changes the roles of the ghost and Pac-Man, he also changes the ending conditions of the game: 

1.Pac-Man eats all dots in the maze. In this case, the player loses. 

2.The ghost controlled by the player catches Pac-Man. In this case, the player wins. 


  Adam has almost developed the first full functioning version of his game. He wants to test his game and creates a simple stage for testing. The maze of the stage is based on a 10-by-10 grid. We label the cell at the intersection of row r and column c with (r, c). In this problem, rows and columns are numbered from 0 to 9. Each grid cell contains exact one dot. The exterior boundary of the grid are walls. No characters may move to the area outside of the grid. Inside the grid, there are no walls or obstacles. All characters may move freely from a cell to any cell adjacent to it. Note that two grid cells (r1, c1) and (r2, c2) are adjacent to each other if and only if |r1 − r2| + |c1 − c2| = 1.
  Adam has to prepare the movements of Pac-Man for the testing. He needs a set of Pac-Man’s trajectories with diversity, but any trajectory must satisfy the following requirements.
• Pac-Man eats all dots in the maze if it follows the trajectory.
• Pac-Man moves at most 10000 steps.
  Adam needs your help to generate a trajectory starting at cell (x, y). Please write a program to generate a trajectory of Pac-Man satisfying all requirements above and starting at cell (x, y).

输入描述:

The input has exactly one line which consists of two space-separated  integers x and y. You are asked to generate a trajectory starting at  cell (x, y).

输出描述:

 

You must output a requested trajectory in the following format: 

The trajectory is represented by m + 1 lines where m is the number of steps of the trajectory.The i-th line contains two integers ri and ci separated by exactly one space. The trajectorystarts at the cell (r1, c1), and Pac-Man will be in cell (ri, ci) after moving i − 1 steps along thetrajectory for 1 < i ≤ m + 1. 

示例1

输入

复制

0 0

输出

复制

0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 9
1 8
1 7
1 6
1 5
1 4
1 3
1 2
1 1
1 0
2 0
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
3 9
3 8
3 7
3 6
3 5
3 4
3 3
3 2
3 1
3 0
4 0
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
5 9
5 8
5 7
5 6
5 5
5 4
5 3
5 2
5 1
5 0
6 0
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
7 9
7 8
7 7
7 6
7 5
7 4
7 3
7 2
7 1
7 0
8 0
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 8
8 9
9 9
9 8
9 7
9 6
9 5
9 4
9 3
9 2
9 1
9 0

备注:

 

• m ≤ 10000

• x, y, ri, ci ∈ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} for all i ∈ {1, 2, . . . , m + 1}.

• Cells (ri, ci) and (ri+1, ci+1) are adjacent to each other for all i ∈ {1, 2, . . . , m}. 

• {(r1, c1)} ∪ {(r2, c2)} ∪ · · · ∪ {(rm+1, cm+1)} = {(r, c) : r ∈ {0, 1, . . . , 9}, c ∈ {0, 1, . . . , 9}}

• If there are multiple solutions, then you may output any of them. 

#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;

long long numbers[100];
int main()
{
    int x, y;
    cin >> x >> y;
    for(int i = x; i > 0; --i)
        cout << i << " " << y << endl;
    for(int i = y; i > 0; --i)
        cout << 0 << " " << i << endl;
    for(int i = 0; i < 10; ++i)
    {
        if(i % 2 == 0)
        {
            for(int j = 0; j < 10; ++j)
                cout << i << " " << j << endl;
        }
        else
        {
            for(int j = 9; j >= 0; --j)
                cout << i << " " << j << endl;
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郭晋龙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值