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

coreBugZJ

此 blog 已棄。

微軟2014實習生及秋令營技術類職位在線測試


1.String reorder

Time Limit: 10000ms
Case Time Limit: 1000ms
Memory Limit: 256MB

 

Description

For this question, your program is required to process an input string containing only ASCII characters between ‘0’ and ‘9’, or between ‘a’ and ‘z’ (including ‘0’, ‘9’, ‘a’, ‘z’).

Your program should reorder and split all input string characters into multiple segments, and output all segments as one concatenated string. The following requirements should also be met,
1. Characters in each segment should be in strictly increasing order. For ordering, ‘9’ is larger than ‘0’, ‘a’ is larger than ‘9’, and ‘z’ is larger than ‘a’ (basically following ASCII character order).
2. Characters in the second segment must be the same as or a subset of the first segment; and every following segment must be the same as or a subset of its previous segment.

Your program should output string “<invalid input string>” when the input contains any invalid characters (i.e., outside the '0'-'9' and 'a'-'z' range).

 

Input

Input consists of multiple cases, one case per line. Each case is one string consisting of ASCII characters.

 

Output

For each case, print exactly one line with the reordered string based on the criteria above.

 

Sample In

aabbccdd
007799aabbccddeeff113355zz
1234.89898
abcdefabcdefabcdefaaaaaaaaaaaaaabbbbbbbddddddee


Sample Out

abcdabcd
013579abcdefz013579abcdefz
<invalid input string>
abcdefabcdefabcdefabdeabdeabdabdabdabdabaaaaaaa


代碼:
 1#include <cstdio>
 2#include <cstring>
 3
 4using namespace std;
 5
 6typedef  long long  Lint;
 7
 8#define  L  256
 9Lint cnt[ L ];
10Lint tot;
11
12#define  INVALID  "<invalid input string>"
13
14int main() {
15        int ch = 1;
16        int i;
17        int invalid;
18        while ( EOF != ch ) {
19                memset( cnt, 0sizeof(cnt) );
20                for ( ch = getchar(); (EOF != ch) && ('\n' != ch); ch = getchar() ) {
21                        ++cnt[ ch ];
22                        ++tot;
23                }

24                invalid = 0;
25                for ( i = 0; i < L; ++i ) {
26                        if (    (0 < cnt[ i ]) && 
27                                (!      (       ( ('0' <= i) && ('9' >= i)
28                                                ) || 
29                                                ( ('a' <= i) && ('z' >= i)
30                                                )
31                                        )
32                                )
33                        ) {
34                                invalid = 1;
35                                break;
36                        }

37                }

38                if ( invalid ) {
39                        puts( INVALID );
40                        continue;
41                }

42
43                while ( 0 < tot ) {
44                        for ( i = 0; i < L; ++i ) {
45                                if ( 0 < cnt[ i ] ) {
46                                        putchar( i );
47                                        --cnt[ i ];
48                                        --tot;
49                                }

50                        }

51                }

52                puts( "" );
53        }

54        return 0;
55}

56




2.K-th string

Time Limit: 10000ms
Case Time Limit: 1000ms
Memory Limit: 256MB

 

Description

Consider a string set that each of them consists of {0, 1} only. All strings in the set have the same number of 0s and 1s. Write a program to find and output the K-th string according to the dictionary order. If s​uch a string doesn’t exist, or the input is not valid, please output “Impossible”. For example, if we have two ‘0’s and two ‘1’s, we will have a set with 6 different strings, {0011, 0101, 0110, 1001, 1010, 1100}, and the 4th string is 1001.


Input

The first line of the input file contains a single integer t (1 ≤ t ≤ 10000), the number of test cases, followed by the input data for each test case.
Each test case is 3 integers separated by blank space: N, M(2 <= N + M <= 33 and N , M >= 0), K(1 <= K <= 1000000000). N stands for the number of ‘0’s, M stands for the number of ‘1’s, and K stands for the K-th of string in the set that needs to be printed as output.


Output

For each case, print exactly one line. If the string exists, please print it, otherwise print “Impossible”.


Sample In

3
2 2 2
2 2 7
4 7 47

Sample Out

0101
Impossible
01010111011


代碼:
 1#include <cstdio>
 2#include <cstring>
 3
 4using namespace std;
 5
 6#define  IMP  "Impossible"
 7
 8typedef  long long  Lint;
 9
10#define  L  35
11
12Lint c[ L ][ L ];
13char ans[ L+L ];
14
15void init() {
16        int i, j;
17        memset( c, 0sizeof(c) );
18        c[ 0 ][ 0 ] = 1;
19        for ( i = 1; i < L; ++i ) {
20                c[ i ][ 0 ] = c[ i ][ i ] = 1;
21                for ( j = 1; j < i; ++j ) {
22                        c[ i ][ j ] = c[ i-1 ][ j-1 ] + c[ i-1 ][ j ];
23                }

24        }

25}

26
27static int solve_i( int n0, int n1, int idx, int off ) {
28        if ( (0 == n0) && (0 == n1) && (0 == idx) ) {
29                return 1;
30        }

31
32        if ( ((1 > n0) || (1 > n1)) && (1 != idx) ) {
33                return 0;
34        }

35
36        if ( 1 == idx ) {
37                for ( int i = 0; i < n0; ++i ) {
38                        ans[ off + i ] = '0';
39                }

40                for ( int i = 0; i < n1; ++i ) {
41                        ans[ off + n0 + i ] = '1';
42                }

43                return 1;
44        }

45
46        int i = 0;
47        while ( c[n1+i-1][i] < idx ) {
48                idx -= c[n1+i-1][i];
49                ++i;
50        }

51        for ( int j = 0; j < n0 - i; ++j ) {
52                ans[ off + j ] = '0';
53        }

54        ans[ off + n0 - i ] = '1';
55        return solve_i( i, n1-1, idx, off + n0 - i + 1 );
56}

57
58/*
59n0=n=4, n1=m=7, idx=k=47
60
61i   n0      n1
62
630   0000    1??????     c[6][0] = 1
641   0001    ???????     c[7][1] = 7
652   001?    ???????     c[8][2] = 28
663   01??    ???????     c[9][3] = 84
674   1???    ???????     c[10][4]
68
69*/

70
71int solve( int n, int m, int k ) {
72        if ( c[n+m][n] < k ) {
73                return 0;
74        }

75        memset( ans, 0sizeof(ans) );
76        return solve_i( n, m, k, 0 );
77}

78
79int main() {
80        int tot_case;
81        int n, m, k;
82
83        init();
84
85        scanf( "%d"&tot_case );
86        while ( 0 < tot_case-- ) {
87                scanf( "%d%d%d"&n, &m, &k );
88
89                if ( solve( n, m, k ) ) {
90                        puts( ans );
91                }

92                else {
93                        puts( IMP );
94                }

95        }

96
97        return 0;
98}

99




3.Reduce inversion count

Time Limit: 10000ms
Case Time Limit: 1000ms
Memory Limit: 256MB

Description

Find a pair in an integer array that swapping them would maximally decrease the inversion count of the array. If such a pair exists, return the new inversion count; otherwise returns the original inversion count.

Definition of Inversion: Let (A[0], A[1] ... A[n]) be a sequence of n numbers. If i < j and A[i] > A[j], then the pair (i, j) is called inversion of A.

Example:
Count(Inversion({3, 1, 2})) = Count({3, 1}, {3, 2}) = 2
InversionCountOfSwap({3, 1, 2})=>
{
  InversionCount({1, 3, 2}) = 1 <-- swapping 1 with 3, decreases inversion count by 1
  InversionCount({2, 1, 3}) = 1 <-- swapping 2 with 3, decreases inversion count by 1
  InversionCount({3, 2, 1}) = 3 <-- swapping 1 with 2 , increases inversion count by 1
}


Input

Input consists of multiple cases, one case per line.Each case consists of a sequence of integers separated by comma.

Output

For each case, print exactly one line with the new inversion count or the original inversion count if it cannot be reduced.


Sample In

3,1,2
1,2,3,4,5

Sample Out

1
0


解法:
窮舉兩元素交換,使用修改的歸并排序求逆序對數,時間復雜度O(n*n*n*logn)。



4.Most Frequent Logs
不會。










posted on 2014-04-13 19:11 coreBugZJ 閱讀(3757) 評論(0)  編輯 收藏 引用 所屬分類: ACMAlgorithm

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美成人精品h版在线观看| 久久综合九色九九| 亚洲人成网站777色婷婷| 亚洲综合精品| 中文欧美字幕免费| 美女脱光内衣内裤视频久久影院| 欧美在线www| 久久嫩草精品久久久精品一| 在线一区二区三区四区| 久久久精品五月天| 久久精品99久久香蕉国产色戒| 欧美精品系列| 欧美福利一区二区| 在线观看国产精品淫| 欧美在线观看视频一区二区三区 | 国产精品啊v在线| 亚洲国产天堂网精品网站| 国产亚洲美州欧州综合国| 亚洲一区二区三区在线视频| 在线中文字幕不卡| 欧美日韩精品免费观看| 亚洲精品久久久久久久久久久久| 亚洲啪啪91| 欧美+日本+国产+在线a∨观看| 噜噜噜在线观看免费视频日韩| 国产亚洲精品bt天堂精选| 午夜欧美精品| 久久亚洲精品一区二区| 精品成人一区| 久久综合色婷婷| 亚洲电影第1页| 99国产精品国产精品久久| 欧美精品亚洲精品| 一区二区高清在线| 性欧美video另类hd性玩具| 国产欧美视频一区二区三区| 欧美中文字幕精品| 欧美a级一区| 亚洲免费激情| 国产精品久久久久一区二区三区 | 在线观看亚洲a| 免费h精品视频在线播放| 亚洲国产小视频在线观看| 一本久久综合亚洲鲁鲁五月天| 欧美日韩精品综合| 亚洲欧美视频一区二区三区| 久久综合给合久久狠狠狠97色69| 亚洲国产一区二区精品专区| 欧美巨乳波霸| 欧美一级视频| 91久久极品少妇xxxxⅹ软件| 亚洲永久网站| 激情综合网激情| 欧美日本在线一区| 先锋影音网一区二区| 欧美大胆成人| 午夜精品福利在线观看| 亚洲春色另类小说| 欧美新色视频| 免费短视频成人日韩| 一本一本久久a久久精品牛牛影视| 久久精品官网| 制服丝袜亚洲播放| 樱花yy私人影院亚洲| 欧美午夜不卡视频| 久久视频国产精品免费视频在线| 99成人在线| 免费成人在线观看视频| 亚洲男同1069视频| 亚洲国产小视频在线观看| 国产精品一区二区在线观看网站| 美女91精品| 欧美制服丝袜| 亚洲图片欧美午夜| 亚洲日本成人| 蜜臀av国产精品久久久久| 西瓜成人精品人成网站| 91久久视频| 曰韩精品一区二区| 国产午夜精品全部视频在线播放| 欧美日韩ab片| 鲁鲁狠狠狠7777一区二区| 欧美影院精品一区| 亚洲一区国产精品| 一区二区三区精品| 最新国产乱人伦偷精品免费网站 | 国语自产偷拍精品视频偷 | 亚洲私人影院| 亚洲人成网站999久久久综合| 国产婷婷成人久久av免费高清| 欧美人体xx| 欧美大片国产精品| 久久综合伊人77777麻豆| 香蕉成人久久| 小黄鸭精品密入口导航| 一区二区三区欧美亚洲| 亚洲伦理在线观看| 亚洲精品午夜精品| 亚洲精品乱码久久久久久按摩观| 男男成人高潮片免费网站| 久久久欧美精品sm网站| 欧美一区二区日韩| 欧美一区深夜视频| 香蕉久久一区二区不卡无毒影院 | 99国产精品久久久久久久成人热| 亚洲高清在线观看| 亚洲国产人成综合网站| 亚洲国产成人高清精品| 亚洲国产精品一区在线观看不卡| 在线观看国产日韩| 亚洲黄色av一区| 亚洲理伦电影| 亚洲视频在线免费观看| 亚洲一区二区三区在线观看视频| 一区二区不卡在线视频 午夜欧美不卡在| 亚洲精品1区| 亚洲美女尤物影院| 中日韩男男gay无套| 亚洲欧美电影院| 欧美亚洲免费电影| 久久综合导航| 亚洲风情在线资源站| 亚洲精品自在在线观看| 妖精成人www高清在线观看| 亚洲午夜激情免费视频| 欧美一级电影久久| 久热精品视频在线| 欧美日韩精品一区二区三区四区 | 国产精品乱人伦一区二区| 国产亚洲精品福利| 亚洲国产成人午夜在线一区| 亚洲精品中文字幕有码专区| 亚洲一级黄色片| 久久久久久91香蕉国产| 亚洲第一精品在线| 一区二区三区四区五区视频| 欧美在线二区| 欧美日韩国产精品| 国产综合香蕉五月婷在线| 日韩视频免费| 久久精品国产在热久久| 亚洲狠狠丁香婷婷综合久久久| 一本色道久久综合亚洲精品不卡| 欧美一级电影久久| 欧美日韩国产大片| 国产亚洲在线观看| 一区二区三区成人| 噜噜噜在线观看免费视频日韩 | 亚洲私人黄色宅男| 久久午夜激情| 国产精品久久久一区二区三区| 激情成人中文字幕| 亚洲一区二区三区久久| 暖暖成人免费视频| 亚洲午夜免费福利视频| 麻豆精品91| 国产日韩一区二区三区在线| 亚洲欧洲在线看| 久久久国产精品一区二区三区| 亚洲精品国产品国语在线app| 欧美一区二视频| 欧美日韩一区二区三| 亚洲国产成人在线| 久久精品国产亚洲精品 | 亚洲国产欧美日韩| 欧美一区影院| 国产精品久久久久9999吃药| 亚洲经典在线| 卡一卡二国产精品| 亚洲综合色网站| 欧美日韩情趣电影| 亚洲精品欧美日韩专区| 老色鬼精品视频在线观看播放| 亚洲私人影院在线观看| 欧美日韩xxxxx| 99re8这里有精品热视频免费| 欧美jizz19性欧美| 久久国产精品久久精品国产| 国产精品毛片高清在线完整版| 中日韩美女免费视频网址在线观看 | 久热精品在线视频| 最新精品在线| 狂野欧美激情性xxxx| 久久婷婷色综合| 国产视频久久| 性色av香蕉一区二区| 欧美黄色影院| 久久精品国产久精国产一老狼| 国产精品视频一二| 亚洲欧美在线免费观看| 久久亚洲图片| 香蕉久久精品日日躁夜夜躁| 免费高清在线视频一区·| 一区二区三欧美| 免费观看不卡av| 国产日韩欧美一区二区| 一本色道综合亚洲| 欧美成人免费在线观看| 午夜精品短视频| 欧美色视频在线|