poj 1208 The Blocks Problem 模拟+vector的使用

模拟水题,直接贴代码,主要是vector的使用。

//poj 1208
//sep9
#include <iostream>
#include <vector>
using namespace std;
const int maxN=32;
vector<int> v[maxN],tmp;
char a[32],b[32];
int n,x,y,a1,a2,b1,b2;
void get_address()
{
	int i,j;
	for(i=0;i<n;++i)
		for(j=0;j<v[i].size();++j)
			if(v[i][j]==x){
				a1=i;
				b1=j;
			}
	for(i=0;i<n;++i)
		for(j=0;j<v[i].size();++j)
			if(v[i][j]==y){
				a2=i;
				b2=j;
			}
}

void show()
{
	int i,j;
	for(i=0;i<n;++i){
		printf("%d:",i);
			for(j=0;j<v[i].size();++j)
				printf("% d",v[i][j]);
			printf("\n");
		}
}

void a_move_back()
{
	int i;
	tmp.clear();
	for(i=b1+1;i<v[a1].size();++i)
		tmp.push_back(v[a1][i]);
	v[a1].erase(v[a1].begin()+b1+1,v[a1].end());
	for(i=0;i<tmp.size();++i){
		int x=tmp[i];
		v[x].insert(v[x].begin(),x);
	}
}

void b_move_back()
{
	int i;
	tmp.clear();
	for(i=b2+1;i<v[a2].size();++i)
		tmp.push_back(v[a2][i]);
	v[a2].erase(v[a2].begin()+b2+1,v[a2].end());
	for(i=0;i<tmp.size();++i){
		int x=tmp[i];
		v[x].insert(v[x].begin(),x);
	}
}
时间: 2024-10-18 19:26:15

poj 1208 The Blocks Problem 模拟+vector的使用的相关文章

POJ 1208 The Blocks Problem

The Blocks Problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5397   Accepted: 2312 Description Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of

PKU 1208 The Blocks Problem(模拟+list应用)

题目大意:原题链接 关键是正确理解题目意思 首先:介绍一下list容器的一些操作:参考链接 list<int> c1; c1.unique();              去重. c1.reverse();             反转链表. c1.insert(pos,num);   在pos位置插入元素num. c1.insert(pos,n,num);在pos位置插入n个元素num. c1.assign(n,num);     将n个num拷贝赋值给链表c. c1.sort();    

The Blocks Problem(vector)

题目链接:http://poj.org/problem?id=1208 The Blocks Problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5004   Accepted: 2119 Description Many areas of Computer Science use simple, abstract domains for both analytical and empirical studie

POJ 1208.cpp

The Blocks Problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4815   Accepted: 2043 Description Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of

uva 101 The Blocks Problem (基本算法-模拟)

 The Blocks Problem  Background Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world in which a robot arm performed

UVA - 101 The Blocks Problem(STL,模拟)

The Blocks Problem Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description Background Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an e

uva 101 The Blocks Problem (模拟)

uva 101  The Blocks Problem Background Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world in which a robot arm per

UVA101 HDU1612 POJ1208 The Blocks Problem

问题链接:UVA101 HDU1612 POJ1208 The Blocks Problem. 这是一个模拟题,程序过程都是套路. 程序中用到了STL的容器类vector. 这个程序在UVA和POJ中都AC,可是在HDU中是"Presentation Error". AC通过的C++语言程序如下: /* UVA101 HDU1612 POJ1208 The Blocks Problem */ #include <iostream> #include <string&g

poj 3087 Shuffle&#39;m Up(模拟题)

Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6143   Accepted: 2880 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of