- 博客(23)
- 资源 (4)
- 收藏
- 关注
原创 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
2014-01-14 22:26:13 592
原创 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 (
2014-01-13 20:40:13 713
原创 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)*(
2014-01-13 20:39:24 1003
原创 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;i<=(int)sqrt(K);i++){ if (K%i==0)
2014-01-13 20:37:47 1107
原创 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 (
2014-01-12 22:30:01 611
原创 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
2014-01-12 20:38:14 613
原创 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
2014-01-12 18:37:33 618
原创 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<=n;i++) { int l=1,r=m; LL ans=0; while (l<=r){
2014-01-12 17:42:35 714
原创 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
2014-01-11 23:05:29 589
原创 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]];
2014-01-11 21:28:19 962
原创 hdu 4080 Stammering Aliens 二分 hash
POJ 3882 TLE 需后缀数组------------const int SEED = 13331;const int MAX_N = 50000 + 10;char s[MAX_N];struct HASH{ ULL H[MAX_N]; ULL XL[MAX_N]; int len; HASH(){} void build(char *
2014-01-11 21:26:14 899
原创 POJ 3106 Flip and Turn 模拟 分析
--------const int maxn=400;const int maxm=200000;int n,m;char a[maxn][maxn];char b[maxn][maxn];int stk[10];int cnt;char s[maxm];char cd[7][3]={"1","CX","V","BY","2","AZ","H"};char sp[7][8]=
2014-01-10 00:27:40 901 1
原创 UVA 10635 Prince and Princess DP LIS
--------int n;int a1[111111];int a2[111111];int c[111111];int a[111111];int g[111111];int d[111111];int N,p,q;int main(){ int T; scanf("%d",&T); for (int cas=1;cas<=T;cas++)
2014-01-10 00:26:36 682
原创 URAL 1098 Questions 约瑟夫环
--------int n;int f[maxn];char s[maxn];int main(){ int n=0; while (gets(s+n)){ n=strlen(s); } s[n]=0; f[0]=0; for (int i=1;i<=n;i++) f[i]=(f[i-1]+1999)%i; if (
2014-01-09 00:54:56 770
原创 POJ 2786 Keep the Customer Satisfied 优先队列
----------const int maxn=900000;const int maxm=10000;int n;struct Dat{ int v,lim; const bool operator<(const Dat& rhs) const{ return v<rhs.v; }}a[maxn];bool cmp(Dat a,Dat b
2014-01-08 23:01:27 710
原创 UVA 1335 Beijing Guards 二分贪心
--------const int maxn=110000;const int maxm=10000;int n;int a[maxn];int lb[maxn],rb[maxn];bool C(int x){ lb[0]=a[0]; rb[0]=0; for (int i=1;i<n;i++){ if (i&1){ i
2014-01-08 01:40:03 571
原创 POJ 3169 Layout 差分约束系统
d_x d_x d_y - d_x d_y d_y - d_x >= mind --> d_x -----------const int maxn=4100;const int maxm=180000;int n;struct EdgeNode{ int to; int w; int next;};struct BellmanFord{
2014-01-07 22:56:45 631
原创 ZOJ 2334 Monkey King 可并堆左偏树
----------int n,m;class LeftistTree{private: int tot,v[maxn],l[maxn],r[maxn],d[maxn];public: int merge(int x,int y){ if (!x) return y; if (!y) return x; if (v[x]<
2014-01-07 22:10:14 599
原创 ZOJ 2112 Dynamic Rankings 线段树套平衡树
------------const int N=60010;const int M=10010;class SegmentTree_Treap{private: struct Treap{ int key,fix,cnt,size,ch[2]; }T[N*15]; int tree[N<<1],nodecnt; int ID(int l,
2014-01-07 00:09:43 592
原创 POJ 2796 Feel Good 并查集
答案为0时要输出一个合理的区间...这是个坑.-----------------------const int maxn=110000;const int maxm=10000;int n;int a[maxn];struct Dat{ int v; int idx;};bool cmp(const Dat& a,const Dat& b){ retur
2014-01-06 22:21:29 606
原创 POJ 2970 The lazy programmer 优先队列
--------------const double EPS = 1e-7;const int maxn=150000;int dcmp(double a,double b){ if (abs(a-b)<EPS) return 0; if (a>b) return 1; else return -1;}struct Dat{ int a,b,d;
2014-01-06 00:53:01 835
原创 SGU 180 Inversions 逆序数
--------------int n;int a[maxn];int b[maxn];struct BIT{ int n; int tree[maxn]; void init(int n){ this->n=n; memset(tree,0,sizeof(tree)); } int lowbit(int x){
2014-01-05 19:38:20 586
原创 SGU 271 Book Pile 双端队列
------------int n,m,k;dequeque;vectorans;char cmd[22],c[4];;int bit;int main(){ scanf("%d%d%d",&n,&m,&k); que.clear(); ans.clear(); for (int i=0;i<n;i++){ scanf("%s",c);
2014-01-05 13:23:12 765
CSDN博客导出器2014/8/22
2014-08-22
(键)脑操语言解释器 brainfuck
2014-07-04
【Java】推箱子小游戏
2014-01-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人