QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#837894#8701. BorderXln23 2ms17996kbC++143.1kb2024-12-30 16:02:022024-12-30 16:02:07

Judging History

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

  • [2024-12-30 16:02:07]
  • 评测
  • 测评结果:23
  • 用时:2ms
  • 内存:17996kb
  • [2024-12-30 16:02:02]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using uubt = unsigned long long;

#define IL inline
#define mkp make_pair
#define fi first
#define se second
using pui = pair<uubt, int>;
IL void ckx(int &x, const int &y) { (x < y) && (x = y); }

const int N = 2e6;
const int maxN = N + 3;

int n;
char s[maxN], t[maxN];

int Br;

const uubt B = 10;
uubt Pw[maxN], H[maxN];
IL uubt get(int l, int r) {
  return H[r] - H[l - 1] * Pw[r - l + 1];
}

struct Seg {
  uubt t[maxN << 2];
  int len[maxN << 2];
#define ls (p << 1)
#define rs (p << 1 | 1)
  IL void upd(int p) {
    t[p] = Pw[len[rs]] * t[ls] + t[rs];
  }
  void build(int p, int l, int r) {
    if (l == r) {
      len[p] = 1, t[p] = s[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(ls, l, mid), build(rs, mid + 1, r);
    upd(p), len[p] = len[ls] + len[rs];
  }
  void change(int K, uubt v, int p = 1, int l = 1, int r = n) {
    if (l == r) return t[p] = v, void();
    int mid = (l + r) >> 1;
    K <= mid ? change(K, v, ls, l, mid)
             : change(K, v, rs, mid + 1, r);
    upd(p);
  }
  pui get(int L, int R, int p = 1, int l = 1, int r = n) {
    if (L <= l && r <= R) return mkp(t[p], len[p]);
    int mid = (l + r) >> 1;
    if (R <= mid) return get(L, R, ls, l, mid);
    if (L > mid) return get(L, R, rs, mid + 1, r);
    uubt g = 0;
    auto r1 = get(L, R, ls, l, mid);
    auto r2 = get(L, R, rs, mid + 1, r);
    g = Pw[r2.se] * r1.fi + r2.fi;
    return mkp(g, r1.se + r2.se);
  }
} T;

int ans[maxN];

struct Cov {
  int t[maxN << 2];
  int id[maxN];
  IL void down(int p) {
    if (t[p])
      t[ls] = t[rs] = t[p], t[p] = 0;
  }
  void change(int L, int R, int v, int p, int l, int r) {
    if (L <= l && r <= R) return t[p] = v, void();
    down(p);
    int mid = (l + r) >> 1;
    if (L <= mid) change(L, R, v, ls, l, mid);
    if (R > mid) change(L, R, v, rs, mid + 1, r);
  }
  void dfs(int p, int l, int r) {
    if (l == r) return id[l] = p, void();
    down(p);
    int mid = (l + r) >> 1;
    dfs(ls, l, mid), dfs(rs, mid + 1, r);
  }
} cv;

int main() {
  cin >> (s + 1) >> (t + 1);
  n = strlen(s + 1);

  for (int i = 1; i <= n; i++)
    s[i] -= 'a' - 1, t[i] -= 'a' - 1;

  Pw[0] = 1;
  for (int i = 1; i <= n; i++)
    Pw[i] = Pw[i - 1] * B, H[i] = H[i - 1] * B + s[i];

  T.build(1, 1, n);

  for (int i = 1; i <= n; i++) {
    if (get(1, i) == get(n - i + 1, n)) {
      Br = i;
      cv.change(i + 1, n - i, i, 1, 1, n);
      continue;
    }
    int l = 1, r = i, h = 1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (get(1, mid) == get(n - i + 1, n - i + mid))
        l = mid + 1, h = mid + 1;
      else r = mid - 1;
    }
    
    T.change(h, t[h]);
    if (T.get(1, i) == T.get(n - i + 1, n))
      ans[h] = i;
    T.change(h, s[h]);

    int p = n - i + h;
    T.change(p, t[p]);
    if (T.get(1, i) == T.get(n - i + 1, n))
      ans[p] = i;
    T.change(p, s[p]);
  }
  cv.dfs(1, 1, n);

  for (int i = 1; i <= n; i++)
    cout << max(cv.t[cv.id[i]], ans[i]) << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 23
Accepted

Test #1:

score: 23
Accepted
time: 0ms
memory: 17832kb

input:

cbaababaabacbaababaabacbaabacbaababaabacbaaba
dabbababbabaabbafabbgbaabfebaabzababbayaabcac

output:

0
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
17
17
17
17
17
17
17
17
17
17
17
6
6
6
6
6
6
6
6
6
6
6
0
0
0
3
0
1

result:

ok 45 numbers

Test #2:

score: 23
Accepted
time: 0ms
memory: 17896kb

input:

cbaababaabacbaabadbaababaabacbaabacbaaba
aabwaxjbbabtalbabcasbabibbabaabbabaabiac

output:

3
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
23
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
0
0
0
0
0
1

result:

ok 40 numbers

Test #3:

score: 23
Accepted
time: 0ms
memory: 17996kb

input:

cadaabacabacabacabaabacabacadaabacabacaba
bbbbbabtbabababalalbawababababbaoababebdc

output:

2
0
4
0
0
0
0
0
0
0
0
0
0
0
0
15
15
15
15
15
15
15
15
15
15
15
0
0
0
0
0
0
0
0
0
0
0
0
0
4
1

result:

ok 41 numbers

Test #4:

score: 23
Accepted
time: 0ms
memory: 15852kb

input:

dabacbaadcbaadabacbaadabecbaadcbaadabacbaadabacbaa
ababaabbyaarbabfbvdbuaoaaaabbaaabbababaabbababqadd

output:

2
0
0
0
0
0
0
0
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
29
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
0
0
0
0
0
0
2
1

result:

ok 50 numbers

Test #5:

score: 23
Accepted
time: 0ms
memory: 17912kb

input:

edacbcacacbcaecbcacacbcadacbcacacbca
sabaaabtbaaabaaalblbawaeabaaababoaae

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
13
0
0
0
0
0
0
0
0
0
0
0
1

result:

ok 36 numbers

Test #6:

score: 23
Accepted
time: 0ms
memory: 17832kb

input:

cbaababaabacbaabacbaabdbaabacbaabacbaaba
aabbababbaoaabbxbaabbaqabbabltbpagaabcac

output:

3
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
0
0
0
3
0
1

result:

ok 40 numbers

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #7:

score: 0
Wrong Answer
time: 2ms
memory: 16088kb

input:

abacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacababacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacaecabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacababacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacad...

output:

27
0
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
123
1...

result:

wrong answer 124th numbers differ - expected: '75', found: '123'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%