/*
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. lua报错,看到报错信息有tail call,以为和尾调用有关,于是查了一下相关知识

    尾调用是指在函数return时直接将被调函数的返回值作为调用函数的返回值返回,尾调用在很多语言中都可以被编译器优化, 基本都是直接复用旧的执行栈, 不用再创建新的栈帧, 原理上其实也很简单, 因为尾调 ...

  2. multi cookie & read bug

    js cookie multi cookie & read bug document.cookie; // "access_token_test=eyJhbGciOiJIUzI1Ni ...

  3. BestCoder Round #29 GTY's gay friends

    #include <cstdio> #include <cstring> #include <vector> #include <algorithm> ...

  4. Codeforces679C. Bear and Square Grid

    n<=500,n*n的01矩阵,可以选择一个k*k的矩阵全变1,求最大1联通区域. 敢敢n^3..模拟k*k的矩阵的位置,从左到右扫的时候,每变一个位置只会引起边界的信息变化,就记含边界的k*k ...

  5. python之模块随笔记-os

    操作系统模块:import os os.remove() 删除文件 os.unlink() 删除链接文件 os.rename() 重命名文件 os.listdir() 列出指定目录下所有文件 os.c ...

  6. JAVA配置--JDK环境变量配置

    环境变量是整台电脑的全局变量,(这台电脑上)任何程序都可以读取这个变量. 如果您安装好jdk,但环境变量配置让你感到有一点模糊的话,那么请您看一下这篇,希望对您有帮助 根据打开电脑的属性(R),出现 ...

  7. HashMap源码分析1:添加元素

    本文源码基于JDK1.8.0_45. final V putVal(int hash, K key, V value, boolean onlyIfAbsent, boolean evict) { N ...

  8. 我的arcgis培训照片9

    来自:http://www.cioiot.com/successview-547-1.html

  9. Linux命令输出头(标题)、输出结果排序技巧

    原文:http://blog.csdn.net/hongweigg/article/details/65446007 ----------------------------------------- ...

  10. GETTING STARTED WITH THE OTTO JAVASCRIPT INTERPRETER

    原文: https://www.fknsrs.biz/blog/otto-getting-started.html.html GETTING STARTED WITH THE OTTO JAVASCR ...