/*
big模拟
细节不少
remove表示这个玩意儿在这一秒有没有移动
注意在一秒内所有小葱一起移动,所以如果一个一个处理
别忘了“错位”这种情况
*/
#include<iostream>
#include<cstdio>
#include<cstring> #define N 1001 using namespace std;
int n,m,T,k,ans;
int belong[N][N],cnt[N][N];
struct C{
int x,y,flag1,turn,f,remove;
}p[N]; inline int read()
{
int x=,f=;char c=getchar();
while(c>''||c<''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
} bool can(int x)
{
if(p[x].remove==) return true;
if(p[x].x== && p[x].turn==) return true;
if(p[x].x==n && p[x].turn==) return true;
if(p[x].y== && p[x].turn==) return true;
if(p[x].y==m && p[x].turn==) return true;
return false;
} void judge(int i,int o)
{
if(cnt[p[i].x][p[i].y])
{
if(can(belong[p[i].x][p[i].y]))
{
if(p[belong[p[i].x][p[i].y]].f>p[i].f) p [i].flag1=;
else p[belong[p[i].x][p[i].y]].flag1=,belong [p[i].x][p[i].y]=i;
}
else
{
belong[p[i].x][p[i].y]=i;
cnt[p[i].x][p[i].y]++;
}
}
else
{
belong[p[i].x][p[i].y]=i;
cnt[p[i].x][p[i].y]++;
}
} int main()
{
freopen("problem.in","r",stdin);
freopen("problem.out","w",stdout);
n=read();m=read();k=read();
for(int i=;i<=k;i++) p[i].x=read(),p[i].y=read(),
p[i].turn=read(),p[i].f=read();
T=read();
for(int i=;i<=k;i++)
belong[p[i].x][p[i].y]=i,cnt[p[i].x][p[i].y]++; while(T--)
{
for(int i=;i<=k;i++) p[i].remove=;
for(int i=;i<=k;i++)
{
if(p[i].flag1) continue;
if(p[i].turn==)
{
if(p[i].x>)
{
cnt[p[i].x][p[i].y]--;
if(belong[p[i].x][p[i].y]==i)
belong[p[i].x][p[i].y]=;
p[i].x--;
judge(i,);p[i].remove=;
}
else {p[i].turn=;p [i].remove=;continue;}
}
if(p[i].turn==)
{
if(p[i].x<n)
{
cnt[p[i].x][p[i].y]--;
if(belong[p[i].x][p[i].y]==i)
belong[p[i].x][p[i].y]=;
p[i].x++;
judge(i,);p[i].remove=;
}
else {p[i].turn=;p[i].remove=;continue;}
}
if(p[i].turn==)
{
if(p[i].y>)
{
cnt[p[i].x][p[i].y]--;
if(belong[p[i].x][p[i].y]==i)
belong[p[i].x][p[i].y]=;
p[i].y--;
judge(i,);p[i].remove=;
}
else {p[i].turn=;p [i].remove=;continue;}
}
if(p[i].turn==)
{
if(p[i].y<m)
{
cnt[p[i].x][p[i].y]--;
if(belong[p[i].x][p[i].y]==i)
belong[p[i].x][p[i].y]=;
p[i].y++;
judge(i,);p[i].remove=;
}
else {p[i].turn=;p [i].remove=;continue;}
}
}
}
for(int i=;i<=k;i++) printf("%d %d\n",p[i].x,p[i].y);
fclose(stdin);fclose(stdout);
return ;
}
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm> using namespace std; const int maxn=;
const int maxk=; int n,m,k,x[maxk],y[maxk],d[maxk],f[maxk],z[maxk],t; bool alive[maxk]; int dx[],dy[]; void move(int p)
{
x[p] += dx[d[p]];
y[p] += dy[d[p]];
if (x[p]< || x[p]>n || y[p]< || y[p]>m)
{
x[p] -= dx[d[p]];
y[p] -= dy[d[p]];
d[p] ^= ;
}
} bool cmp(int a,int b)
{
if (x[a]!=x[b]) return x[a]<x[b];
else return y[a]<y[b];
} int main()
{
dx[]=-;dx[]=;dy[]=-;dy[]=;
scanf("%d%d%d",&n,&m,&k);
for (int a=;a<=k;a++)
scanf("%d%d%d%d",&x[a],&y[a],&d[a],&f[a]);
for (int a=;a<=k;a++)
{
alive[a]=true;
z[a]=a;
}
scanf("%d",&t); for (;t--;)
{
for (int a=;a<=k;a++)
if (alive[a]) move(a);
sort(z+,z+k+,cmp); for (int a=;a<=k;)
{
int b=a,p=-;
while (x[z[b]]==x[z[a]] && y[z[b]]==y[z[a]] && b<=k)
{
if (alive[z[b]] && (p==- || f[z[b]]>f[z[p]])) p=b;
b++;
}
for (int c=a;c<b;c++)
if (p!=- && c!=p) alive[z[c]]=false;
a=b;
}
}
for (int a=;a<=k;a++)
printf("%d %d\n",x[a],y[a]); return ;
}

知道自己代码丑 std0.0

/*
题意不好懂,自行体会。
20暴力 dfs
加剪枝可能会多跑过两个点
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map> #define mod 12345 #define N 9001
using namespace std;
int n,m,flag;
long long ans;
char c[N],cur[N];
int b[N],vis[N];
map<char,int>cnt; inline int read()
{
int x=,f=;char c=getchar();
while(c>''||c<''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
} void dfs(int now)
{
if(now==n+)
{
for(int i=;i<=m;i++) cnt[c[i]]=;
flag=;
for(int i=;i<=n;i++) cnt[cur[i]]++;
for(int i=;i<=m;i++)
if(cnt[c[i]]%b[i] && cnt[c[i]]) flag=;
if(!flag) ans++,ans%=mod;
return;
}
for(int i=;i<=m;i++)
{
if(!vis[now]) vis[now]=,cur[now]=c[i];
dfs(now+);vis[now]=;
}
} int main()
{
freopen("too.in","r",stdin);
freopen("too.out","w",stdout);
n=read();m=read();
for(int i=;i<=m;i++) cin>>c[i]>>b[i];
dfs();ans%=mod;
printf("%lld\n",ans);
return ;
}

/*
30暴力
bitset预处理任意两点间边数 e[i][j]
然后dp dp[i]表示1->i路径数
dp[i+1]=Σdp[j]*e[j][i+1] (j<=i)
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bitset> #define N 1007
#define mod 991127
#define ll long long using namespace std;
bitset<>a;
bitset<>b;
bitset<>c;
int n,m,num[N];
ll e[N][N],dp[N]; inline int read()
{
int x=,f=;char c=getchar();
while(c>''||c<''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
} int main()
{
freopen("easy.in","r",stdin);
freopen("easy.out","w",stdout);
n=read();
for(int i=;i<=n;i++) num[i]=read();
for(int i=;i<=n;i++) for(int j=i+;j<=n;j++)
{
a=num[i];b=num[j];c=a&b;
e[i][j]=c.count();e[i][j]%=mod;
}
dp[]=;ll tmp=;
for(int i=;i<n;i++)
{
tmp=;
for(int j=;j<=i;j++)
{
tmp+=(dp[j]*e[j][i+])%mod;
tmp%=mod;
}
dp[i+]+=tmp;dp[i+]%=mod;
}
dp[n]%=mod;
printf("%lld\n",dp[n]);
return ;
}
/*
注意题目要求只能编号小的往大的连边
f[i]表示第i位是1的数的贡献,编号由小到大类似前缀和累计
先枚举每个点权
如果当前点第i位是1的话,那能转移到它的位置也一定是1
然后再把当前位置的贡献加上
*/
#include <bits/stdc++.h> #define MOD 991127 using namespace std ; int n ; const int MAXN = ; int a[MAXN]; int f[] ; int dp[MAXN] ; inline void update(int &a, int b) {
a += b ;
if (a >= MOD) a -= MOD ;
}
int main() { scanf("%d", &n) ;
for (int i = ; i <= n; i ++) {
scanf("%d", &a[i]) ;
} memset(f, , sizeof f); for (int i = ; i < ; i ++) {
if ((a[] >> i) & ) f[i] = ;
}
dp[] = ;
for (int i = ; i <= n; i ++) {
for (int j = ; j < ; j ++) {
if ((a[i] >> j) & ) update(dp[i], f[j]) ;
}
for (int j = ; j < ; j ++) {
if ((a[i] >> j) & ) update(f[j], dp[i]) ;
}
} printf("%d\n", dp[n]) ; }

10.9NOIP模拟题的更多相关文章

  1. 10.13NOIP模拟题

    /* 容斥原理 考虑到a[i]要么不会太大,要么就对答案贡献很小 dfs即可 */ #include<bits/stdc++.h> #define ll long long #define ...

  2. 10.23NOIP模拟题

    叉叉题目描述现在有一个字符串,每个字母出现的次数均为偶数.接下来我们把第一次出现的字母 a 和第二次出现的 a 连一条线,第三次出现的和四次出现的字母 a 连一条线,第五次出现的和六次出现的字母 a ...

  3. 10.12NOIP模拟题(2)

    /* 有谁知道这道题结论是怎么来的? 晚上问问学数学的孩子23333 */ #include<iostream> #include<cstdio> #include<cs ...

  4. 10.12NOIP模拟题(1)

    #include<iostream> #include<cstdio> #include<cstring> #include<queue> #defin ...

  5. 10.11NOIP模拟题(3)

    /* 可以看出,对于一段区间[L,R]如果统计了答案 若a[L]<a[R],那么当右端点往左移时答案不会更优,a[R]>a[L]同理 所以两个指针分别从头尾往中间扫那边小移哪边即可. */ ...

  6. 10.11NOIP模拟题(2)

    /* string水过 */ #include<bits/stdc++.h> #define N 1001 using namespace std; int n,x,y,m,pre; st ...

  7. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

  8. poj 1888 Crossword Answers 模拟题

    Crossword Answers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 869   Accepted: 405 D ...

  9. sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)

    The Android University ACM Team Selection Contest Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里 ...

随机推荐

  1. BNUOJ 2105 Distance Queries

    Distance Queries Time Limit: 2000ms Memory Limit: 30000KB This problem will be judged on PKU. Origin ...

  2. windows 下 iptables

    windows自带的防火墙就可以. 在命令行方式下输入netsh回车,再输入firewall回车,之后想干什么就干什么. 头一次见对图形化防火墙头晕的...

  3. 封装java-get-post请求方式

    package com.ecar.eoc.content.platform.utils; import java.io.IOException;import java.util.HashMap;imp ...

  4. Inversion 归并求逆元

    bobo has a sequence a 1,a 2,…,a n. He is allowed to swap twoadjacent numbers for no more than k time ...

  5. win10笔记本相机打开黑屏无法打开笔记本相机

    打开注册表编辑器(WINDOWS图标+R,或者右击左下角微软图标选择“运行(R)”),在出现的窗口输入regedit并回车(Enter)确定   进入HKEY_LOCAL_MACHINE \ SOFT ...

  6. Ubuntu 16.04出现:qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory

    没有安装qt4-qmake,安装即可: sudo apt-get install qt4-qmake 参考: https://stackoverflow.com/questions/23703864/ ...

  7. zip4j加密压缩、解压缩文件、文件夹

    原文:http://blog.csdn.net/k21325/article/details/54376188 1.首先,引用到zip4j的第三方类库,感谢作者的无私奉献,官网打不开,这里就不贴了,下 ...

  8. 在gentoo中打开tomcat的远程调试开关

    在一般象gentoo等发行版中,系统安装tomcat这类软件后会产生一些启动脚本, 比如是/etc/init.d/tomcat-7, 启动方式与原始的tomcat不太一样.在gentoo中,假设须要远 ...

  9. 【转】c++中placement new操作符

    new:指我们在C++里通常用到的运算符,比如A* a = new A;  对于new来说,有new和::new之分,前者位于std operator new():指对new的重载形式,它是一个函数, ...

  10. 修改windows下mysql的max_allowed_packet的值

    执行sql报错:Error updating database. Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is to ...