T1 [HAOI2016]放棋子

https://daniu.luogu.org/problem/show?pid=3182

障碍交换行不影响

所以第i列有障碍的行换到第i行

然后错排公式

本校自测要写压位高精,不写了。。。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
int len;
int num[];
void clear()
{
len=;
memset(num,,sizeof(num));
}
void operator = (int a)
{
len=;
while(a) len++,num[len]=a%,a/=;
}
void operator = (node a)
{
len=a.len;
for(int i=;i<=len;i++) num[i]=a.num[i];
}
node operator + (node a)
{
node c; c.clear();
memset(c.num,,sizeof(c.num));
int L=max(a.len,len);
c.len=L;
for(int i=;i<=L;i++) c.num[i]=num[i]+a.num[i];
for(int i=;i<=L;i++)
if(c.num[i]>) c.num[i+]+=c.num[i]/,c.num[i]%=;
if(c.num[L+]) c.len++;
while(c.num[c.len]>) c.num[c.len+]=c.num[c.len]/,c.num[c.len]%=,len++;
if(c.num[c.len+]) c.len++;
return c;
}
node operator * (int a)
{
node c; c.clear();
int L;
c.len=L=len;
for(int i=;i<=L;i++) c.num[i]=num[i]*a;
for(int i=;i<=L;i++)
if(c.num[i]>) c.num[i+]+=c.num[i]/,c.num[i]%=;
if(c.num[L+]) c.len++;
while(c.num[c.len]>) c.num[c.len+]=c.num[c.len]/,c.num[c.len]%=,len++;
if(c.num[c.len+]) c.len++;
return c;
}
void print()
{
for(int i=len;i;i--) printf("%d",num[i]);
}
};
node f[];
int main()
{
// freopen("firstmeet.in","r",stdin);
// freopen("firstmeet.out","w",stdout);
int n;
scanf("%d",&n);
f[]=,f[]=,f[]=;
for(int i=;i<=n;i++)
{
f[i].clear();
f[i]=(f[i-]+f[i-])*(i-);
}
f[n].print();
}

T2  [Usaco2010 Dec]Exercise 奶牛健美操

http://www.lydsy.com/JudgeOnline/problem.php?id=2097

树形DP

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 100001
using namespace std;
int front[N],to[N<<],nxt[N<<],tot;
int dp[N],tmp[N];
int cnt,p;
void read(int &x)
{
x=; char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) { x=x*+c-''; c=getchar(); }
}
void add(int u,int v)
{
to[++tot]=v; nxt[tot]=front[u]; front[u]=tot;
to[++tot]=u; nxt[tot]=front[v]; front[v]=tot;
}
bool dfs(int x,int y,int z)
{
int sum=;
for(int i=front[x];i;i=nxt[i])
if(to[i]!=y) { if(!dfs(to[i],x,z)) return false; }
for(int i=front[x];i;i=nxt[i])
if(to[i]!=y) tmp[++sum]=dp[to[i]]+;
sort(tmp+,tmp+sum+);
for(sum;tmp[sum]+tmp[sum-]>z;sum--,cnt++);
dp[x]=tmp[sum];
if(cnt>p) return false;
return true;
}
bool check(int mid)
{
memset(dp,,sizeof(dp));
cnt=;
return dfs(,,mid);
}
int main()
{
/* int size = 256 << 15;
char *pp = (char*) malloc(size) + size;
__asm__ ("movl %0, %%esp\n" :: "r"(pp));
freopen("longnosee.in","r",stdin);
freopen("longnosee.out","w",stdout); */
int n;
read(n), read(p);
int u,v;
for(int i=;i<n;i++)
{
read(u),read(v);
add(u,v);
}
int l=,r=n,mid,ans;
while(l<=r)
{
mid=l+r>>;
if(check(mid)) ans=mid,r=mid-;
else l=mid+;
}
printf("%d",ans);
}

T3

大爆搜,粘std啦

#include <cstdio>
#include <iostream>
#define rg register
#define Max 22
inline void read (int &now)
{
rg char c = getchar ();
for (now = ; !isdigit (c); c = getchar ());
for (; isdigit (c); now = now * + c - '', c = getchar ());
}
int _x[] = { , -, , , , }, _y[] = { , , , -, , }, _z[] = { , , , , , - };
int N, M, Z, P, Sx, Sy, Sz, St, Tt,Tx, Ty, Tz, Answer; bool is[Max][Max][Max], dot[Max][Max][Max];
inline bool Can (int x, int y, int z) { return x > && x <= N && y > && y <= M && z > && z <= Z && !is[x][y][z] && !dot[x][y][z]; }
inline int abs (int a) { return a < ? -a : a; }
void Dfs (int x, int y, int z, int t, int s)
{
int r = abs (x - Tx) + abs (y - Ty) + abs (z - Tz);
if (s + (r >> ) >= Answer) return ;
if (x == Tx && y == Ty && z == Tz) { if (t == Tt) Answer = s; return ; }
rg int i, a, b, c;
if (Can (x + _x[t], y + _y[t], z + _z[t]) && Can (x + _x[t] * , y + _y[t] * , z + _z[t] * ))
{
is[x + _x[t]][y + _y[t]][z + _z[t]] = true;
is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = true;
for (i = ; i < ; ++ i)
if ((i >> ) != (t >> ) && Can (a + _x[i], b + _y[i], c + _z[i]) && Can (a + _x[i] * , b + _y[i] * , c + _z[i] * ))
{
is[a + _x[i]][b + _y[i]][c + _z[i]] = true;
is[a + _x[i] * ][b + _y[i] * ][c + _z[i] * ] = true;
Dfs (a + _x[i] * , b + _y[i] * , c + _z[i] * , i, s + );
is[a + _x[i]][b + _y[i]][c + _z[i]] = false;
is[a + _x[i] * ][b + _y[i] * ][c + _z[i] * ] = false;
}
if (Can (x + _x[t] * , y + _y[t] * , z + _z[t] * ))
{
is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = true;
for (i = ; i < ; ++ i)
if ((i >> ) != (t >> ) && Can (a + _x[i], b + _y[i], c + _z[i]))
{
is[a + _x[i]][b + _y[i]][c + _z[i]] = true;
Dfs (a + _x[i], b + _y[i], c + _z[i], i, s + );
is[a + _x[i]][b + _y[i]][c + _z[i]] = false;
}
is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = false;
}
is[x + _x[t]][y + _y[t]][z + _z[t]] = false;
is[x + _x[t] * ][y + _y[t] * ][z + _z[t] * ] = false;
}
}
int Main ()
{
freopen ("blessyou.in", "r", stdin); freopen ("blessyou.out", "w", stdout);
read (N), read (M), read (Z), read (P); rg int i, j; int x, y, z; rg char c;
if (N <= && M <= && Z <= ) return printf ("Dream Battle"), ;
read (Sx), read (Sy), read (Sz);
for (c = getchar (); c != 'x' && c != 'y' && c != 'z'; c = getchar ());
St = (c - 'x') << ;
if (c == 'x') St += (Sx == N); else if (c == 'y') St += (Sy == M);
else if (c == 'z') St += (Sz == Z);
Sx -= _x[St], Sy -= _y[St], Sz -= _z[St];
read (Tx), read (Ty), read (Tz);
for (c = getchar (); c != 'x' && c != 'y' && c != 'z'; c = getchar ());
Tt = (c - 'x') << ;
if (c == 'x') Tt += (Tx == ); else if (c == 'y') Tt += (Ty == );
else if (c == 'z') Tt += (Tz == );
for (i = ; i <= P; ++ i) read (x), read (y), read (z), dot[x][y][z] = true;
Answer = ; Dfs (Sx, Sy, Sz, St, );
if (Answer == ) printf ("Dream Battle"); else printf ("%d", Answer);
return ;
}
int ZlycerQan = Main (); int main (int argc, char *argv[]) { return ; }

NOIP模拟赛11的更多相关文章

  1. 11/1 NOIP 模拟赛

    11.1 NOIP 模拟赛 期望得分:50:实际得分:50: 思路:暴力枚举 + 快速幂 #include <algorithm> #include <cstring> #in ...

  2. NOIP模拟赛-2018.11.7

    NOIP模拟赛 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 编译之前另存一份,听说如果敲 ...

  3. NOIP模拟赛-2018.11.6

    NOIP模拟赛 今天想着反正高一高二都要考试,那么干脆跟着高二考吧,因为高二的比赛更有技术含量(我自己带的键盘放在这里). 今天考了一套英文题?发现阅读理解还是有一些困难的. T1:有$n$个点,$m ...

  4. NOIP模拟赛-2018.11.5

    NOIP模拟赛 好像最近每天都会有模拟赛了.今天从高二逃考试跑到高一机房,然而高一也要考试,这回好像没有拒绝的理由了. 今天的模拟赛好像很有技术含量的感觉. T1:xgy断句. 好诡异的题目,首先给出 ...

  5. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

  6. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  7. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

  8. 10.17 NOIP模拟赛

    目录 2018.10.17 NOIP模拟赛 A 咒语curse B 神光light(二分 DP) C 迷宫maze(次短路) 考试代码 B 2018.10.17 NOIP模拟赛 时间:1h15min( ...

  9. NOI.AC NOIP模拟赛 第三场 补记

    NOI.AC NOIP模拟赛 第三场 补记 列队 题目大意: 给定一个\(n\times m(n,m\le1000)\)的矩阵,每个格子上有一个数\(w_{i,j}\).保证\(w_{i,j}\)互不 ...

随机推荐

  1. Planning The Expedition(暴力枚举+map迭代器)

    Description Natasha is planning an expedition to Mars for nn people. One of the important tasks is t ...

  2. 20172330 2017-2018-1 《Java程序设计》第十周学习总结

    20172330 2017-2018-1 <程序设计与数据结构>第十周学习总结 教材学习内容总结 本周的学习内容为集合 集合 对象具有定义良好的接口,从而成为一种实现集合的完善体制. 动态 ...

  3. vue+vue-video-player实现弹窗播放视频

    将视频播放器标签放在对话框标签中,实现弹窗 template 中 <el-dialog :visible.sync="dialogVisible" width='680px' ...

  4. webpack打包多html开发案例新

    闲来无事在原来简单打包案例的基础上,参考vue-cli的打包代码,改为多文件打包. 区别于上篇文章<webpack打包多html开发案例>,此次打包根据开发的不同环节进行打包,也就是有开发 ...

  5. PHP中对象的传值方式

    对象的传值方式: 为什么对于对象,值传递和引用传递,这个情况下,他们似乎没有区别??? 这要从对象的数据的存储方式来理解: $o1 = new C1(); //这里创建一个对象o1,其存储结果如图所示 ...

  6. Testng 运行Cannot find class in classpath

    用Testng运行多个class,结果报: org.testng.TestNGException: Cannot find class in classpath: Salesman     at or ...

  7. windows 网络共享无法用

    可以远程电脑,但是无法网卡共享 原因是  远程电脑的Server服务停掉了,再开启下就行了

  8. 【刷题】BZOJ 1195 [HNOI2006]最短母串

    Description 给定n个字符串(S1,S2,„,Sn),要求找到一个最短的字符串T,使得这n个字符串(S1,S2,„,Sn)都是T的子串. Input 第一行是一个正整数n(n<=12) ...

  9. Unity3D实现3D立体游戏原理及过程

    Unity3D实现3D立体游戏原理及过程 183 0 0     下面的教程是我今天整理的资料,教大家一步步完成自己的3D立体游戏,并向大家介绍一些3D成像的原理.     理论上,每个普通的非立体3 ...

  10. mysqldump备份恢复

    数据库的备份恢复是DBA的必修课,本文首先讲解mysqldump完整备份恢复的操作方法,演示数据库完整备份的基本过程.然后再模拟数据库遭遇灾难性破坏,配合bin-log日志实验数据库灾难性恢复的步骤. ...