A.Babs' Box Boutique

给定n个盒子,每个盒子都有长宽高(任意两个盒子长宽高不完全相同),现在选盒子的任意两面,要求x1 <= x2 && y1 <= y2,问最多能选多少盒子满足这需求。

直接dfs暴搞................

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
# define INF 0x7FFFFFFF
using namespace std;
int vis[11];
struct node {
int a[3];
}p[11];
int ans,n;
int dx[] = {0,0,1};
int dy[] = {1,2,2};
//bool cmp(int a,int b) {
// return a > b;
//} void dfs(int step,int x,int y) {
if(step > ans) ans = step;
if(step == n) return ;
for(int i=0; i<n; i++) {
if(vis[i] == 1) continue; for(int j=0; j<3; j++) {
int xx = p[i].a[dx[j]];
int yy = p[i].a[dy[j]];
if(xx >= x && yy >= y ) {
vis[i] = 1;
dfs(step + 1,xx,yy);
vis[i] = 0;
}
}
}
} int main() {
int casee = 1;
while(scanf("%d",&n) && n) {
if(n == 0) break;
int tmp[3];
for(int i=0; i<n; i++) {
scanf("%d%d%d",&tmp[0],&tmp[1],&tmp[2]);
sort(tmp,tmp+3);
p[i].a[0] = tmp[0];
p[i].a[1] = tmp[1];
p[i].a[2] = tmp[2];
}
ans = 0;
memset(vis,0,sizeof(vis));
dfs(0,0,0);
printf("Case %d: %d\n",casee++,ans);
}
return 0;
}

C.Hexagon Perplexagon

题意就不写了:戳这

dfs暴搞,每一层传入三个参数,层数, 每一块需要匹配的前驱点,和最后一块需要匹配的点..........

#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int map[8][8];
int ans[8];
int save[8];
int vis[8];
int n,ok; void change(int x,int pos) {
int i;
for(i=0; i<6; i++) {
if(map[x][i] == pos) break;
}
pos = i;
int cnt = 0;
for(int i=0; i<6; i++) {
save[cnt++] = map[x][pos];
pos ++;
if(pos >= 6) pos -= 6;
}
} int getpre(int pos,int t) {
t --;
if(t < 0) t = 5;
return map[pos][t];
} int getsuc(int pos,int t) {
t ++;
if(t > 5) t = 0;
return map[pos][t];
} void dfs(int step,int p1,int p2) {
if(step == 7) return ;
if(ok == 1) return ;
for(int i=0; i<7; i++) {
if(vis[i] == 1) continue;
int j;
for(j=0; j<6; j++) {
if(map[i][j] == save[step-1]) break;
}
int tmp1 = getpre(i,j);
int tmp2 = getsuc(i,j);
if(step == 1) {
ans[step] = i;
vis[i] = 1;
dfs(step + 1,tmp1,tmp2);
vis[i] = 0;
}
if(step > 1 && step < 6) {
if(tmp2 == p1 ) {
ans[step] = i;
vis[i] = 1;
dfs(step+1,tmp1,p2);
vis[i] = 0;
}
}
if(step == 6) {
if(tmp2 == p1 && tmp1 == p2 ) {
ans[step] = i;
ok = 1;
}
}
if(ok == 1) return ;
}
}
int main() {
int T;
cin >> T;
int casee = 1;
while(T --) {
for(int i=0; i<7; i++) {
for(int j=0; j<6; j++) {
scanf("%d",&map[i][j]);
}
}
ok = 0;
for(int i=0; i<7; i++) {
memset(vis,0,sizeof(vis));
vis[i] = 1;
change(i,1);
ans[0] = i;
dfs(1,0,0);
if(ok) break;
}
printf("Case %d: ",casee++);
if(ok == 0) {
printf("No solution\n");
continue;
}
printf("%d",ans[0]);
for(int i=1; i<7; i++) {
printf(" %d",ans[i]);
}
puts("");
}
return 0;
}

D.I've Got Your Back(gammon)

暴搞,每一种排列分别保存它的各个点的情况,并且用map保存每种排列的顺序下标

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;
struct node
{
int pos[10];
} p[20000]; map <string,int>mm;
int cnt ;
string str = "";
string str2 = "";
string change(int x)
{
str = "";
str2 = "";
if(x == 0)
{
str += '0';
return str;
}
int cn = 0;
while(x)
{
int t = x % 10;
str += t + '0';
x = x / 10;
}
int len = str.length();
for(int i=len-1; i>=0; i--) str2 += str[i];
str2 += '\0';
return str2;
}
void init()
{
cnt = 0;
for(int i=0; i<=15; i++)
{
for(int j=0; j<=15; j++)
{
for(int k=0; k<=15; k++)
{
for(int l=0; l<=15; l++)
{
for(int x=0; x<=15; x++)
{
for(int y=0; y<=15; y++)
{
int t = i + j + k + l + x + y;
if(t > 15) break;
if(t == 15)
{
string tmp;
p[cnt].pos[0] = i;
p[cnt].pos[1] = j;
p[cnt].pos[2] = k;
p[cnt].pos[3] = l;
p[cnt].pos[4] = x;
p[cnt].pos[5] = y;
tmp += change(i);
tmp += ' ';
tmp += change(j);
tmp += ' ';
tmp += change(k);
tmp += ' ';
tmp += change(l);
tmp += ' ';
tmp += change(x);
tmp += ' ';
tmp += change(y); mm[tmp] = cnt;
cnt ++;
}
}
}
}
}
}
}
} int n;
int main()
{
init();
char c;
int a,b,d,e,f,g;
int casee = 1;
while(cin >> c)
{
if(c == 'e') break;
printf("Case %d: ",casee++);
if(c == 'm')
{
scanf("%d%d%d%d%d%d",&a,&b,&d,&e,&f,&g);
string tmp;
tmp += change(a);
tmp += ' ';
tmp += change(b);
tmp += ' ';
tmp += change(d);
tmp += ' ';
tmp += change(e);
tmp += ' ';
tmp += change(f);
tmp += ' ';
tmp += change(g);
//cout << tmp << endl;
printf("%d\n",mm[tmp]);
}
if(c == 'u')
{
scanf("%d",&a);
printf("%d",p[a].pos[0]);
for(int i=1; i<6; i++)
{
printf(" %d",p[a].pos[i]);
}
puts("");
}
}
return 0;
}

组队练习赛(Regionals 2012, North America - East Central NA)的更多相关文章

  1. 130825组队赛-Regionals 2012, North America - East Central NA

    A.Babs' Box Boutique 一道简单的dfs搜索题,需要两两比较,然后搜到底,得到最大值就行了.比赛时队友写的,我只负责debug..赛后自己写的.. #include<iostr ...

  2. Regionals 2012, North America - Greater NY 解题报告

    这套题..除了几何的都出了 完全没时间学几何.杯具 A,B,J 水题不解释 C.Pen Counts 这题的话 写几个不等式限制边得范围就行了 然后枚举最小边 D.Maximum Random Wal ...

  3. HNU 13064 Cuckoo for Hashing解题报告 North America - East Central 2013

    题目大意:使用两个哈希表来解决哈希冲突的问题.假如现在有两个哈希表分别为:H1,H2 ,大小分别为:n1,n2:现有一数据X需要插入,其插入方法为: 1.计算index1 = X MOD N1,  若 ...

  4. Regionals 2013 :: North America - Southeast USA

    Regionals 2013 :: North America - Southeast USA It Takes a Village As a Sociologist, you are studyin ...

  5. 2015 UESTC Winter Training #6【Regionals 2010 >> North America - Rocky Mountain】

    2015 UESTC Winter Training #6 Regionals 2010 >> North America - Rocky Mountain A - Parenthesis ...

  6. MPI Maelstrom(East Central North America 1996)(poj1502)

    MPI Maelstrom 总时间限制:  1000ms 内存限制:  65536kB 描述 BIT has recently taken delivery of their new supercom ...

  7. ICPC North Central NA Contest 2018

    目录 ICPC North Central NA Contest 2018 1. 题目分析 2. 题解 A.Pokegene B.Maximum Subarrays C.Rational Ratio ...

  8. poj 2732 Countdown(East Central North America 2005)

    题意:建一个家庭树,找出有第d代子孙的名字,按照要求的第d代子孙的数从大到小输出三个人名,如果有一样大小子孙数的,就按字母序从小到大将同等大小的都输出,如果小于三个人的就全输出. 题目链接:http: ...

  9. East Central North America Region 2015

    E 每过一秒,当前点会把它的值传递给所有相邻点,问t时刻该图的值 #include <iostream> #include <cstdio> #include <algo ...

随机推荐

  1. JS设置获取cookies

    结合JavaScript权威指南,加上项目开发时在网上搜集的资料,整理了两种设置和获取cookie的方法. <script> //设置cookie  方法一function setCook ...

  2. PL/SQL --> 动态SQL调用包中函数或过程

    动态SQL主要是用于针对不同的条件或查询任务来生成不同的SQL语句.最常用的方法是直接使用EXECUTE IMMEDIATE来执行动态SQL语句字符串或字符串变量.但是对于系统自定义的包或用户自定的包 ...

  3. Luci流程分析(openwrt下)

    1. 页面请求: 1.1. 代码结构 在openwrt文件系统中,lua语言的代码不要编译,类似一种脚本语言被执行,还有一些uhttpd服务器的主目录,它们是: /www/index.html cgi ...

  4. Qt Creator编译时:cannot open file 'debug\QtGuiEx.exe' File not found

    Qt Creator编译时:cannot open file 'debug\QtGuiEx.exe' File not found 利用Qt Creator编译工程时,出现如题目所示的错误,其中红色部 ...

  5. Android.mk文件语法规范及使用模板

    Android.mk文件语法详述 介绍:------------这篇文档是用来描述你的C或C++源文件中Android.mk编译文件的语法的,为了理解她们我们需要您先看完docs/OVERVIEW.h ...

  6. jquery 绑定动态元素

    以一个小例子来简单说明下情况 ? 1 2 3 4 5 6 7 8  <script src="jquery-1.11.0.min.js"></script> ...

  7. hdu1753()模拟大型实景数字相加

    标题信息: 手动求大的实数在一起, pid=1753">http://acm.hdu.edu.cn/showproblem.php?pid=1753 AC代码: /**  *大实数相加 ...

  8. 从头开始——重装ubuntu

    一.装系统 环境:计算机原本装的系统是windows7+ubuntu 14.04,后来ubuntu的启动项被我手贱破坏了,进不了ubuntu,只能重新安装. 启动盘:使用UltraISO软碟通制作U ...

  9. 使用SOAPUI测试WEBAPI接口

    其实很简单,用起来也挺方便的. 首先,先去百度下SoapUI 下载,下载安装好后,打开软件. 1.新建一个项目 点击 Create Empty Project 按钮后,会自动新建一个项目,名字默认为: ...

  10. 程序员使用Node的十个技巧

    从问世到现在将近20年,JavaScript一直缺乏其它有吸引力的编程语言,比如Python和Ruby,的很多优点:命令行界面,REPL,包管理器,以及组织良好的开源社区.感谢Node.js和npm, ...