Submission details
Task:Leimasin
Sender:Yytsi
Submission time:2025-09-26 19:57:33 +0300
Language:C++ (C++20)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED33
#2ACCEPTED43
#3ACCEPTED24
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#2ACCEPTED0.00 s1, 2, 3details
#3ACCEPTED0.00 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.04 s2, 3details
#6ACCEPTED0.04 s2, 3details
#7ACCEPTED0.04 s2, 3details
#8ACCEPTED0.04 s2, 3details
#9ACCEPTED0.61 s3details
#10ACCEPTED0.66 s3details
#11ACCEPTED0.78 s3details
#12ACCEPTED0.84 s3details
#13ACCEPTED0.88 s3details
#14ACCEPTED0.46 s3details

Code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 0xffff
#endif

int n, m, k;

#define N (1<<20)
int segTree[2*N], lazy[2*N];

void pushDown(int cur) {
  if (lazy[cur]) {
    segTree[cur] = lazy[cur];
    if (cur < N) {
      lazy[2*cur] = lazy[cur];
      lazy[2*cur+1] = lazy[cur];
    }
    lazy[cur] = 0;
  }
}

void upd(int l, int r, int x, int y, int cur, int val) {
  // [l, r] is node
  // [x, y] is range update
  pushDown(cur);
  if (r < x || y < l) return;
  if (x <= l && r <= y) {
    // node is fully inside range
    lazy[cur] = val;
    segTree[cur] = val;
    return;
  }

  int mid = (l + r) / 2;
  upd(l, mid, x, y, 2*cur, val);
  upd(mid+1, r, x, y, 2*cur+1, val);
  pushDown(cur);
}

int query(int l, int r, int p, int cur) {
  // [l, r] is node
  // [x, y] is range update
  pushDown(cur);
  if (r < p || p < l) return 0;
  if (l == r) {
    if (l == p) return segTree[cur];
    return 0;
  }

  int mid = (l + r) / 2;
  int vl = query(l, mid, p, 2*cur);
  int vr = query(mid+1, r, p, 2*cur+1);
  pushDown(cur);
  return max(vl, vr);
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin>>n>>m>>k;
  string s;
  cin>>s;
  vector<int> pidxs;

  for (int i = 0; i < k; i++) {
    int idx;
    cin>>idx;
    pidxs.push_back(idx);

    idx--; // just for easier indexing
    upd(0, N-1, idx, idx+m-1, 1, i+1);
  }

  for (int i = 0; i < n; i++) {
    int ridx = query(0, N-1, i, 1);
    if (ridx == 0) {
      cout<<".";
      continue;
    }
    // this means that ith character is stamped by ridx
    int startOfStamp = pidxs[ridx-1];
    
    cout << s[i - (startOfStamp - 1)];
  }
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
1000 1 100
a
585 600 750 170 794 845 341 39...

correct output
............a....aa..............

user output
............a....aa..............

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
1000 4 100
zhrb
795 569 744 662 315 869 913 21...

correct output
.........................zhrb....

user output
.........................zhrb....

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
1000 100 100
wkmtgzytnfwptwukbartgunjyrkyml...

correct output
wkmtgzywkmtgzytnfwptwukbartgun...

user output
wkmtgzywkmtgzytnfwptwukbartgun...

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
1000 1000 100
njplbyvkaytbcyzbylzntnmpfapvfg...

correct output
njplbyvkaytbcyzbylzntnmpfapvfg...

user output
njplbyvkaytbcyzbylzntnmpfapvfg...

Test 5

Group: 2, 3

Verdict: ACCEPTED

input
100000 1 1000
a
61541 4948 46214 29629 8779 76...

correct output
.................................

user output
.................................

Test 6

Group: 2, 3

Verdict: ACCEPTED

input
100000 10 1000
ntsconpqnv
17118 69319 2115 8873 892 9994...

correct output
.....................ntsconpqn...

user output
.....................ntsconpqn...

Test 7

Group: 2, 3

Verdict: ACCEPTED

input
100000 10000 1000
wcyeepjmmvavmoncfxclqrsebjzwbf...

correct output
.................................

user output
.................................

Test 8

Group: 2, 3

Verdict: ACCEPTED

input
100000 100000 1000
chdcxwwznawllrxcxlckeziomcsjhc...

correct output
chdcxwwznawllrxcxlckeziomcsjhc...

user output
chdcxwwznawllrxcxlckeziomcsjhc...

Test 9

Group: 3

Verdict: ACCEPTED

input
1000000 1 500000
a
406018 635983 429225 943593 90...

correct output
.a...aa.....a.aaaa.a.aaa..aa.a...

user output
.a...aa.....a.aaaa.a.aaa..aa.a...

Test 10

Group: 3

Verdict: ACCEPTED

input
1000000 10 500000
frvhrhlrxi
85148 459715 677814 98302 4081...

correct output
frvhfrvhrhlrxihrhlrxifrvhrfrvf...

user output
frvhfrvhrhlrxihrhlrxifrvhrfrvf...

Test 11

Group: 3

Verdict: ACCEPTED

input
1000000 1000 500000
hklmkntjqgilackgurwlerwvvfjwwr...

correct output
.hklhklmkntjqgilackgurwlerwvvf...

user output
.hklhklmkntjqgilackgurwlerwvvf...

Test 12

Group: 3

Verdict: ACCEPTED

input
1000000 10000 500000
yxajftmelgwiofcugtrvcltdemhyuu...

correct output
yxajftyxayxajftmelgwiofcugtrvc...

user output
yxajftyxayxajftmelgwiofcugtrvc...

Test 13

Group: 3

Verdict: ACCEPTED

input
1000000 100000 500000
yyzteckvutdnprlklyxgenyqpznght...

correct output
.yyyyzteckvutdnpryyzteckvutdnp...

user output
.yyyyzteckvutdnpryyzteckvutdnp...

Test 14

Group: 3

Verdict: ACCEPTED

input
1000000 1000000 500000
hhgvveiosloznsihxtccfjbizayyhl...

correct output
hhgvveiosloznsihxtccfjbizayyhl...

user output
hhgvveiosloznsihxtccfjbizayyhl...