Submission #1444691
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//
int N;
ll x[112345], d[112345], t[112345], ans[112345];
int a[112345], b[64][112345];
ll M, K;
int main() {
cin >> N;
REP(i, N) scanf("%lld", x + i);
cin >> M >> K;
REP(i, M) scanf("%d", a + i), a[i]--;
REP(i, N - 1) d[i] = x[i + 1] - x[i];
REP(i, N) b[0][i] = i;
REP(i, M) swap(b[0][a[i] - 1], b[0][a[i]]);
REP(i, 63) REP(j, N) b[i + 1][j] = b[i][ b[i][j] ];
REP(i, N) t[i] = i;
REP(i, 64) if (K >> i & 1) {
REP(j, N) t[j] = b[i][ t[j] ];
}
ans[0] = x[0];
REP(i, N - 1) ans[i + 1] = ans[i] + d[t[i]];
REP(i, N) printf("%lld\n", ans[i]);
return 0;
}
Submission Info
Submission Time
2017-07-23 17:13:29+0900
Task
C - Rabbit Exercise
User
tkmst201
Language
C++14 (GCC 5.4.1)
Score
800
Code Size
1262 Byte
Status
AC
Exec Time
47 ms
Memory
32896 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i, N) scanf("%lld", x + i);
^
./Main.cpp:29:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i, M) scanf("%d", a + i), a[i]--;
^
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
7 ms
28928 KB
0_01.txt
AC
7 ms
28928 KB
0_02.txt
AC
7 ms
28928 KB
1_00.txt
AC
7 ms
29056 KB
1_01.txt
AC
7 ms
28928 KB
1_02.txt
AC
38 ms
32896 KB
1_03.txt
AC
47 ms
32896 KB
1_04.txt
AC
37 ms
31616 KB
1_05.txt
AC
8 ms
28928 KB
1_06.txt
AC
13 ms
28928 KB
1_07.txt
AC
10 ms
28928 KB
1_08.txt
AC
12 ms
28928 KB
1_09.txt
AC
12 ms
28928 KB
1_10.txt
AC
8 ms
28928 KB
1_11.txt
AC
10 ms
28928 KB
1_12.txt
AC
7 ms
28928 KB
1_13.txt
AC
13 ms
28928 KB
1_14.txt
AC
11 ms
28928 KB
1_15.txt
AC
16 ms
29312 KB
1_16.txt
AC
9 ms
29184 KB
1_17.txt
AC
28 ms
30464 KB
1_18.txt
AC
32 ms
30976 KB
1_19.txt
AC
38 ms
31744 KB
1_20.txt
AC
22 ms
29696 KB
1_21.txt
AC
22 ms
29952 KB
1_22.txt
AC
38 ms
31744 KB
1_23.txt
AC
36 ms
32256 KB
1_24.txt
AC
27 ms
31360 KB
1_25.txt
AC
41 ms
32128 KB