QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#175588#5680. You You See What?Fr1nGeLoveAC ✓2ms3556kbC++203.4kb2023-09-10 20:11:152023-09-10 20:11:16

Judging History

你现在查看的是最新测评结果

  • [2023-09-10 20:11:16]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3556kb
  • [2023-09-10 20:11:15]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::string s;
    std::cin >> s;

    std::map<std::string, int> f;
    std::map<int, std::string> g;
    int idx = 0;
    std::vector<int> a;
    for (int i = 0; i < s.size(); i++) {
        int j = i;
        while (j < s.size() && s[j] != '!') {
            j++;
        }
        std::string str = s.substr(i, j - i);
        std::string ss = "";
        for (auto x : str) {
            ss += std::tolower(x);
        }
        if (!f.count(ss)) {
            f[ss] = idx++;
            g[f[ss]] = str;
        }
        a.push_back(f[ss]);
        i = j;
    }

    const int n = a.size();
    if (n == 1) {
        std::cout << g[a.back()];
        return 0;
    }
    int t = a.back();
    a.pop_back();

    // for (auto x : a) {
    //     std::cerr << x << " ";
    // }
    // std::cerr << "\n";
    int mx = 1;
    while (1) {
        // for (auto x : a) {
        //     std::cerr << x << " ";
        // }
        // std::cerr << "\n";
        std::vector<int> u;
        std::vector<int> v;
        for (int i = 0; i < a.size(); i++) {
            int cnt = 0;
            // std::cerr << "start : " << a[i] << "\n";
            for (int l = i - 1, r = i + 1; l >= 0 && r < a.size(); l--, r++) {
                if (a[l] == a[r]) {
                    // std::cerr << l << " " << r << "\n";
                    // std::cerr << a[l] << " " << a[r] << "\n";
                    cnt++;
                } else {
                    break;
                }
            }
            u.push_back(cnt);
            cnt = 0;
            if (i + 1 < a.size() && a[i] == a[i + 1]) {
                cnt++;
                for (int l = i - 1, r = i + 2; l >= 0 && r < a.size(); l--, r++) {
                    if (a[l] == a[r]) {
                        cnt++;
                    } else {
                        break;
                    }
                }
            }
            v.push_back(cnt);
        }
        // std::cerr << "check : \n";
        // for (auto x : u) {
        //     std::cerr << x << " ";
        // }
        // std::cerr << "\n";
        // for (auto x : v) {
        //     std::cerr << x << " ";
        // }
        // std::cerr << "\n";

        int mx1 = *std::max_element(u.begin(), u.end());
        int mx2 = *std::max_element(v.begin(), v.end());
        // std::cerr << mx1 << " " << mx2 << "\n";
        if (mx1 == 0 && mx2 == 0) {
            break;
        }
        int val1 = 2 * mx1 + 1, val2 = (mx2 == 0 ? 0 : 2 * mx2);
        if (val1 > val2) {
            int p = 0;
            for (int i = 0; i < u.size(); i++) {
                if (mx1 == u[i]) {
                    p = i;
                    break;
                }
            }
            // std::cerr << p << "\n";
            a.erase(a.begin() + p - mx1 + 1, a.begin() + p + mx1 + 1);
        } else {
            int p = 0;
            for (int i = 0; i < v.size(); i++) {
                if (mx2 == v[i]) {
                    p = i;
                    break;
                }
            }
            a.erase(a.begin() + p - mx2 + 2, a.begin() + p + mx2 + 1);
        }
    }

    for (int i = 0; i < a.size(); i++) {
        std::cout << g[a[i]] << "!";
    }
    std::cout << g[t];
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3512kb

input:

texasam!rice!baylor!csdept!baylor!rice!dev!bresearch!bpoucher

output:

texasam!rice!dev!bresearch!bpoucher

result:

ok single line: 'texasam!rice!dev!bresearch!bpoucher'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

texasam!Rice!baYlor!csdept!BayloR!dev!Rice!bresearch!bpoucher

output:

texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher

result:

ok single line: 'texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

bresearch!bpoucher

output:

bresearch!bpoucher

result:

ok single line: 'bresearch!bpoucher'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!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x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx

result:

ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3448kb

input:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z

output:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z

result:

ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

abcdEFGHij!bbcdEFGHij!cbcdEFGHij!dbcdEFGHij!ebcdEFGHij!fbcdEFGHij!gbcdEFGHij!hbcdEFGHij!ibcdEFGHij!jbcdEFGHij!kbcdEFGHij!lbcdEFGHij!mbcdEFGHij!nbcdEFGHij!obcdEFGHij!pbcdEFGHij!qbcdEFGHij!rbcdEFGHij!sbcdEFGHij!tbcdEFGHij!ubcdEFGHij!vbcdEFGHij!wbcdEFGHij!abc

output:

abcdEFGHij!bbcdEFGHij!cbcdEFGHij!dbcdEFGHij!ebcdEFGHij!fbcdEFGHij!gbcdEFGHij!hbcdEFGHij!ibcdEFGHij!jbcdEFGHij!kbcdEFGHij!lbcdEFGHij!mbcdEFGHij!nbcdEFGHij!obcdEFGHij!pbcdEFGHij!qbcdEFGHij!rbcdEFGHij!sbcdEFGHij!tbcdEFGHij!ubcdEFGHij!vbcdEFGHij!wbcdEFGHij!abc

result:

ok single line: 'abcdEFGHij!bbcdEFGHij!cbcdEFGH...FGHij!vbcdEFGHij!wbcdEFGHij!abc'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abc

output:

abcdEFGHij!abc

result:

ok single line: 'abcdEFGHij!abc'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3440kb

input:

a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb

output:

a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb

result:

ok single line: 'a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!...!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3520kb

input:

aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!B

output:

aa!B

result:

ok single line: 'aa!B'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3440kb

input:

b

output:

b

result:

ok single line: 'b'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3468kb

input:

bpoucher

output:

bpoucher

result:

ok single line: 'bpoucher'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

Abcdefghij

output:

Abcdefghij

result:

ok single line: 'Abcdefghij'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

polyof!johnb

output:

polyof!johnb

result:

ok single line: 'polyof!johnb'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

polyvm!polyof!gracie!johnb

output:

polyvm!polyof!gracie!johnb

result:

ok single line: 'polyvm!polyof!gracie!johnb'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3448kb

input:

a!b!b!c!c!d!d!d!e!e!e

output:

a!b!c!d!e!e

result:

ok single line: 'a!b!c!d!e!e'

Test #17:

score: 0
Accepted
time: 1ms
memory: 3468kb

input:

aaaa!bbbbb!bbbbb!testacct

output:

aaaa!bbbbb!testacct

result:

ok single line: 'aaaa!bbbbb!testacct'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3476kb

input:

a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b

output:

a!b!b

result:

ok single line: 'a!b!b'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3448kb

input:

a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!bb!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b

output:

a!b!b

result:

ok single line: 'a!b!b'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3484kb

input:

a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!c!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b

output:

a!b!b

result:

ok single line: 'a!b!b'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3504kb

input:

a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!c!d!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b

output:

a!b!c!d!b!b

result:

ok single line: 'a!b!c!d!b!b'