青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

superman

聚精會神搞建設 一心一意謀發展
posts - 190, comments - 17, trackbacks - 0, articles - 0
   :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

 1 /* Accepted 1119 C++ 00:00.03 1832K */
 2 #include <iostream>
 3 
 4 using namespace std;
 5 
 6 const int N = 1001;
 7 
 8 int maxTo; bool map[N][N];
 9 int low[N], visited[N], subset[N], cnt;
10 
11 void dfs(int u)
12 {
13     low[u] = visited[u] = ++cnt;
14     for(int v = 1; v <= maxTo; v++)
15         if(map[u][v])
16         {
17             if(visited[v] == 0)
18             {
19                 dfs(v);
20                 low[u] <?= low[v];
21                 if(low[v] >= visited[u])
22                     subset[u]++;
23             }
24             else
25                 low[u] <?= visited[v];
26         }
27 }
28 
29 int main()
30 {
31     int s, t, network = 0;
32     cin >> s;
33     while(s)
34     {
35         maxTo = 0, cnt = 0;
36         memset(map, falsesizeof(map));
37         memset(low, 0sizeof(low));
38         memset(visited, 0sizeof(visited));
39         memset(subset, 0sizeof(subset));
40         
41         if(s == 0)
42             break;
43         while(s)
44         {
45             cin >> t;
46             maxTo >?= s;
47             maxTo >?= t;
48             map[s][t] = true;
49             map[t][s] = true;
50             cin >> s;
51         }
52         
53         dfs(1);
54         if(subset[1])
55             subset[1]--;
56         cout << "Network #" << ++network << endl;
57         bool flag = false;
58         for(int i = 1; i <= maxTo; i++)
59             if(subset[i])
60             {
61                 flag = true;
62                 cout << "  SPF node " << i << ' '
63                      << "leaves " << subset[i] + 1 << " subnets" << endl;
64             }
65         if(flag == false)
66             cout << "  No SPF nodes" << endl;
67         cin >> s;
68         if(s)
69             cout << endl;
70     }
71     
72     return 0;
73 }
74 

posted @ 2008-04-09 09:32 superman 閱讀(320) | 評論 (0)編輯 收藏

 1 /* Accepted 0.001 196 KB */
 2 #include <iostream>
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     int n, k;
 9     unsigned long long cnt[20][2= {0};
10     
11     cin >> n >> k;
12     cnt[1][1= k - 1;
13     for(int i = 2; i <= n; i++)
14     {
15         cnt[i][0= cnt[i - 1][1];
16         cnt[i][1= (cnt[i - 1][0+ cnt[i - 1][1]) * (k - 1);
17     }
18     cout << cnt[n][0+ cnt[n][1<< endl;
19     
20     return 0;
21 }
22 

posted @ 2008-04-08 15:52 superman 閱讀(316) | 評論 (0)編輯 收藏

 1 /* Accepted 1.968 204 KB */
 2 #include <string>
 3 #include <iostream>
 4 
 5 using namespace std;
 6 
 7 int main()
 8 {
 9     int n;
10     cin >> n;
11     string word;
12     while(cin >> word)
13     {
14         if(word.size() == n - 1)
15             for(int i = 0; i < n; i++)
16             {
17                 int sum = 0;
18                 for(int j = 0;j < i; j++)
19                     sum += (word[j] == '1' ? j + 10);
20                 for(int j = i; j < n - 1; j++)
21                     sum += (word[j] == '1' ? j + 20);
22                 if(sum == 0 || sum % (n + 1== 0 || (sum + i + 1% (n + 1== 0)
23                 {
24                     for(int j = 0;j < i; j++)
25                         cout << word[j];
26                     cout << (sum % (n + 1== 0 ? '0' : '1');
27                     for(int j = i; j < n - 1; j++)
28                         cout << word[j];
29                     cout << endl;
30                     break;
31                 }
32             }
33         if(word.size() == n)
34         {
35             for(int i = 0; i < n; i++)
36                 if(word[i] == '1')
37                 {
38                     int sum = 0;
39                     word[i] = '0';
40                     for(int j = 0; j < n; j++)
41                         sum += (word[j] == '1' ? j + 1 : 0);
42                     if(sum == 0 || sum % (n + 1== 0)
43                         break;
44                     word[i] = '1';
45                 }
46             cout << word << endl;
47         }
48         if(word.size() == n + 1)
49             for(int i = 0; i < n + 1; i++)
50             {
51                 int sum = 0;
52                 for(int j = 0; j < i; j++)
53                     sum += (word[j] == '1' ? j + 1 : 0);
54                 for(int j = i + 1; j < n + 1; j++)
55                     sum += (word[j] == '1' ? j : 0);
56                 if(sum == 0 || sum % (n + 1== 0)
57                 {
58                     for(int j = 0; j < i; j++)
59                         cout << word[j];
60                     for(int j = i + 1; j < n + 1; j++)
61                         cout << word[j];
62                     cout << endl;
63                     break;
64                 }
65             }
66     }
67     
68     return 0;
69 }
70 

posted @ 2008-04-08 14:20 superman 閱讀(261) | 評論 (0)編輯 收藏

  1 /* Accepted 0.015 212 KB */
  2 #include <queue>
  3 #include <cctype>
  4 #include <string>
  5 #include <iostream>
  6 
  7 using namespace std;
  8 
  9 struct pixel { int x, y; };
 10 
 11 int main()
 12 {
 13     int n, x, y;
 14     bool map[12][12= {false};
 15     
 16     cin >> n;
 17     if(cin.get() == '\n')
 18     {
 19         int sx, sy;
 20         cin >> sx >> sy;
 21         cout << sx << ' ' << sy << endl;
 22         
 23         map[sx][sy] = true;
 24         while(cin >> x >> y)
 25             map[x][y] = true;
 26         
 27         pixel cur = {sx, sy};
 28         queue <pixel> q;
 29         q.push(cur);
 30         
 31         while(q.empty() == false)
 32         {
 33             n--;
 34             cur = q.front(); q.pop();
 35             map[cur.x][cur.y] = false;
 36             if(map[cur.x + 1][cur.y])
 37             {
 38                 cout << 'R';
 39                 map[cur.x + 1][cur.y] = false;
 40                 pixel tmp = {cur.x + 1, cur.y};
 41                 q.push(tmp);
 42             }
 43             if(map[cur.x][cur.y + 1])
 44             {
 45                 cout << 'T';
 46                 map[cur.x][cur.y + 1= false;
 47                 pixel tmp = {cur.x, cur.y + 1};
 48                 q.push(tmp);
 49             }
 50             if(map[cur.x - 1][cur.y])
 51             {
 52                 cout << 'L';
 53                 map[cur.x - 1][cur.y] = false;
 54                 pixel tmp = {cur.x - 1, cur.y};
 55                 q.push(tmp);
 56             }
 57             if(map[cur.x][cur.y - 1])
 58             {
 59                 cout << 'B';
 60                 map[cur.x][cur.y - 1= false;
 61                 pixel tmp = {cur.x, cur.y - 1};
 62                 q.push(tmp);
 63             }
 64             cout << (n ? ',' : '.'<< endl;
 65         }
 66     }
 67     else
 68     {
 69         int x = n, y, cnt = 0; cin >> y;
 70         pixel cur = {x, y};
 71         
 72         queue <pixel> q;
 73         q.push(cur);
 74         
 75         string s;
 76         while(q.empty() == false)
 77         {
 78             cnt++;
 79             cin >> s;
 80             cur = q.front(); q.pop();
 81             map[cur.x][cur.y] = true;
 82             for(int i = 0; isalpha(s[i]); i++)
 83             {
 84                 if(s[i] == 'R')
 85                 {
 86                     pixel tmp = {cur.x + 1, cur.y};
 87                     q.push(tmp);
 88                 }
 89                 if(s[i] == 'T')
 90                 {
 91                     pixel tmp = {cur.x, cur.y + 1};
 92                     q.push(tmp);
 93                 }
 94                 if(s[i] == 'L')
 95                 {
 96                     pixel tmp = {cur.x - 1, cur.y};
 97                     q.push(tmp);
 98                 }
 99                 if(s[i] == 'B')
100                 {
101                     pixel tmp = {cur.x, cur.y - 1};
102                     q.push(tmp);
103                 }
104             }
105         }
106         cout << cnt << endl;
107         for(int i = 1; i <= 10; i++)
108         for(int j = 1; j <= 10; j++)
109             if(map[i][j])
110                 cout << i << ' ' << j << endl;
111     }
112     
113     return 0;
114 }
115 

posted @ 2008-04-08 13:05 superman 閱讀(384) | 評論 (0)編輯 收藏

Ural can not use <?= operator :(
 1 /* Accepted 0.031 200 KB */
 2 #include <iostream>
 3 
 4 using namespace std;
 5 
 6 int n, w[20], cnt, best = 0X7FFFFFFF;
 7 
 8 void search(int i, int sum)
 9 {
10     if(i == n)
11         return;
12     if(best > abs(cnt - 2 * sum))
13         best = abs(cnt - 2 * sum);
14     search(i + 1, sum);
15     search(i + 1, sum + w[i]);
16 }
17 
18 int main()
19 {
20     cin >> n;
21     for(int i = 0; i < n; i++)
22     {
23         cin >> w[i];
24         cnt += w[i];
25     }
26     search(00);
27     cout << best << endl;
28     
29     return 0;
30 }
31 

posted @ 2008-04-08 00:18 superman 閱讀(331) | 評論 (0)編輯 收藏

 1 /* Accepted 1103 C++ 00:00.08 1188K */
 2 #include <queue>
 3 #include <iostream>
 4 
 5 using namespace std;
 6 
 7 struct Rec { int p1, p2, p3, cnt; };
 8 
 9 int main()
10 {
11     int n, p1, p2, p3;
12     while((cin >> n) && n)
13     {
14         cin >> p1 >> p2 >> p3;
15         
16         char m[51][51];
17         for(int i = 1; i <= n; i++)
18             for(int j = 1; j <= n; j++)
19                 cin >> m[i][j];
20         
21         Rec cur = {p1, p2, p3, 0};
22         queue <Rec> rec;
23         rec.push(cur);
24         
25         bool isRepeat[51][51][51= {false};
26         isRepeat[p1][p2][p3] = true;
27         bool find = false;
28         
29         while(rec.empty() == false)
30         {
31             cur = rec.front(); rec.pop();
32             
33             if(cur.p1 == cur.p2 && cur.p2 == cur.p3)
34             {
35                 cout << cur.cnt << endl;
36                 find = true;
37                 break;
38             }
39             
40             for(int i = 1; i <= n; i++)
41                 if(cur.p1 != i && m[cur.p1][i] == m[cur.p2][cur.p3])
42                     if(isRepeat[i][cur.p2][cur.p3] == false)
43                     {
44                         isRepeat[i][cur.p2][cur.p3] = true;
45                         Rec tmp = {i, cur.p2, cur.p3, cur.cnt + 1};
46                         rec.push(tmp);
47                     }
48             for(int i = 1; i <= n; i++)
49                 if(cur.p2 != i && m[cur.p2][i] == m[cur.p1][cur.p3])
50                     if(isRepeat[cur.p1][i][cur.p3] == false)
51                     {
52                         isRepeat[cur.p1][i][cur.p3] == true;
53                         Rec tmp = {cur.p1, i, cur.p3, cur.cnt + 1};
54                         rec.push(tmp);
55                     }
56             for(int i = 1; i <= n; i++)
57                 if(cur.p3 != i && m[cur.p3][i] == m[cur.p1][cur.p2])
58                     if(isRepeat[cur.p1][cur.p2][i] == false)
59                     {
60                         isRepeat[cur.p1][cur.p2][i] = true;
61                         Rec tmp = {cur.p1, cur.p2, i, cur.cnt + 1};
62                         rec.push(tmp);
63                     }
64         }
65         if(find == false)
66             cout << "impossible" << endl;
67     }
68     
69     return 0;
70 }
71 

posted @ 2008-04-07 10:58 superman 閱讀(440) | 評論 (0)編輯 收藏

 1 /* Accepted 1152 C++ 00:00.32 836K */
 2 #include <iostream>
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     int N, n, m, Case = 0;
 9     
10     cin >> N;
11     while(N)
12     {
13         cin >> n >> m;
14         if(n == 0)
15         {
16             N--;
17             Case = 0;
18             if(N)
19                 cout << endl;
20             continue;
21         }
22         int count = 0;
23         for(int a = 1; a < n - 1; a++)
24             for(int b = a + 1; b < n; b++)
25                 if((a * a + b * b + m) % (a * b) == 0)
26                     count++;
27         cout << "Case " << ++Case << "" << count << endl;
28     }
29     
30     return 0;
31 }
32 

posted @ 2008-04-06 21:06 superman 閱讀(299) | 評論 (0)編輯 收藏

 1 /* Accepted 1113 C++ 00:00.00 832K */
 2 #include <iostream>
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     cout << "n e" << endl
 9          << "- -----------" << endl;
10     
11     cout.setf(ios_base::showpoint);
12     cout.setf(ios_base::fixed);
13     
14     double e = 0;
15     for(int n = 0; n < 10; n++)
16     {
17         int i = 1;
18         for(int k = 1; k <= n; k++)
19             i *= k;
20         e += 1.00 / i;
21         cout << n << ' ';
22         if(n < 2)
23         {
24             cout << int(e) << endl;;
25             continue;
26         }
27         if(n == 2)
28             cout.precision(1);
29         if(n == 3)
30             cout.precision(9);
31         cout << e << endl;
32     }
33     
34     return 0;
35 }
36 

posted @ 2008-04-06 20:33 superman 閱讀(371) | 評論 (0)編輯 收藏

Official Solution:

Problem G: Phylogenetic Trees Inherited

The first thing to observe is that the different positions in every sequence are independent of each other. This reduces the tree of sequences to a tree of amino acids. At the root of the tree, or for that matter of any sub-tree, there may be many possible amino acids leading to optimal costs. Suppose, you have calculated for two sub-trees Tl and Tr the sets of amino-acids leading to optimal costs Al and Ar. Adjacent sub-trees Tl and Tr have as their father the node T. Now you want to find the set of amino-acids A that you can mark T with, leading to optimal costs for T.

There are two cases: if the intersection of Al with Ar is non-empty, define A as just this intersection, otherwise define A to be the union of Al and Ar. To see why this is true, observe the extra costs you get, when you assemble T from Tl and Tr. In the first case, you have 0 extra costs when you take an amino-acid from the intersection, but 1 or 2 extra costs when you do not. In the second case, you have 1 extra costs when you take an amino-acid from the union, but 2 extra-costs when you do not. Now, you may want to assemble T not from Tl and Tr but from some other sub-optimal trees. As you can easily verify, this leads to sub-optimal costs for T as well.

This reasoning is carried over straightforwardly to an induction proof and leads to a dynamic programming solution. Since the amino-acids are upper-case letters, you can represent sets of amino-acids as ints. The set operations you need are then easily performed as bitwise and respectively or. Whenever you do a union operation, your costs increase by 1.

Another, more straight-forward solution is to calculate for each node of the tree the optimal costs for every amino acid the node can be marked with. This is done by trying every possible combination of amino acids for the two sub-trees, assuming their optimal costs have already been calculated. Since this solution might turn out to be too inefficient, it can be improved upon by observing that a father node always can be marked with either the left or the right son's amino-acid - there is no need to take an amino acid that differs from both.

Judges' test data was constructed from a test-case with a few long sequences, a test-case with many short sequences, a test-case where every possible pair of amino-acids occured, and 100 random-generated test-cases where length and number of sequences are geometrically distributed. The total number of test-cases is 110. Since there may be multiple correct answers for the test cases, a special verification program was written by slightly modifying the judges' solution.


 1 /* Accepted 1102 C++ 00:00.56 1040K */
 2 #include <string>
 3 #include <iostream>
 4 
 5 using namespace std;
 6 
 7 int main()
 8 {
 9     int n, l;
10     while((cin >> n >> l) && n && l)
11     {
12         int heap[2048], cost = 0;
13         string seq[1024];
14         
15         for(int i = 0; i < n; i++)
16             cin >> seq[i];
17         
18         for(int i = 0; i < l; i++)
19         {
20             for(int k = 0; k < n; k++)
21                 heap[n + k] = 1 << (seq[k][i] - 'A');
22             for(int k = n - 1; k >= 1; k--)
23                 if((heap[k] = heap[2 * k] & heap[2 * k + 1]) == 0)
24                 {
25                     cost++;
26                     heap[k] = heap[2 * k] | heap[2 * k + 1];
27                 }
28             char c = 'A';
29             while(heap[1>>= 1)
30                 c++;
31             cout << c;
32         }
33         cout << ' ' << cost << endl;
34     }
35     
36     return 0;
37 }
38 

posted @ 2008-04-06 11:13 superman 閱讀(435) | 評論 (0)編輯 收藏

 1 /* Accepted 1151 C++ 00:00.84 844K */
 2 #include <cstdio>
 3 #include <string>
 4 #include <iostream>
 5 
 6 using namespace std;
 7 
 8 int main()
 9 {
10     int n, m;
11     string word;
12     
13     cin >> n;
14     while(n--)
15     {
16         cin >> m;
17         
18         while(m)
19         {
20             cin >> word;
21             for(int i = word.size() - 1; i >= 0; i--)
22                 cout << word[i];
23             if(getchar() == '\n')
24             {
25                 m--;
26                 cout << endl;
27             }
28             else
29                 cout << ' ';
30         }
31         
32         if(n)
33             cout << endl;
34     }
35     
36     return 0;
37 }
38 

posted @ 2008-04-05 20:23 superman 閱讀(726) | 評論 (0)編輯 收藏

僅列出標題
共19頁: First 11 12 13 14 15 16 17 18 19 
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美在线观看天堂一区二区三区| 亚洲激情午夜| 亚洲主播在线| 一本到高清视频免费精品| 欧美日韩大片| 亚洲欧美日韩精品久久亚洲区| 在线一区日本视频| 国产日韩高清一区二区三区在线| 欧美在线看片| 久久免费少妇高潮久久精品99| 蜜桃久久av| 欧美国产欧美综合| 亚洲一区在线播放| 欧美在线亚洲在线| 亚洲日本精品国产第一区| 亚洲美女在线一区| 国产无一区二区| 欧美成人精品高清在线播放| 欧美日韩国产在线观看| 午夜精品久久| 免费精品99久久国产综合精品| 一本色道久久综合精品竹菊| 在线综合亚洲| 亚洲第一色在线| 这里只有精品视频| 在线观看国产成人av片| 在线亚洲精品| 亚洲激情视频在线| 亚洲欧美电影院| 亚洲精品乱码久久久久久按摩观| 亚洲一区久久久| 亚洲国产成人久久综合一区| 一区二区电影免费在线观看| 在线成人av网站| 一区二区三区四区五区精品视频| 国产一区二区三区在线播放免费观看 | 一区二区欧美视频| 尤物在线精品| 亚洲丝袜av一区| 亚洲视频碰碰| 久久综合精品国产一区二区三区| 欧美国产欧美综合 | 亚洲黄色视屏| 欧美综合第一页| 亚洲特色特黄| 欧美国产精品久久| 裸体一区二区| 国产视频亚洲| 亚洲免费视频成人| 亚洲午夜免费视频| 欧美精品在线观看一区二区| 久久综合狠狠综合久久激情| 国产精品久久久久影院亚瑟| 亚洲黄色天堂| 亚洲激情第一区| 久久久97精品| 久久美女性网| 黄色成人在线网址| 欧美亚洲系列| 久久久精品欧美丰满| 国产精品嫩草99av在线| 一片黄亚洲嫩模| 这里只有视频精品| 欧美日韩色一区| 一区二区不卡在线视频 午夜欧美不卡在| 亚洲国产导航| 欧美大片免费观看在线观看网站推荐| 另类欧美日韩国产在线| 一区二区亚洲欧洲国产日韩| 久久久www成人免费精品| 久久久久久久综合日本| 好吊色欧美一区二区三区四区| 欧美一区二区精品久久911| 久久不射2019中文字幕| 国产中文一区| 久久国产精品色婷婷| 久久综合狠狠综合久久综青草 | 欧美国产免费| 99人久久精品视频最新地址| 亚洲欧美视频一区| 国产欧美日韩一区二区三区在线观看| 午夜日本精品| 欧美sm重口味系列视频在线观看| 在线看片第一页欧美| 欧美激情第4页| 一本一道久久综合狠狠老精东影业 | 亚洲欧美综合v| 国产亚洲欧美一区二区三区| 久久国产精品久久w女人spa| 欧美大片91| 一区二区三区四区精品| 国产精品久久久一本精品| 欧美亚洲视频| 亚洲高清一区二区三区| 亚洲香蕉网站| 国模精品娜娜一二三区| 免费h精品视频在线播放| 亚洲精品孕妇| 欧美在线免费播放| 在线欧美三区| 欧美亚州在线观看| 久久精品一区二区国产| 亚洲精品久久在线| 久久精品盗摄| 亚洲美女视频| 国产色爱av资源综合区| 免费观看成人鲁鲁鲁鲁鲁视频| 一区二区免费在线视频| 另类图片国产| 午夜激情一区| 亚洲精品久久久久久久久久久| 国产精品久久久久久超碰| 久久免费的精品国产v∧| 亚洲美女福利视频网站| 久久综合中文字幕| 久久精品91久久久久久再现| 亚洲日本一区二区三区| 久久久夜色精品亚洲| 亚洲一区二区三区精品视频| 影音先锋日韩资源| 国产精品视频大全| 欧美成人亚洲| 久久精品国产成人| 亚洲欧美一区二区在线观看| 亚洲激情午夜| 嫩模写真一区二区三区三州| 亚洲欧美日韩一区二区三区在线观看| 极品少妇一区二区三区| 国产精品尤物福利片在线观看| 欧美剧在线免费观看网站| 久久久成人网| 欧美一区二区三区在线观看视频 | 久久国产婷婷国产香蕉| 亚洲婷婷综合色高清在线| 亚洲日本国产| 伊人久久成人| 一区二区在线不卡| 国内精品伊人久久久久av影院| 国产精品亚发布| 国产精品视频久久一区| 国产精品久久久久久亚洲调教| 欧美日韩国产首页在线观看| 欧美成人精品一区| 蜜臀久久99精品久久久画质超高清 | 亚洲精品免费观看| 欧美激情在线狂野欧美精品| 欧美成人蜜桃| 亚洲电影在线播放| 亚洲成在线观看| 亚洲精美视频| 99精品国产在热久久婷婷| 一级成人国产| 亚洲欧美经典视频| 欧美在线免费观看| 久久综合久久久久88| 欧美成人激情视频免费观看| 欧美成年网站| 欧美色区777第一页| 国产精品任我爽爆在线播放| 国产日韩av高清| 极品中文字幕一区| 亚洲精品在线观| 亚洲一区三区电影在线观看| 亚洲欧美精品一区| 久久最新视频| 亚洲人成小说网站色在线| 99精品欧美一区二区三区| 亚洲午夜在线观看| 久久电影一区| 欧美激情小视频| 国产乱码精品一区二区三区忘忧草 | 亚洲欧美综合另类中字| 久久久久国色av免费观看性色| 免费影视亚洲| 国产精品一区二区你懂的| 激情丁香综合| 在线一区二区三区做爰视频网站| 亚洲自拍另类| 欧美96在线丨欧| 日韩一级精品| 久久久久九九视频| 欧美日韩中文字幕| 狠狠色丁香婷婷综合久久片| 夜夜精品视频一区二区| 久久狠狠亚洲综合| 亚洲精品视频啊美女在线直播| 小处雏高清一区二区三区| 欧美国产精品| 狠狠色丁香久久婷婷综合丁香| 99在线热播精品免费| 久久一区二区三区超碰国产精品| 亚洲日本视频| 久久久久久亚洲精品中文字幕 | 亚洲一区在线直播| 欧美精品电影| 一色屋精品视频免费看| 午夜精品久久久| 亚洲免费成人av| 麻豆成人在线播放| 国内精品写真在线观看|