|
邮箱是很重要的工具,我使用QQ邮箱,除了在寝室网通连接过慢一直都很好用,呵呵,希望越做越好。 Blog验证码: QQREADER8A9ED325C16B65D5
CTRL+ALT+D
若想更改成windows的习惯 如下操作:
首先打开终端输入: gconf-editor 到“Apps->Metacity->Global keybingdings" 出找 “show desktop”编辑值为<Super>d 即可。 还可以修改其他相应键值,或者自定义快捷键详见[url]http://www.wangchao.net.cn/bbsdetail_1786773.html[/url]
在ubuntu 8.04里安装java后,会发现所有java的gui都会乱码,这是因为在ubuntu 8.04里uming.ttf变成了uming.ttc,而ubuntu里java默认的中文字体就是uming.ttf,所以只要获得它就可以了,比如:
sudo ln -s /usr/share/fonts/truetype/arphic/uming.ttc /usr/share/fonts/truetype/arphic/uming.ttf
优化1:求最大匹配时候先能匹配就匹配上。 优化2:标记已经确定不是必要点的行和列 flag[]和flag2[] 注意1:删除匹配边后 应在匹配边的两面点 分别查询 注意2:没查到新匹配要还原匹配边 #include<stdio.h> #include<string.h> const int size2 = 100110; const int size1 = 10110; int n , m , k ; struct node{ node *p; node *q; int v; int v2; }; int val;
node edg[size2];
bool visit[size1]; int pp[size1]; bool flag[size1]; bool flag2[size1];
node *g[size1]; node *g1[size1];
int ppre[size1]; int ppr[size1];
int nxy[size1]; inline bool check(int x , int y , int fc){ node *now = g[x]; while(now != NULL){ if(now->v == y){ if(fc == 0) return true; if(fc == 1){ now->v = -1; return true; } if(fc == 2){ now->v = val; return true; } } else{ now = now->p; } } return false; }
inline bool check2(int x , int y , int fc){ node *now = g1[x]; while(now != NULL){ if(now->v2 == y){ if(fc == 0) return true; if(fc == 1){ now->v2 = -1; return true; } if(fc == 2){ now->v2 = val; return true; } } else{ now = now->q; } } return false; } inline bool find(int a){ node *now = g[a]; while(now != NULL){ int i = now->v; if(i != -1){ if(!visit[i] ){ visit[i] = true; if(pp[i] == -1 ||find(pp[i])){ pp[i] = a; nxy[a] = i; return true; } } } now = now->p; } return false; }
inline bool find2(int a){ node *now = g1[a]; while(now != NULL){ int i = now->v2; if(i != -1){ if(!visit[i] ){ visit[i] = true; if(nxy[i] == -1 ||find2(nxy[i])){ nxy[i] = a; pp[a] = i; return true; } } } now = now->q; } return false; }
void output(){ printf("\n\n"); for( int i = 1 ; i <= m ; i++) printf("%d -> %d\n",pp[i],i); printf("\n"); for( int i = 1 ; i <= n ; i++) printf("%d -> %d\n",i,nxy[i]); printf("\n\n"); }
void output1(int x){ node *now = g1[x]; while(now != NULL){ int i = now->v2;
printf(" %d",i); now = now->q; } printf("\n"); }
int main(){ int a1,i,a2; int _case = 0; int num; while(scanf("%d%d%d",&n,&m,&k)!=EOF){ num = 0; memset(g,0,sizeof(g)); memset(g1,0,sizeof(g1)); memset(pp,-1,sizeof(pp)); memset(nxy,-1,sizeof(nxy)); for(i = 1; i <= k ; i++){ scanf("%d%d",&a1,&a2); if(check(a1,a2,0)) continue; edg[i].v = a2; edg[i].v2 = a1; edg[i].p = NULL; edg[i].q = NULL;
if(g[a1] == NULL){ g[a1] = &edg[i]; }else{ edg[ppre[a1]].p = &edg[i]; }
if(g1[a2] == NULL){ g1[a2] = &edg[i]; }else{ edg[ppr[a2]].q = &edg[i]; }
ppre[a1] = i ; ppr[a2] = i ;
if(pp[a2] == -1 && nxy[a1] == -1){ pp[a2] = a1; nxy[a1] = a2; num++; } } for(i = 1 ; i <= m ; i++){ if(pp[i] == -1){ memset(visit,0,sizeof(visit)); if(find2(i)){ num++; } } } memset(flag,0,sizeof(flag)); memset(flag2,0,sizeof(flag2)); int ans = 0; for(i = 1 ; i <= m ; i++){ if(pp[i] != -1){ int key = 0; int now = pp[i]; pp[i] = -1 ; nxy[now] = -1; if(flag[pp[i]] == 0){ check(now,i,1); memset(visit,0,sizeof(visit)); if(find(now)){ key = 1; } val = i ; check(now,-1,2); }
if(flag2[i] == 0 && key == 0 ){ check2(i,now,1); memset(visit,0,sizeof(visit)); if(find2(i)){ key = 1; } val = now ; check2(i,-1,2); } if(!key){ ans++; nxy[now] = i; pp[i] = now; } else{ flag[now] = 1 ; flag2[i] = 1 ; } }//右侧有边 } printf("Board %d have %d important blanks for %d chessmen.\n",++_case,ans,num); } return 0; }
/*Tju 3207. Sand Castle http://acm.tju.edu.cn/toj/showp3207.html 排序后贪心,贪心的正确性证明很简单,只要匹配出现交叉则浪费 */ #include<stdio.h> #include<algorithm> using namespace std; int na[25001]; int nb[25001];
int cmp(int x , int y){ return x < y; }
int main(){ int n , h1, h2 ; scanf("%d%d%d",&n,&h1,&h2); for(int i = 0 ; i < n ; i++) scanf("%d%d",&na[i],&nb[i]); sort(na,na+n,cmp); sort(nb,nb+n,cmp);
int sum = 0; for(int i = 0 ; i < n ; i++){ if(na[i] > nb[i]){ sum += h2 * (na[i] - nb[i]); } else{ sum += h1 * (nb[i] - na[i]); } } printf("%d\n",sum); return 0; }
/* TJU 3209. Look Up http://acm.tju.edu.cn/toj/showp3209.html 自底而上扫,纪录结果,以纪录跳转的方式优化时间 */ #include<stdio.h> int a[100001]; int ans[100001]; int now; int main(){ int n; scanf("%d",&n); for(int i = 0 ; i <n ; i++){ scanf("%d",&a[i]); } ans[n-1] = -1 ; for(int i = n - 2 ; i >= 0 ; i--){ if(a[i]<a[i+1]){ ans[i] = i + 1; } else{ now = i + 1; while(1){ if(now == -1 ){ if(a[now] > a[i]) ans[i] = now; else ans[i] = -1 ; break; }
if(a[now] > a[i] ) { ans[i] = now; break; } else{ now = ans[now]; }
}
} } for(int i = 0 ; i < n ; i++) printf("%d\n",ans[i]+1);
return 0; }
/**//* TJU 3208. Cow Frisbee Team http://acm.tju.edu.cn/toj/showp3208.html DP 控制取与不取更新更大的值 dp的两维分别代表取用前i个cow 和 余数大小 */
#include<stdio.h> const int MOD=100000000; int a[2001]; int n , f; int dp[2001][1001]; int main(){ scanf("%d%d",&n,&f); for(int i = 0 ; i < n ; i++){ scanf("%d",&a[i]); }
dp[0][0] = 1; for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < f ; j++){ dp[i+1][j] += dp[i][j] % MOD; dp[i+1][(j+a[i])%f] += dp[i][j] % MOD; } } printf("%d\n",(dp[n][0]-1)%MOD); return 0 ; }
1 #include<string.h> 2 #include<stdio.h> 3 #include<algorithm> 4 using namespace std; 5 6 7 struct edg{ 8 int x ; 9 int y ; 10 int len; 11 }a[200000]; 12 int flag[200000]; 13 int cmp (edg aa ,edg bb){ 14 return aa.len<bb.len; 15 } 16 17 int find(int pot){ 18 if(flag[pot] == -1){ 19 return pot; 20 } 21 else{ 22 return flag[pot] = find(flag[pot]); 23 } 24 } 25 void Union(int p1 , int p2){ 26 flag[find(p2)] = find(p1); 27 } 28 29 int add(edg t){ 30 // printf("t.x t.y %d %d\n",t.x,t.y); 31 if( find(t.x) != find(t.y)){ 32 Union(t.x,t.y); 33 // printf("f.x f.y %d %d\n",flag[t.x],flag[t.y]); 34 return t.len; 35 } 36 else{ 37 return 0; 38 } 39 } 40 41 int n , m; 42 int main(){ 43 while(1){ 44 scanf("%d%d",&n,&m); 45 int sum1 = 0; 46 if(n == m && m == 0) break; 47 memset(flag,-1,sizeof(flag)); 48 for(int i = 0 ; i < m ; i++){ 49 scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].len); 50 sum1 += a[i].len; 51 } 52 sort(a,a+m,cmp); 53 int ans = 0; 54 int sum = 0; 55 for(int i = 0 ; i < m ; i++){ 56 if(ans == n+1 ) break; 57 // printf("ans a[i] %d %d %d\n",a[i].x,a[i].y,a[i].len); 58 int now = add(a[i]); 59 if(now){ 60 sum += now; 61 ans++; 62 } 63 } 64 printf("%d\n",sum1-sum); 65 } 66 return 0; 67 } 68
摘要: WA 了很多次...有几个小细节需要处理就是读入数据 控制精度 判断闰年 还有最重要的是理解清楚题意。。。
1#include<stdio.h> 2#define SIZE 400 3 4int flag , flag2;&nbs... 阅读全文
摘要: 由每个最末的状态(n,n,n)推得所有可行的状态,并记录被推得状态的来源和步长,类似筛法的方式,没有被扩展到的情况即无法到达的情况,标记其步长仍为0.
1#include<stdio.h> 2#include<string.h> 3 4struct Q{ &nbs... 阅读全文
摘要: 呵呵 过了这个题目挺高兴锻炼了 筛法和判断素数的能力还想了一个关键的枚举剪枝这个题目我是去枚举题目中的A和第一个素数P1;然后计算B 幷继续推Pn对小于1000000的数一次性筛出;大数用最基本的判断的方式。
1Source Code 2 3Problem: 3005 User:&nbs... 阅读全文
|