2014
02-13

# Bloxorz

Bloxorz is an interesting game and someone may have played it before. The rule of this game is simple.
This game is played on a platform constructed of many square grids. You have a cuboid whose size is 2×1×1. On the platform there is a 1×1 hole and it‘s your destination. What you have to do is move the cuboids to the hole. During the game you must keep the cuboid on the platform, if any part of cuboid is off the platform, you lose the game.
When this game starts, the cuboid stays on the platform. The way to move the cuboid is not sliding but rolling. You can move it in any of the four directions. If you want to move it right, the surfaces next to the original bottom in that direction will be the new bottom. In the following three images, the cuboid moves right twice.
Pic-1

Input contains multiple test cases. Each test case starts with two integers N and M (0<N, M < 20), which stand for number of rows and columns of the platform. Then there comes N lines, describe the platform with ‘#’ for empty cell, ‘^’ for square grid, ‘X’ for the position of cuboid (There maybe two ‘X’, but data guarantee that these two ‘X’s belong to the same cuboid and only one cuboid exists.).
Then there comes several lines which stand for order list. Each line only contains uppercase characters and blank. In the list, ‘L’ means moving left, ‘R’ means moving right, ‘U’ means moving up and ‘D’ means moving down. If you meet a ‘Q’, print the whole station of platform. Each case ends with a line a line entitled “END”.
ANY MOVE COULD CAUSE YOU TO LOSE THE GAME, YOU SHOULD JUST IGNORE IT.

Input contains multiple test cases. Each test case starts with two integers N and M (0<N, M < 20), which stand for number of rows and columns of the platform. Then there comes N lines, describe the platform with ‘#’ for empty cell, ‘^’ for square grid, ‘X’ for the position of cuboid (There maybe two ‘X’, but data guarantee that these two ‘X’s belong to the same cuboid and only one cuboid exists.).
Then there comes several lines which stand for order list. Each line only contains uppercase characters and blank. In the list, ‘L’ means moving left, ‘R’ means moving right, ‘U’ means moving up and ‘D’ means moving down. If you meet a ‘Q’, print the whole station of platform. Each case ends with a line a line entitled “END”.
ANY MOVE COULD CAUSE YOU TO LOSE THE GAME, YOU SHOULD JUST IGNORE IT.

5 6
^^^^^^
^X^^^^
^^^^^^
#^^^^^
###^^^
RQ
RQ
END

^^^^^^
^^XX^^
^^^^^^
#^^^^^
###^^^

^^^^^^
^^^^X^
^^^^^^
#^^^^^
###^^^

Input

Output

Sample Input

1 2 3 4
0 0 0 0

Sample Output

5

#include <iostream>

#include <cstring>

#define N 5008

#define M 100000000LL

using namespace std;

long long c[N];

int lowbit(int x)

{

return x&(-x);

}

{

{

}

}

{

long long ans = 0;

{

}

return ans;

}

int main()

{

int x, y, z, n;

long long temp;

while (cin >> x >> y >> z >> n && x)

{

memset(c, 0, sizeof(c));

while (n)

{

temp = sum(n+y) – sum(n+x-1);

n–;

}

cout << (sum(n+z) – sum(n+1))%M << endl;

}

return 0;

}

1. bottes vernies blanches

I appreciate the efforts you men and women place in to share blogs on such sort of matters, it was certainly useful. Keep Posting!

2. 学算法中的数据结构学到一定程度会乐此不疲的，比如其中的2－3树，类似的红黑树，我甚至可以自己写个逻辑文件系统结构来。

3. 学算法中的数据结构学到一定程度会乐此不疲的，比如其中的2－3树，类似的红黑树，我甚至可以自己写个逻辑文件系统结构来。

4. #include <cstdio>
#include <algorithm>

struct LWPair{
int l,w;
};

int main() {
//freopen("input.txt","r",stdin);
const int MAXSIZE=5000, MAXVAL=10000;
LWPair sticks[MAXSIZE];
int store[MAXSIZE];
int ncase, nstick, length,width, tmp, time, i,j;
if(scanf("%d",&ncase)!=1) return -1;
while(ncase– && scanf("%d",&nstick)==1) {
for(i=0;i<nstick;++i) scanf("%d%d",&sticks .l,&sticks .w);
std::sort(sticks,sticks+nstick,[](const LWPair &lhs, const LWPair &rhs) { return lhs.l>rhs.l || lhs.l==rhs.l && lhs.w>rhs.w; });
for(time=-1,i=0;i<nstick;++i) {
tmp=sticks .w;
for(j=time;j>=0 && store >=tmp;–j) ; // search from right to left
if(j==time) { store[++time]=tmp; }
else { store[j+1]=tmp; }
}
printf("%dn",time+1);
}
return 0;
}