답안 #1034790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1034790 2024-07-25T18:22:32 Z vuh Addk (eJOI21_addk) C++14
컴파일 오류
0 ms 0 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 vctor <int>
#define vll vctor<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_t, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//template<class T> using ordered_multiset = tree<T, null_t, 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;}
vctor<ll> siev(int n) {int*arr = new int[n + 1](); vctor<ll> vct; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vct.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vct;}
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;
vctor <pair <int,int>> variants;
vctor <vctor <int>> g;
vctor <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 solv() {
    int n,k;
    cin>>n>>k;
    vctor<int> a(n + 1);
    vctor<ll> pref(n + 1);
    vctor<ll> ppref(n + 1);
    for (int i = 1; i <= n; ++i)
        cin >> a[i], pref[i] = pref[i - 1] + a[i];
    for (int i = 1; i <= n; ++i) 
        ppref[i] = ppref[i - 1] + pref[i];
    int q;
    cin>>q;
    while(q--) {
        int t;
        cin>>t;
        if(t == 2) {
            int l,r,x;
            cin>>l>>r>>x;
            ll ans = 0;
            if(l == 1){
                ans -= ppref[r - x];
            }
            else{
                ans -= ppref[r - x] - ppref[l - 2];
            }
            ans += ppref[r] - ppref[l + x - 2];
            cout<<ans<<endl;
        }
        else{
            vctor<int> v(k);
            for (int i = 0; i < k; ++i)
                cin>>v[i];
            int last = a[v[0]];
            for (int i = 0; i < k - 1; ++i)
                a[v[ i]] = a[v[i + 1]];
            a[v.back()] = last;
            for (int i = 1; i <= n; ++i)
                pref[i] = pref[i - 1] + a[i];
            for (int i = 1; i <= n; ++i)
                ppref[i] = ppref[i - 1] + pref[i];
        }
    }
 
    //cout<<endl;
}
signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int t = 1;
	//cin>>t;
	while(t--)
        solv();
 
    return 0;
}

Compilation message

Main.cpp:9:12: error: 'vctor' does not name a type
    9 | #define vi vctor <int>
      |            ^~~~~
Main.cpp:20:1: note: in expansion of macro 'vi'
   20 | vi dx = {0, 0, -1, 1}, dy = {-1, 1, 0, 0};
      | ^~
Main.cpp:20:22: error: expected unqualified-id before ',' token
   20 | vi dx = {0, 0, -1, 1}, dy = {-1, 1, 0, 0};
      |                      ^
Main.cpp:20:27: error: expected constructor, destructor, or type conversion before '=' token
   20 | vi dx = {0, 0, -1, 1}, dy = {-1, 1, 0, 0};
      |                           ^
Main.cpp:9:12: error: 'vctor' does not name a type
    9 | #define vi vctor <int>
      |            ^~~~~
Main.cpp:21:1: note: in expansion of macro 'vi'
   21 | vi dx2 = {1, 1, 0, -1, -1, -1, 0, 1}, dy2 = {0, 1, 1, 1, 0, -1, -1, -1};
      | ^~
Main.cpp:21:37: error: expected unqualified-id before ',' token
   21 | vi dx2 = {1, 1, 0, -1, -1, -1, 0, 1}, dy2 = {0, 1, 1, 1, 0, -1, -1, -1};
      |                                     ^
Main.cpp:21:43: error: expected constructor, destructor, or type conversion before '=' token
   21 | vi dx2 = {1, 1, 0, -1, -1, -1, 0, 1}, dy2 = {0, 1, 1, 1, 0, -1, -1, -1};
      |                                           ^
Main.cpp:35:1: error: 'vctor' does not name a type
   35 | vctor<ll> siev(int n) {int*arr = new int[n + 1](); vctor<ll> vct; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vct.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vct;}
      | ^~~~~
Main.cpp:9:12: error: 'vctor' does not name a type
    9 | #define vi vctor <int>
      |            ^~~~~
Main.cpp:44:1: note: in expansion of macro 'vi'
   44 | vi parent,checkcycle;
      | ^~
Main.cpp:45:1: error: 'vctor' does not name a type
   45 | vctor <pair <int,int>> variants;
      | ^~~~~
Main.cpp:46:1: error: 'vctor' does not name a type
   46 | vctor <vctor <int>> g;
      | ^~~~~
Main.cpp:47:1: error: 'vctor' does not name a type
   47 | vctor <bool> check;
      | ^~~~~
Main.cpp: In function 'bool f()':
Main.cpp:86:1: warning: no return statement in function returning non-void [-Wreturn-type]
   86 | }
      | ^
Main.cpp: In function 'void solv()':
Main.cpp:91:5: error: 'vctor' was not declared in this scope
   91 |     vctor<int> a(n + 1);
      |     ^~~~~
Main.cpp:91:11: error: expected primary-expression before 'int'
   91 |     vctor<int> a(n + 1);
      |           ^~~
Main.cpp:6:12: error: expected primary-expression before 'long'
    6 | #define ll long long
      |            ^~~~
Main.cpp:92:11: note: in expansion of macro 'll'
   92 |     vctor<ll> pref(n + 1);
      |           ^~
Main.cpp:6:12: error: expected primary-expression before 'long'
    6 | #define ll long long
      |            ^~~~
Main.cpp:93:11: note: in expansion of macro 'll'
   93 |     vctor<ll> ppref(n + 1);
      |           ^~
Main.cpp:95:22: error: 'pref' was not declared in this scope
   95 |         cin >> a[i], pref[i] = pref[i - 1] + a[i];
      |                      ^~~~
Main.cpp:97:9: error: 'ppref' was not declared in this scope
   97 |         ppref[i] = ppref[i - 1] + pref[i];
      |         ^~~~~
Main.cpp:97:35: error: 'pref' was not declared in this scope
   97 |         ppref[i] = ppref[i - 1] + pref[i];
      |                                   ^~~~
Main.cpp:108:24: error: 'ppref' was not declared in this scope
  108 |                 ans -= ppref[r - x];
      |                        ^~~~~
Main.cpp:111:24: error: 'ppref' was not declared in this scope
  111 |                 ans -= ppref[r - x] - ppref[l - 2];
      |                        ^~~~~
Main.cpp:113:20: error: 'ppref' was not declared in this scope
  113 |             ans += ppref[r] - ppref[l + x - 2];
      |                    ^~~~~
Main.cpp:117:19: error: expected primary-expression before 'int'
  117 |             vctor<int> v(k);
      |                   ^~~
Main.cpp:119:22: error: 'v' was not declared in this scope
  119 |                 cin>>v[i];
      |                      ^
Main.cpp:120:26: error: 'v' was not declared in this scope
  120 |             int last = a[v[0]];
      |                          ^
Main.cpp:125:17: error: 'pref' was not declared in this scope
  125 |                 pref[i] = pref[i - 1] + a[i];
      |                 ^~~~
Main.cpp:127:17: error: 'ppref' was not declared in this scope
  127 |                 ppref[i] = ppref[i - 1] + pref[i];
      |                 ^~~~~
Main.cpp:127:43: error: 'pref' was not declared in this scope
  127 |                 ppref[i] = ppref[i - 1] + pref[i];
      |                                           ^~~~