SRM 630 div2

Source: Internet
Author: User

SRM 630 div2

For the first time tc, I thought it was AK. The result was 1000 points and the system dropped the result, but it was also cha. Others made a lot of money.

A: the string length is only 50, which can be directly simulated.
B: The number of nodes is only 10. First, use Floyd to find the path between two or two nodes. Then, use brute force enumeration to determine which nodes are required. If yes, record the maximum number.
C: In the beginning, after constructing the rank array, put a for a continuous segment, and then put B in the last one. We thought that the constructed sequence must be the smallest Lexicographic Order, the result is dropped by the system.
The correct method: first, the SA array is constructed, and each position of the brute force enumeration is not 'a'. If the value is reduced by 1, The lexicographically small order is ensured. Then, the SA array is constructed, determine whether the two Suffix Arrays are different. If all positions are different, it indicates that this is the smallest Lexicographic Order.

Code:

A:

# Include <cstdio> # include <cstring> # include <iostream> # include <vector> # include <set> # include <map> # include <string> using namespace STD; class doubleletter {public: String abletosolve (string s) {While (1) {int n = S. length (); string TMP = ""; int flag = 1; for (INT I = 0; I <n-1; I ++) {If (s [I] = s [I + 1]) {flag = 0; For (Int J = 0; j <n; j ++) {If (j = I | j = I + 1) continue; TMP + = s [J];} break ;}} if (FLAG) break; S = TMP;} If (S = "") Return "possible"; else return "impossible ";}};

B:

# Include <iostream> # include <cstdio> # include <cstring> # include <vector> # include <algorithm> using namespace STD; Class egalitarianism3easy {public: int bitcount (int x) {int ans = 0; while (x) {ans + = (X & 1); X >>=1;} return ans ;}int maxcities (int n, vector <int> A, vector <int> B, vector <int> Len) {int G [15] [15]; for (INT I = 1; I <= 10; I ++) for (Int J = 1; j <= 10; j ++) {if (I = J) g [I] [J] = 0; else G [I] [J] = 1000000000 ;}for (INT I = 0; I <n-1; I ++) G [A [I] [B [I] = G [B [I] [A [I] = Len [I]; for (int K = 1; k <= N; k ++) {for (INT I = 1; I <= N; I ++) {for (Int J = 1; j <= N; j ++) {G [I] [J] = min (G [I] [J], G [I] [k] + G [k] [J]) ;}} int TMP [15], TN; int ans = 1; for (INT I = 1; I <(1 <n); I ++) {tn = 0; For (Int J = 0; j <n; j ++) {if (I & (1 <j) {TMP [tn ++] = J + 1 ;}} int Ss =-1; int flag = 0; fo R (Int J = 0; j <tn; j ++) {for (int K = J + 1; k <tn; k ++) {If (Ss =-1) Ss = G [TMP [J] [TMP [k]; else {If (SS! = G [TMP [J] [TMP [k]) {flag = 1; break ;}} if (FLAG) Break ;}if (flag = 0) ans = max (ANS, bitcount (I) ;}return ans ;}};

C:

# Include <iostream> # include <cstdio> # include <string> # include <algorithm> using namespace STD; typedef pair <string, int> PII; Class suffixarraydiv2 {public: string smallerone (string s) {int n = S. length (); PII save [55]; for (INT I = n-1; I> = 0; I --) {string TMP = ""; for (Int J = I; j <n; j ++) TMP + = s [J]; save [I]. first = TMP; save [I]. second = I;} Sort (save, save + n); For (int t = 0; t <n; t ++) {I F (s [T] = 'A') continue; string Ss = s; SS [T] --; PII sav [55]; for (INT I = n-1; i> = 0; I --) {string TMP = ""; for (Int J = I; j <n; j ++) TMP + = ss [J]; sav [I]. first = TMP; sav [I]. second = I;} Sort (SAV, sav + n); int K = 0; For (; k <n; k ++) if (save [K]. second! = Sav [K]. Second) break; If (k = N) Return "exists";} return "does not exist ";}};


SRM 630 div2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.