Submission #74524470
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int n, m, a[100010];
long long k;
int x[100010];
using P = array<int, 100010>;
void mul(P &a, const P &b){
static P r;
for (int i = 1; i <= n; ++i)r[i] = a[b[i]];
copy_n(r.begin() + 1, n, a.begin() + 1);
}
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i)cin >> x[i];
for (int i = n; i > 1; --i)x[i] -= x[i - 1];
cin >> m >> k;
static P g;
iota(g.begin() + 1, g.begin() + n + 1, 1);
while (m--){
int a;
cin >> a;
swap(g[a], g[a + 1]);
}
static P e;
iota(e.begin() + 1, e.begin() + n + 1, 1);
for (; k; k >>= 1, mul(g, g))
if (k & 1)mul(e, g);
long long s = 0;
for (int i = 1; i <= n; ++i)cout << (s += x[e[i]]) << "\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Rabbit Exercise |
| User | szt100309 |
| Language | C++23 (GCC 15.2.0) |
| Score | 800 |
| Code Size | 863 Byte |
| Status | AC |
| Exec Time | 17 ms |
| Memory | 5228 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 800 / 800 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 0_00.txt, 0_01.txt, 0_02.txt |
| All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_00.txt | AC | 1 ms | 3692 KiB |
| 0_01.txt | AC | 1 ms | 3632 KiB |
| 0_02.txt | AC | 1 ms | 3616 KiB |
| 1_00.txt | AC | 1 ms | 3748 KiB |
| 1_01.txt | AC | 1 ms | 3760 KiB |
| 1_02.txt | AC | 14 ms | 5228 KiB |
| 1_03.txt | AC | 17 ms | 5228 KiB |
| 1_04.txt | AC | 12 ms | 4848 KiB |
| 1_05.txt | AC | 2 ms | 3688 KiB |
| 1_06.txt | AC | 3 ms | 3688 KiB |
| 1_07.txt | AC | 2 ms | 3616 KiB |
| 1_08.txt | AC | 2 ms | 3608 KiB |
| 1_09.txt | AC | 2 ms | 3692 KiB |
| 1_10.txt | AC | 1 ms | 3792 KiB |
| 1_11.txt | AC | 2 ms | 3824 KiB |
| 1_12.txt | AC | 1 ms | 3656 KiB |
| 1_13.txt | AC | 3 ms | 3872 KiB |
| 1_14.txt | AC | 2 ms | 3608 KiB |
| 1_15.txt | AC | 4 ms | 3844 KiB |
| 1_16.txt | AC | 2 ms | 3820 KiB |
| 1_17.txt | AC | 9 ms | 4332 KiB |
| 1_18.txt | AC | 11 ms | 4484 KiB |
| 1_19.txt | AC | 13 ms | 4848 KiB |
| 1_20.txt | AC | 7 ms | 4004 KiB |
| 1_21.txt | AC | 7 ms | 4172 KiB |
| 1_22.txt | AC | 13 ms | 4716 KiB |
| 1_23.txt | AC | 13 ms | 4888 KiB |
| 1_24.txt | AC | 9 ms | 4588 KiB |
| 1_25.txt | AC | 13 ms | 5192 KiB |