# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1034785 |
2024-07-25T18:12:13 Z |
vuh |
Addk (eJOI21_addk) |
C++14 |
|
598 ms |
2696 KB |
#include <bits/stdc++.h>
// www //
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define ll long long
#define pb push_back
#define pqi priority_queue <pair<int,int>,greater<int>>
#define vi vector <int>
#define vll vector<ll>
#define fori for(int i=0 ;i<n ;i++)
#define forj for(int j=0 ;j<n ;j++)
#define rep(i,a,b) for (int i=a; i<=b; ++i)
#define rev(i,a,b) for (int i=a; i>=b; --i)
#define cina fori{cin>>a[i];}
#define all(v) v.begin(), v.end()
#define endl "\n"
//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
vi dx = {0, 0, -1, 1}, dy = {-1, 1, 0, 0};
vi dx2 = {1, 1, 0, -1, -1, -1, 0, 1}, dy2 = {0, 1, 1, 1, 0, -1, -1, -1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 10; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size1 3
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return mod_add(arr[0], 0, b);} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;} //only for prime m
ll combination(ll n, ll r, ll m, ll *fact, ll *ifact) {ll val1 = fact[n]; ll val2 = ifact[n - r]; ll val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}
vector<ll> sieve(int n) {int*arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
ll phin(ll n) {ll number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0) n /= 2;} for (ll i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))
ll getRandomNumber(ll l, ll r) {return uniform_int_distribution<ll>(l, r)(rng);}
/*--------------------------------------------------------------------------------------------------------------------------*/
const int inf = INT_MAX;
const ll mod = 1e9 + 7;
const int sz = 1e5+5;
const int b = 41;
// vuh //
vi parent,checkcycle;
vector <pair <int,int>> variants;
vector <vector <int>> g;
vector <bool> check;
int a[sz];
ll st[4 * sz],lz[4 * sz];
bool bo = 0;
int sa[sz], pos[sz], tmp[sz], lcp[sz];
void build(int l,int r,int v){
if(l == r){
st[v] = a[l];
return;
}
int mid = (l + r) / 2;
build(l,mid,v * 2);
build(mid + 1,r,v * 2 + 1);
st[v] = st[v * 2] + st[v * 2 + 1];
}
void uptade(ll l,ll r,ll v,ll x,ll w){
if(x < l || x > r)
return;
if(l == r){
st[v] = w;
return;
}
ll mid = (l + r) / 2;
uptade(l,mid,v * 2,x,w);
uptade(mid + 1,r,v * 2 + 1,x,w);
st[v] = st[v * 2] + st[v * 2 + 1];
}
ll getans(ll ql,ll qr,ll l,ll r,ll v){
if(ql > r || qr < l)
return 0;
if(ql <= l && qr >= r)
return st[v];
ll mid = (l + r) / 2;
ll q1 = getans(ql,qr,l,mid,v * 2);
ll q2 = getans(ql,qr,mid + 1,r,v * 2 + 1);
return q1 + q2;
}
bool f() {
//off
}
//const int dx[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void solve() {
int n,k,q;
cin>>n>>k;
rep(i,1,n){
cin>>a[i];
}
cin>>q;
while(q--){
int t;
cin>>t;
if(t == 1){
int b[k + 1],af[k + 1];
rep(i,1,k){
cin>>b[i];
}
rep(i,1,k){
if(i == k){
af[k] = b[i];
}
else{
af[i] = b[i + 1];
}
}
rep(i,1,k){
a[b[i]] = a[af[i]];
}
}
else{
int l,r,m,sum = 0,x = 0;
cin>>l>>r>>m;
if(r - l + 1 == m){
rep(i,l,r){
sum += a[i];
}
}
else{
while(l < r){
if(x != m){
x++;
}
sum += x * (a[l] + a[r]);
l++;
r--;
}
if((r - l + 1) % 2 == 1){
if(x != m){
x++;
}
sum += x * a[(r + l) / 2];
}
}
cout<<sum<<endl;
}
}
//cout<<endl;
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(0);
int t = 1;
//cin>>t;
while(t--)
solve();
return 0;
}
Compilation message
Main.cpp: In function 'bool f()':
Main.cpp:86:1: warning: no return statement in function returning non-void [-Wreturn-type]
86 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
152 ms |
1192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
598 ms |
2696 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |