百度空间 | 百度首页 
               
 
文章列表
 
2009-07-10 16:07

网络流

if (ret>0){
     used[i]=false;//ret >0 才有可能贡献流量 , 可以继续访问
     cap[nd][i]-=ret;
     cap[i][nd]+=ret;
     return ret;
    }

很精妙 , 放在if 外 就会TLE

//start


#include <stdio.h>
#include <string.h>
const int SIZE = 220;
const int INF = 10000010;
int cap[SIZE][SIZE];
void init();

类别:Oj | 评论(0) | 浏览()
 
2009-07-10 15:04

最大匹配==最小覆盖

类别:Oj | 评论(0) | 浏览()
 
2009-07-10 14:39
#include <stdio.h>
const int SIZE =100;
int dat[SIZE];
int main(){
int n;
while (scanf("%d",&n)!=EOF){
   if (n==0)
    break;
   int i;
   for (i=1;i<=n;i++){
    scanf("%d",&dat[i]);
   }
   int ep=n,sp=1;
   int etot=0 , stot=0;
   while (true){
    if (etot == stot){
 
类别:Oj | 评论(0) | 浏览()
 
2009-07-10 14:06

二分匹配

//start

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
using namespace std;
const int SIZE = 400;
vector<int> li[SIZE];
int mat[SIZE];
bool used[SIZE];
int p,n;
void init();
int edmonds();
bool dfs(int );
int main(){
int cas=0;
scanf("%d",&cas);
while (cas--){
   scanf("%d%d",&p,&n);
 

类别:Oj | 评论(0) | 浏览()
 
2009-07-10 13:21

//格式控制要注意

//start

/*
ID: yjyfrom1
PROG: hamming
LANG: C++
*/

#include <stdio.h>
const int SIZE = 100;
int dat[SIZE];
int N, B, D;
int sz;
int ones(int);
bool check(int);
void showans();
int main(){
freopen("hamming.in","r",stdin);
freopen("hamming.out","w",stdout);
scanf("%d%d%d",&N, &B, &D);
sz=0;
dat[sz++] = 0;
in

类别:Oj | 评论(0) | 浏览()
 
2009-07-10 11:40

二进制枚举

//start

/*
ID: yjyfrom1
PROG: holstein
LANG: C++
*/

#include <stdio.h>
#include <string.h>
const int SIZE = 40;
const int INF =10000;
int aim[SIZE];
int dat[SIZE][SIZE];
void init();
int hi,wi;
void show(int );
int work();
bool check(int );
int ones(int);
int main(){
freopen("holstein.in","r",stdin);
freopen("holstein.out","w",std

类别:Oj | 评论(0) | 浏览()
 
2009-07-10 11:01

类别:Oj | 评论(0) | 浏览()
 
2009-07-10 10:18

用链表时 加上delete 能省很多内存 ,还会省一点时间

//start

// tju2310.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
const int SIZE = 200010;
char cmd[SIZE];
int n;
class Node{
public:
int up,down;
Node * next;
Node(){
   up=down=1;
   next=NULL;
}
Node(int u ,int d){
   up=u;
   down=d;
}
};
Node * work(int sp)

类别:Oj | 评论(0) | 浏览()
 
2009-07-10 08:31
//start
/*
    f[i]=min(f[i-sqr(j)])+1 ; sqr(j)<i
    选择性的更新 , 值《=4
*/

#include <stdio.h>
const int SIZE = 60010;
int dat[SIZE];
void init();
int main(){
    init();
    int n;
    scanf("%d",&n);
    printf("%d\n",dat[n]);
    return 0;
}
void init(){
  
类别:Oj | 评论(0) | 浏览()
 
2009-07-09 23:43

spfa 很好用

//start

#include <stdio.h>
#include <string.h>
const int LEN = 10000;
const int SIZE = 100;
const int CK = 10;
const int INF = 10000000;
bool map[SIZE][SIZE];
int que[LEN];

class Inter{
public:
int ip ,mask,gw;
void mkhost(){
   gw = ip&mask;
}
void show(){
   printf("ip: %X mask: %X gw: %X \n",ip ,mask,gw);
}
};
class Node{
public:

类别:Oj | 评论(0) | 浏览()
 
2009-07-09 21:35

枚举进制 ,

用vector 超时!

//start

#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
bool check(int ,int ,int );
const int SIZE = 1000;
int lx[SIZE];
int ly[SIZE];
int mk(int ,int ,int * ret);
void show(int * ,int);
int main(){
int x,y;
scanf("%d%d",&x,&y);
int k;
bool ok=false;
for (k=2;k<=x+1;k++){
   if (check(x,y,k)){

类别:Oj | 评论(0) | 浏览()
 
2009-07-09 20:34

类别:Oj | 评论(0) | 浏览()
 
2009-07-09 16:45

试两次就行

//start

#include <stdio.h>
#include <string.h>
const int SIZE = 500;
int main(){
char sa [SIZE],sb[SIZE];
while (scanf("%s%s",sa,sb)!=EOF){
   int i=0,j=0;
   char ans1[SIZE];
   char ans2[SIZE];
   int t=0;
   while (1){
    if (sa[i]==sb[j]){
     ans1[t++]=sa[i];
     i++;

类别:Oj | 评论(0) | 浏览()
 
2009-07-09 16:08

千年不遇的水题

//start

#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
int a=1;
int b=n;
if (a>b){
   int t=a;
   a=b;
   b=t;
}
//printf("%d %d\n",a,b);
int ans = (a+b)*(b-a+1)/2;
printf("%d\n",ans);
}

//end

类别:Oj | 评论(0) | 浏览()
 
2009-07-09 15:31

用set 排序有问题

最后整理一次就行

//start

// ural1067.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
const int SIZE = 100;
const int LEN = 600;
string dat[LEN];

class Dir{
public:
string name;
vector<Dir *> child;
Dir(){
}

类别:Oj | 评论(0) | 浏览()
 
     
 
 
文章分类
 
 
随笔(31)
 
 
Vs(10)
 
Java(88)
 
Vfp(10)
 
Css(8)
 
 
Python(26)
 
c#(36)
 
 
c/c++(19)
 
 
Php(23)
 
Bt(1)
 
Spoj(9)
 
Usaco(19)
 
Ai(19)
 
Ruby(6)
 
 
C51(25)
 
Lua(4)
 
 
Asm(42)
 
 
Oj(168)
 
Noip(10)
 
Google(25)
 
Jsp(4)
 
 
Qt(6)
 
Opengl(12)
 
 
 
Vrml(1)
 
 
Flex(16)
 
     
 
文章存档
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
     
 
最新文章评论
   

fgsdg
 

Orz
 

[表情]
 
 

tmp.isapp=true; 这个是什么?
 
     


©2009 Baidu