QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#175545#5680. You You See What?AshokaWA 1ms3624kbC++201.1kb2023-09-10 19:30:412023-09-10 19:30:41

Judging History

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

  • [2023-09-10 19:30:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3624kb
  • [2023-09-10 19:30:41]
  • 提交

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 - 1; j > i; --j) {
      int l = i, r = j;
      while (l < r && b[l] == b[r]) {
        ++l, --r;
      }
      if (l >= r) {
        vis[i] += 1;
        vis[j] -= 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;
}

詳細信息

Test #1:

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

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: -100
Wrong Answer
time: 1ms
memory: 3608kb

input:

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

output:

texasam!Rice!BayloR!dev!Rice!bresearch!bpoucher

result:

wrong answer 1st lines differ - expected: 'texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher', found: 'texasam!Rice!BayloR!dev!Rice!bresearch!bpoucher'