QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#175554#5680. You You See What?AshokaAC ✓1ms3872kbC++201.1kb2023-09-10 19:35:102023-09-10 19:35:12

Judging History

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

  • [2023-09-10 19:35:12]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3872kb
  • [2023-09-10 19:35:10]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using i64 = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  vector<string> a;
  int len = (int)s.size();
  for (int i = 0, j = 0; i <= len; ++i) {
    if (i == len || s[i] == '!') {
      a.emplace_back(s.substr(j, i - j));
      j = i + 1;
    }
  } 
  int n = a.size();
  map<string, int> mp;
  int cnt = 0;
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    string t = "";
    for (auto c : a[i]) {
      t += tolower(c);
    }
    if (!mp.count(t)) {
      mp[t] = ++cnt;
    }
    b[i] = mp[t];
  }
  vector<int> vis(n);
  for (int i = 0; i < n; ++i) {
    for (int j = n - 2; j > i; --j) {
      int l = i, r = j;
      while (l < r && b[l] == b[r]) {
        ++l, --r;
      }
      if (l >= r) {
        vis[i + 1] += 1;
        vis[j + 1] -= 1;
      }
    }
  }
  for (int i = 1; i < n; ++i) {
    vis[i] += vis[i - 1];
  }
  string ans = "";
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) {
      ans += a[i];
      ans += '!';
    }
  }
  ans.pop_back();
  cout << ans << "\n";
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3604kb

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: 3636kb

input:

bresearch!bpoucher

output:

bresearch!bpoucher

result:

ok single line: 'bresearch!bpoucher'

Test #4:

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

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

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

result:

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

Test #5:

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

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

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!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!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: 1ms
memory: 3612kb

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: 3860kb

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: 3632kb

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: 0ms
memory: 3580kb

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: 0ms
memory: 3872kb

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: 3516kb

input:

b

output:

b

result:

ok single line: 'b'

Test #12:

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

input:

bpoucher

output:

bpoucher

result:

ok single line: 'bpoucher'

Test #13:

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

input:

Abcdefghij

output:

Abcdefghij

result:

ok single line: 'Abcdefghij'

Test #14:

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

input:

polyof!johnb

output:

polyof!johnb

result:

ok single line: 'polyof!johnb'

Test #15:

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

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: 3672kb

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: 0ms
memory: 3612kb

input:

aaaa!bbbbb!bbbbb!testacct

output:

aaaa!bbbbb!testacct

result:

ok single line: 'aaaa!bbbbb!testacct'

Test #18:

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

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: 0ms
memory: 3528kb

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: 3640kb

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: 3676kb

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'