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();
|
2009-07-10 15:04
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){
|
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);
|
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 |
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 |
2009-07-10 11:01
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) |
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(){
|
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: |
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)){ |
2009-07-09 20:34
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++;
|
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 |
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(){
} |
|
| |