摘要: 用了STL_algorithm中的permution,很好很強大! 閱讀全文
摘要: 自己寫了一個,不過貼一個Waterloo的標程,突然喜歡上這種風格了,求最短路的! 閱讀全文
摘要: wa的不行,改了又改,亂套了,最后重寫ac了! 閱讀全文
































































測試結果:
8
2 1
3 2
2 4
5 4
7 8
1 8
8 3
3 6
4 8
4 6
0 0
Can't do it
8
2 1
2 3
2 4
5 4
7 8
1 8
3 8
3 6
4 8
4 6
0 0
2 1 3 5 4 6 7 8
摘要: 幾何題,高中數學,告誡自己細心一點兒,耐心一點兒! 閱讀全文
我就叫他射線法吧
基本步驟:
1,過p點垂直向上作一條射線
2,判斷此射線與n邊形n條邊的交點
3,把所有交點相加,如果是奇數則說明在多邊形內,否則在多邊形外
思路非常的簡單,另外說明一下幾種特殊的情況:
1,射線與多邊形的頂點相交;比如射線過多邊形的Pi點,則如果Pi-1和Pi+1在此射線的異側,此交點可以算一個,如果此兩點在射線的同側,則此交點不計。此結論非常簡單,畫個圖應該就能明白了
2,p點在多邊形的某一條邊上;也認為p在多邊形中
3,p不在多邊形的邊上,但p的射線與多邊形的某一條邊重合;比如與Pi,Pi+1線段重合,則如果Pi-1和Pi+2在射線的兩側,此情況也算一個交點,否則此情況不計交點
摘要: 網上看到的spfa的實現,很清晰。Orz~~
#include <cstdio>#include <cstring>const int maxn = 10000+1;const int maxnm = 100000+1;class node { ... 閱讀全文
這里有對全排列函數permutation的介紹http://hi.baidu.com/sunshine_0316/blog/item/6f87a044bf30f320cffca381.html
#include<iostream>
#include<map>
#include<algorithm>

using namespace std;

typedef struct node


{
char ch;
int flag;
}node;

bool cmp(const node a,const node b)


{
return a.flag<b.flag;
}

int main()


{
int cas,i;
char str[15],ch;
map<char,int> mp;
for(ch='A',i=1;ch<='Z';ch++,i=i+2) mp[ch]=i;
for(ch='a',i=2;ch<='z';ch++,i=i+2) mp[ch]=i;
scanf("%d",&cas);
while(cas--)

{
scanf("%s",str);
int len=strlen(str);
node p[15];
for(i=0;i<len;i++)

{
p[i].ch=str[i];
p[i].flag=mp[str[i]];
}
sort(p,p+len,cmp);
do

{
for(i=0;i<len;i++)
printf("%c",p[i].ch);
printf("\n");
}while(next_permutation(p,p+len,cmp));
}
return 0;
}



























































