又是一道妹子题 →_→
不过就是很简单的一个模拟过程吧,没有什么太多的技巧什么的
题目大意:
给出妹子的二围(长和宽)分别是 n*m,然后接下来给出四组n*m的数据,依次是对应操作1,2,3,4后的坐标变换
比如第一组中的第i行j列的坐标,就是执行操作1之后,如果你之前在位置(i,j) 处, 那么现在就变成在输入的这个坐标处
现在你不知道自己起始的坐标,但是给出操作,问你最终的坐标可能是哪里
直接对于所有的起始坐标模拟一遍变换过程,将最终的位置标记
模拟所有可能的起始位置之后得到的被标记的坐标就是之后的可能的最终位置,进行统计数量和输出操作即可
代码如下:
Result : Accepted Memory : 681 KB Time : 312 ms
/*
* Author: Gatevin
* Created Time: 2014/7/21 15:37:40
* File Name: test.cpp
*/
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
const double eps(1e-8);
typedef long long lint;
int N,M;
int nextx[5][101][101];
int nexty[5][101][101];
int S[4001];
bool hehe[101][101];
int tmp;
int tmpx, tmpy;
void update(int x, int y)
{
for(int i = 1; i <= tmp; i++)
{
tmpx = x;
tmpy = y;
x = nextx[S[i]][tmpx][tmpy];
y = nexty[S[i]][tmpx][tmpy];
}
hehe[x][y] = true;
}
int main()
{
scanf("%d %d",&N,&M);
for(int i = 1; i <= 4; i++)
{
for(int j = 1; j <= N; j++)
{
for(int k = 1; k <= M; k++)
{
scanf("%d %d",&nextx[i][j][k],&nexty[i][j][k]);
}
}
}
scanf("%d",&tmp);
memset(hehe, 0, sizeof(hehe));
for(int i = 1; i <= tmp; i++)
{
scanf("%d",&S[i]);
}
for(int i = 1; i <= N; i++)
{
for(int j = 1; j <= M; j++)
{
update(i, j);
}
}
int cnt = 0;
for(int i = 1; i <= N; i++)
{
for(int j = 1; j <= M; j++)
{
if(hehe[i][j])
cnt++;
}
}
printf("%d\n",cnt);
for(int i = 1; i <= N; i++)
{
for(int j = 1; j <= M; j++)
{
if(hehe[i][j])
printf("%d %d\n", i, j);
}
}
return 0;
}