- 博客(54)
- 资源 (7)
- 问答 (1)
- 收藏
- 关注
原创 UOJ#8. Quine
这道题,主要考察输出能力。 大家不会做很正常,大家可以看看题解,取取思路,注意:putchar(10); == putchar('\n');//即输出回车putchar(34); == putchar('"');//即输出"不说废话 题解
2017-02-14 20:48:57 2684
原创 USACO1.1题解集
beads/*ID:hh826532PROB:beadsLANG:C++*/#define _FILE_ "beads"#include<iostream>#include<stdio.h>#include<algorithm>#include<string.h>#include<math.h>#include<vector>#include<map>#include<st
2017-01-15 19:53:08 350
原创 左偏树讲解
左偏树,就是可并堆 效率: - 左偏树 堆 插入 O(log n) O(log n) 删除 O(log n) O(log n) 合并 O(log n) O(nlog n) 查询 O(1) O(1)合并不是一个级别的!!!
2016-11-16 18:22:15 374 1
原创 URAL 1876 Centipede's Morning[数论]
题意:一只蜈蚣有40条左腿和40条右腿。它有a只左鞋和b只右鞋。穿一只左鞋2s,穿一只右鞋1s,扔鞋1s。问给所有脚都穿上鞋最坏需要多长时间。第一种最坏情况很明显,就是把右脚的鞋子全穿一遍,然后再穿完左脚,耗时2b+40。第二种情况,先穿完左脚,再穿完右脚?不不不,还有更糟糕的情况,先给右脚穿好39只,耗时39*2,然后给左脚穿完鞋子,耗时40,再给右脚最后一只脚穿,把剩下的左脚鞋子都上一遍,耗时2
2016-11-14 20:31:41 304
原创 POJ3612Telephone Wire[DP]
Telephone WireTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3187 Accepted: 1113DescriptionFarmer John's cows are getting restless about their poor telephone service; they want F
2016-09-16 15:15:40 354
原创 偶数幻方
#include<iostream>#include<algorithm>#include<stdio.h>#include<string.h>using namespace std;#define fr(i,a,b) for(int i=a,i_end=b;i<=i_end;i++)#define mem(a,x) memset(a,x,sizeof(x))#define fd(i,
2016-08-08 10:48:02 482
原创 POJ2395Out of Hay[Check set]
#include<iostream>#include<algorithm>#include<stdio.h>#include<string.h>using namespace std;#define fr(i,a,b) for(int i=(a),i_end=(b);i<=i_end;i++)#define frd(i,a,b) for(int i=(a),i_end=(b);i>=i_
2016-08-04 09:51:53 289
原创 POJ2225Asteroids![Depth first search]
3 dimensional Depth frist search#include<stdio.h>#include<queue>#include<iostream>#include<string.h>using namespace std;char s[10];int f[20][20][20],p[20][20][20],x1,x2,y1,y2,z1,z2,i,j,n;void df
2016-08-04 09:26:45 366
原创 luogu1146
#include<bits/stdc++.h>#define fr(i,a,b) for(int i=(a),i_end=(b);i<=i_end;i++)#define frd(i,a,b) for(int i=(a),i_end=(b);i>=i_end;i--)#define ll long long#define pri(x) printf("%d",x)#define mes(x
2016-08-04 08:22:22 250
原创 POJ2044[Deep search]
State with int storage, but to use bit operation, so the code is simple and many. Code:#include<iostream>#include<stdio.h>#include<algorithm>#include<string.h>#define fr(i,a,b) for(int i=(a),i_en
2016-08-03 15:37:20 393
原创 acdream1020The Game about KILL结题报告[约瑟夫问题]
一开始只知道是约瑟夫问题,打野就是隔一个fly一个,求最后那个,可是我O(n) O(n)速度不是开玩笑,后来,我问到了一个O(logn) O(logn)的方法,不过只对隔1杀1有效#include<bits/stdc++.h>using namespace std;int n,k;int main(){ while(cin>>n){ k=1; while
2016-07-18 15:33:16 511
原创 被玩坏的题目——A+B Problem
普通方法:C++:#include<iostream>using namespace std;int a,b;int main(){ cin>>a>>b; cout<<a+b; return 0;}C:#include<stdio.h>int a,b;int main(){ scanf("%d%d",&a,&b); printf("%d",a
2016-07-18 09:36:28 9527 2
原创 树状数组点修改+段求值
#include<bits/stdc++.h>using namespace std;int n,m,x,y,z,i,s,f[100001];int main(){ scanf("%d%d",&n,&m); for(i=1;i<=m;i++){ scanf("%d%d%d",&x,&y,&z); if(x==1) whil
2016-07-16 16:13:32 340
原创 C++小游戏——走迷宫
大家想不想成名,那就一步步来吧,先写一些小游戏热热身。 下载地址 主程序代码:#include<conio.h>#include<stdlib.h>#include<time.h>#include<string.h>#include<windows.h>#include<iostream>using namespace std;char pr[10]={1,' ','E','O'}
2016-07-15 11:53:49 35804 4
原创 NOIP2011铺地毯题解
NOIP2011铺地毯博主第一眼,好坑,10000*10000,时间不说,空间就MLE了,于是我写下了以下代码#include<bits/stdc++.h>using namespace std;int n,i,ans,x1[10010],x2[10010],y3[10010],y2[10010],x,y;int main(){ scanf("%d",&n); for(i=1;
2016-07-14 14:47:58 2981 2
原创 P1084 疫情控制
哎,我只能得60分。# < / . >using namespace std;int (){ int , ; cin>> ; char [ ]; for(int = ; < ; ++) gets( ); cin>> ; int = * + ; if( == )
2016-07-07 15:45:52 602
原创 逆序对nlogn做法
原理#include<bits/stdc++.h>using namespace std;struct node{ int w,v;}a[50001];int cmp(node a,node b){ return a.w<b.w;}int n,i,x,s,ans,c[80001];int main(){ scanf("%d",&n); for(i=1;i
2016-07-07 11:23:38 372
原创 NOIP2012 Vigenère 密码
上图大家看着是不是有写晕? 上图的转换其实非常简单 万能公式:M=C-K+1 ,M<'A' M+=26C=M+K-1 ,C>'Z' C-=26接着就是代码了(无视char*+string,开始没有string,后来因为%错了,就改为string存K)#include<bits/stdc++.h>using namespace std;int i;char s1[2001];stri
2016-07-05 16:55:59 400
原创 手写vector
因为不会构造函数,所以请在使用时先init一下。#include<bits/stdc++.h>using namespace std;class array{ public: void push_back(int x){ last->count=x; k=last; last=new unit;
2016-06-22 14:04:14 696
原创 手写queue
#include<bits/stdc++.h>using namespace std;class myqueue{ public: void push(int x){ r++; a.push_back(x); } void pop(){ if(l<=r)l++;
2016-06-21 15:44:28 368
原创 手写stack[加强版]
#include<bits/stdc++.h>using namespace std;class stac{ public: void push(int x){ a.push_back(x); len++; } void pop(){ len--;
2016-06-21 15:16:33 291
原创 POJ3283Card Hands
#include<iostream>#include<algorithm>#include<stdio.h>#include<cstring>#include<map>using namespace std;int ma[151];int ma2[151];int o,d,i,j,k[100001],n,m,a[100001][60];char s[5];int main(){
2016-06-20 17:40:54 395
原创 POJ3630Phone List[字典树]
题目大意 给你一些字符串,看有没有有字符串是其它任意一个的前缀#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;struct node{ int p1,p2; int c[10];}a[50010];int t,o,i,d,j,fla
2016-06-16 14:09:36 194
原创 POJ2406Power Strings[KMP]
给出一个串,问你这个最多是多少个相同的字串重复连接而成的。#include <cstdio>#include <cstring>using namespace std;char s[1000005];int next[1000005],i,j,l;int main(){ while(scanf("%s",&s)){ if(strcmp(s,".")==0)retu
2016-06-15 16:39:15 201
原创 POJ3461Oulipo[KMP]
题目大意 给你两个字符串,给出第一个在第二个字符串中的出现次数,注意,有多组数据。 Time Limit: 1000MS Memory Limit: 65536K 经典KMP(貌似不是的)题目,十分容易。#include <cstdio>#include <cstring>using namespace std;int t,i,j,next[1000010],an
2016-06-15 16:14:23 206
原创 NOIP2015提高组第二题信息传递[图论]
这道题我一开始做感觉没有任何思路,但一开始就觉得是图论,就在思考用邻接矩阵还是链式前向星,可是邻接矩阵每判断一次就是$O(n^2)$,在次数最多是链式前向星空间复杂度达$O(n^2)$,直接爆空间,后来仔细一想,传回来就是一个环,所以可以先把不可能的人踢了,然后就直接找所有环中最小的那个。
2016-06-12 13:52:08 2170
原创 POJ3342Party at Hali-Bula[树状DP]
http://poj.org/problem?id=3342 题目大意: 一个公司,其中第一个输入的人是老大,给你从属关系,一个人不能和一个与他(她)有直接关系的人一起加入一个晚会,问:最多有几个人参加,参加舞会的人唯不唯一? 简单树形DP,附上map和vector就容易了#include <cctype>#include <cerrno>#include <cfloat>#includ
2016-06-11 20:20:45 200
原创 POJ1463Strategic game[树形DP]
题目大意是: 有一颗树,n个节点,问,最少用几个点,让所有的点与它们中任意一个相邻#include <cctype>#include <cerrno>#include <cfloat>#include <ciso646>#include <climits>#include <clocale>#include <cmath>#include <csetjmp>#include <cs
2016-06-11 16:04:38 215
原创 POJ2486Apple tree题解
题目地址:Apple tree 题目大意: 有一个树,n个节点,第一个节点为根节点,每个点都有一个权值,每个点都可以移动到相邻的点,给你树的链接情况,求出,走k步最多获得多少权值? 输入(多数据,EOF结束): n,k w1 w2 w3……wn 以下n-1行,表示哪两个点相连。 输出: 最大值 思路:简单的树形DP#include <cctype>#include <cerrno
2016-06-11 11:33:14 444
原创 高精度算法
加法#include<stdio.h>#include<string.h>int la,lb,i,j=0,lm,n;char a[501],b[501],c[502];int main(){ gets(a); gets(b); la=strlen(a); lb=strlen(b); lm=la>lb?la:lb; for(i=1;i<=lm;
2016-06-10 14:16:00 321
原创 01背包问题
一维背包问题:采药 这是一个典型的背包问题,动态规划分分钟解决#include<bits/stdc++.h>using namespace std;int n,m,i,j,t[10001],f[10001],w[10001],ans;int main(){ cin>>n>>m; for(i=1;i<=m;i++) cin>>t[i]>>w[i]; fo
2016-06-10 14:12:55 184
原创 sscanf&sprintf讲解
sscanf&sprintf都是针对char*的函数,和输入输出差不多只不过: sscanf(char*,char*,…); sprintf(char*,char*,…); 也就是说:sscanf&sprintf是从一个字符串里读入,输出也是输出到字符串中。 如:#include<bits/stdc++.h>using namespace std;int main(){ char
2016-06-10 11:55:57 257
CE在runtime error时怎么办?
2016-08-02
TA创建的收藏夹 TA关注的收藏夹
TA关注的人