Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

总是 RE 求高人指点。

Posted by dxacm at 2010-06-10 03:28:14 on Problem 3096
#include <iostream>
#include <cstring>

using namespace std;

typedef bool MvTable[26][26];

int main() {
    while (true) {
        string line;
        getline(cin, line);
        if (line == "*") break;
        if (line.length() == 1) {
            cout << line << " is surprising." << endl;
            continue;
        }
        MvTable* hash = new MvTable[line.length()];
        memset(hash, (char)0, line.length() * 26 * 26);
        for (unsigned int y = 1; y < line.length(); y++) {
            for (unsigned int x = 0; x < y; x++) {
                if (hash[line[x]-'A'][line[y]-'A'][y - x - 1] == false) {
                    hash[line[x]-'A'][line[y]-'A'][y - x - 1] = true;
                } else {
                    cout << line << " is NOT surprising." << endl;
                    goto finally;
                }
            }
        }
        cout << line << " is surprising." << endl;
        finally:
        delete [] hash;
    }

    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator