上一页 1 2 3 4 5 6 7 8 9 10 ··· 40 下一页

2014年1月14日

ZOJ 3261 Connections in Galaxy War 并查集

摘要: 将操作序列反向,用并查集维护集合里最强的星球。--------------const int maxn=11000;const int maxm=22000;const int maxq=55000;int n,m,Q;int p[maxn];int a[maxn];int id[maxn];int pa[maxn];void makeset(int n){ for (int i=0;ia[y]){ a[y]=a[x]; id[y]=id[x]; } else if (a[y]==a[x]&&id[x]ans;set... 阅读全文

posted @ 2014-01-14 22:26 电子幼体 阅读(136) 评论(0) 推荐(0) 编辑

2014年1月13日

SGU 467 Chessmaster 几何

摘要: ------------------int n;int main(){ int cas=0; while (~scanf("%d",&n)){ int ans=0; if (n==0) ans=0; else if (n<=78) ans=1; else if (n<=95) ans=2; else if (n<=99) ans=3; else ans=4; printf("Case #%d: %d\n",++cas,ans); } return 0;}------------------ 阅读全文

posted @ 2014-01-13 20:40 电子幼体 阅读(176) 评论(0) 推荐(0) 编辑

POJ 2784 Buy or Build 最小生成树

摘要: 枚举方案后做最小生成树。------------const int maxn=1100;const int maxm=10000;int n,q;vectorg[10];int c[10];struct Point{ int x,y; int getValueTo(Point p){ return (p.x-x)*(p.x-x)+(p.y-y)*(p.y-y); }}p[maxn];struct EDGE{ int u,v,d; bool operator<(const EDGE& rhs) const{ return d<rhs.d;... 阅读全文

posted @ 2014-01-13 20:39 电子幼体 阅读(201) 评论(0) 推荐(0) 编辑

URAL 1023 Buttons 博弈

摘要: 当K是L+1的倍数时,先手必败。又因为L>=2,特殊考虑2*p的数据。--------#include #include using namespace std;int main(){ int K,i,L; while (cin>>K){ for (i=3;i4) L=K/2-1; else L=K-1; cout<<L<<endl; } return 0;}-------- 阅读全文

posted @ 2014-01-13 20:37 电子幼体 阅读(109) 评论(0) 推荐(0) 编辑

2014年1月12日

ZOJ 3149 Breadtree DP

摘要: --------------------const int maxn=100000;const int maxm=10000;const LL LIM=1234567890LL;LL n,k;LL f[maxn];LL sum[maxn];int main(){ while (cin>>n>>k){ if (n==0) break; if (k==0) coutLIM) break; } cout<<ans<<endl; } } return 0;}-------------------- 阅读全文

posted @ 2014-01-12 22:30 电子幼体 阅读(138) 评论(0) 推荐(0) 编辑

ZOJ 3279 Ants 二分树状数组

摘要: ----------const int maxn=110000;const int maxm=10000;int n,m;struct BIT{ int n; int tree[maxn]; void init(int n){ this->n=n; memset(tree,0,sizeof(tree)); } int lowbit(int x){ return x&(-x); } void add(int x,int val){ for (int i=x;i0;i-=lowbit(i)) ret+... 阅读全文

posted @ 2014-01-12 20:38 电子幼体 阅读(123) 评论(0) 推荐(0) 编辑

URAL 1039 Anniversary Party 树形dp

摘要: -----------const int maxn=10000;const int maxm=110000;int n;struct EdgeNode{ int to,next;}edges[maxm];int head[maxn],edge;void init(){ memset(head,-1,sizeof(head)); edge=0;}void addedge(int u,int v){ edges[edge].to=v,edges[edge].next=head[u],head[u]=edge++;}int a[maxn];int f[maxn][2];int... 阅读全文

posted @ 2014-01-12 18:37 电子幼体 阅读(118) 评论(0) 推荐(0) 编辑

ZOJ 3278 8G Island 二分+二分

摘要: 第K大,不是第K小啊 (╯‵□′)╯︵┻━┻----------int n,m;LL K;LL a[maxn],b[maxn];bool C(LL x){ LL res=0; for (int i=1;i=x){ ans=mid; l=mid+1; } else r=mid-1; } res+=ans; } return res>=K;}int main(){ while (cin>>n>>m>>K){ for (int... 阅读全文

posted @ 2014-01-12 17:42 电子幼体 阅读(121) 评论(0) 推荐(0) 编辑

2014年1月11日

POJ 2785 4 Values whose Sum is 0 二分

摘要: ---------------const int maxn=4100;const int maxm=10000;int n,m;int a[4][maxn];int b[maxn*maxn];int main(){ while (~scanf("%d",&n)){ for (int i=0;i<n;i++){ for (int k=0;k<4;k++){ scanf("%d",&a[k][i]); } } for (int i=0;i<n;i++){ for... 阅读全文

posted @ 2014-01-11 23:05 电子幼体 阅读(154) 评论(0) 推荐(0) 编辑

POJ 3063 Sherlock Holmes 随机化

摘要: ----------------int n,m;int w[maxn],b[maxn];int s1[maxn],s2[maxn];int w1,b1,w2,b2;double ans,mo;bool flag;void work(int x,int y) { w1=w1-w[s1[x]]+w[s2[y]]; w2=w2-w[s2[y]]+w[s1[x]]; b1=b1-b[s1[x]]+b[s2[y]]; b2=b2-b[s2[y]]+b[s1[x]]; swap(s1[x],s2[y]);}void cal() { if (w1>b1&&w2>b2) {... 阅读全文

posted @ 2014-01-11 21:28 电子幼体 阅读(186) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 10 ··· 40 下一页

导航