[物理 杂题] Codeforces Gym 101190 NEERC 16 J. Jenga Boom
来源:互联网 发布:mac五国问题 编辑:程序博客网 时间:2024/05/22 12:50
纯模拟
#include<cstdio>#include<cstdlib>#include<algorithm>using namespace std;typedef long long ll;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;}inline void read(int &x){ char c=nc(),b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;}const int N=5005;bool used[N][N<<1];int n,w,h,m;ll l[N],r[N],x[N],y[N],cnt[N];int main(){ int k,s; freopen("jenga.in","r",stdin); freopen("jenga.out","w",stdout); read(n); read(w); read(h); read(m); for (int i=1;i<=h;i++){ for (int j=1;j<=n;j++) used[i][j]=1; l[i]=1,r[i]=n; x[i]=n*n,y[i]=n*n; cnt[i]=n; } for (int t=1;t<=m;t++){ read(k); read(s); used[k][s]=0; cnt[k]--; if (!cnt[k]) for (int i=k;i<=h;i++) if (cnt[i]) return printf("yes\n%d\n",t),0; if (~k&1) y[k]-=n,x[k]-=2*s-1; else x[k]-=n,y[k]-=2*s-1; for (int i=1;i<=n;i++) if (used[k][i]){ l[k]=i; break; } for (int i=n;i;i--) if (used[k][i]){ r[k]=i; break; } ll sumx=0,sumy=0,sumcnt=0; for (int i=h;i;i--){ if (sumcnt) if (~i&1){ if (2*(l[i]-1)*sumcnt>=sumx || 2*r[i]*sumcnt<=sumx) return printf("yes\n%d\n",t),0; }else { if (2*(l[i]-1)*sumcnt>=sumy || 2*r[i]*sumcnt<=sumy) return printf("yes\n%d\n",t),0; } sumx+=x[i],sumy+=y[i],sumcnt+=cnt[i]; } } printf("no\n"); return 0;}
0 0
- [物理 杂题] Codeforces Gym 101190 NEERC 16 J. Jenga Boom
- Codeforces Gym 101190 (NEERC 2016) J. Jenga Boom
- [杂题] Codeforces Gym 101190 NEERC 16 K. Kids Designing Kids
- [杂题] Codeforces Gym 101190 NEERC 16 L. List of Primes
- [博弈论] Codeforces Gym 101190 NEERC 16 G. Game on Graph
- [构造] Codeforces Gym 101190 NEERC 16 C. Cactus Construction
- [扫描线 杂题] Codeforces Gym 101190 NEERC 16 E. Expect to Wait
- [杂题 交互] Codeforces Gym 101190 NEERC 16 I. Indiana Jones and the Uniform Cave
- Codeforces Gym 101190 (NEERC 2016) A. Abbreviation
- [树形DP 费用流手动增广] Codeforces Gym 101190 NEERC 16 M. Mole Tunnels
- [Trie树建图 2-SAT] Codeforces Gym 101190 NEERC 16 B. Binary Code
- [费用流建模] Codeforces Gym 101190 NEERC 16 D. Delight for a Cat
- Codeforces Gym 101190 (NEERC 2016) F. Foreign Postcards (dp + 期望)
- Codeforces Gym 101190 NEERC 2016 B. Binary Code
- [交互 杂题] Codeforces Gym 100307 NEERC 13 I. Interactive Interception
- codeforces-gym-100187-J【dfs】
- Codeforces Gym 101246J Buoys
- Codeforces Gym 100753J Souvenirs
- 第63天(就业班) easyui
- mysql-5.7.16-winx64解压版安装超详细图文教程
- poj 3667 hotel
- HDU 1372 Knight Moves
- 克隆二叉树
- [物理 杂题] Codeforces Gym 101190 NEERC 16 J. Jenga Boom
- F. 80ers' Memory
- C++ 类方法和实例方法辨析
- Win7系统下利用U盘安装Ubuntu_12.04实现双系统教程
- Unity中File和FileInfo
- Html中设置按钮竖直居中
- 微信小程序用户数据解密
- 无聊的计算机网络应急知识
- Mysql的接口函数