Task: | Leimasin |
Sender: | jhuun |
Submission time: | 2025-09-27 20:18:39 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 33 |
#2 | ACCEPTED | 43 |
#3 | ACCEPTED | 24 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.01 s | 2, 3 | details |
#6 | ACCEPTED | 0.00 s | 2, 3 | details |
#7 | ACCEPTED | 0.01 s | 2, 3 | details |
#8 | ACCEPTED | 0.01 s | 2, 3 | details |
#9 | ACCEPTED | 0.58 s | 3 | details |
#10 | ACCEPTED | 0.34 s | 3 | details |
#11 | ACCEPTED | 0.18 s | 3 | details |
#12 | ACCEPTED | 0.18 s | 3 | details |
#13 | ACCEPTED | 0.19 s | 3 | details |
#14 | ACCEPTED | 0.12 s | 3 | details |
Code
#include <bits/stdc++.h> #define MIN(a, b) ((a) < (b) ? (a) : (b)) int main() { int n, m, k; std::string M; std::cin >> n >> m >> k >> M; std::string res(n, '.'); std::vector<int> P(k); for (int i = 0; i < k; ++i) { std::cin >> P[i]; --P[i]; } std::set<std::pair<int, int>> E{{P.back(), P.back() + m}}; std::memcpy(res.data() + P.back(), M.data(), m); for (const auto p : P | std::views::reverse | std::views::drop(1)) { auto next = E.upper_bound({p, n}); auto prev = std::prev(next); const auto [sp, ep] = *prev; const auto [sn, en] = next != E.end() ? *next : std::pair<int, int>{n + n, n + n}; const auto ip = p >= sp && p < ep; const auto in = p + m >= sn; if (ip && in) { E.erase(prev); E.erase(next); E.emplace(sp, en); std::memcpy(res.data() + ep, M.data() + (ep - p), MIN(m + p - ep, sn - ep)); } else if (ip) { if (p >= sp && p + m <= ep) { continue; } E.erase(prev); E.emplace(sp, p + m); std::memcpy(res.data() + ep, M.data() + (ep - p), p + m - ep); } else if (in) { E.erase(next); E.emplace(p, en); std::memcpy(res.data() + p, M.data(), sn - p); } else { E.emplace(p, p + m); std::memcpy(res.data() + p, M.data(), m); } } std::cout << res << '\n'; }
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... |