답안 #475054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475054 2021-09-20T21:50:50 Z nickmet2004 Addk (eJOI21_addk) C++11
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
 
const int N = 1e6 + 5;
int n , k , q,a[N] , Y[11];
struct Node{
    int F , S;
    Node operator+(Node b){
        Node ret;
        ret.F = F + b.F;
        ret.S = S + b.S;
        return ret;
    }
};
struct ST{
    Node T[4*N];
    void upd(int id , int d , int l = 1 , int r = n , int pos = 1){
        if(id < l || id > r) return;
        if(l==r){
            T[pos].F = d , T[pos].S = d*id;
            return;
        }
        int mid = (l + r) >> 1;
        upd(id , d , l , mid , pos *2 + 1); upd(id , d , mid + 1 , r , pos * 2 + 2);
        T[pos] = T[pos * 2 + 1] + T[pos * 2 + 2];
    }
    Node get(int L , int R , int l = 1 , int r = n , int pos = 1){
        if(r < L || R < l) return {0 ,0};
        if(L<=l&&r<=R) return T[pos];
        int mid = (l + r) >> 1;
        return get(L , R , l , mid , pos * 2 + 1) + get(L , R ,mid + 1 , r , pos * 2 + 2);
    }
}L;

 main (){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; ++i)cin >> a[i];
    for(int i = 1; i<= n; ++i)
        L.upd(i , a[i]);
 cin >> q;
 
    while(q--){
        int tp;
        cin >> tp;
        if(tp==1){
            for(int i = 0; i < k; ++i)cin >> Y[i];
            sort(Y , Y + k);
            for(int i = 1; i < k; ++i) swap(a[Y[i]] , a[Y[i - 1]]);
            for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
        }else {
            int l , r , m;
            cin >> l >> r >> m;
            m = min(m , r - l - m + 2);
            int ans = 0;
            Node gR = L.get(0 , l + m - 1);
            Node gL = L.get(0 , l - 1);
            ans += (gR.S - gL.S - (l - 1) * (gR.F - gL.F));
            ans += (L.get(0 , r - m).F - L.get(0 , l + m - 1).F)*m;
            ans += (r+1)*(gR.F-gL.F) - (gR.S-gL.s);
            cout << ans << endl;
        }
    }
}

Compilation message

Main.cpp:41:2: error: extended character   is not valid in an identifier
   41 |         L.upd(i , a[i]);
      |  ^
Main.cpp:41:5: error: extended character   is not valid in an identifier
   41 |         L.upd(i , a[i]);
      |    ^
Main.cpp:41:8: error: extended character   is not valid in an identifier
   41 |         L.upd(i , a[i]);
      |      ^
Main.cpp:41:11: error: extended character   is not valid in an identifier
   41 |         L.upd(i , a[i]);
      |        ^
Main.cpp:51:2: error: extended character   is not valid in an identifier
   51 |             for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
      |  ^
Main.cpp:51:5: error: extended character   is not valid in an identifier
   51 |             for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
      |    ^
Main.cpp:51:8: error: extended character   is not valid in an identifier
   51 |             for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
      |      ^
Main.cpp:51:11: error: extended character   is not valid in an identifier
   51 |             for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
      |        ^
Main.cpp:51:14: error: extended character   is not valid in an identifier
   51 |             for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
      |          ^
Main.cpp:51:17: error: extended character   is not valid in an identifier
   51 |             for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
      |            ^
Main.cpp:52:2: error: extended character   is not valid in an identifier
   52 |         }else {
      |  ^
Main.cpp:52:5: error: extended character   is not valid in an identifier
   52 |         }else {
      |    ^
Main.cpp:52:8: error: extended character   is not valid in an identifier
   52 |         }else {
      |      ^
Main.cpp:61:2: error: extended character   is not valid in an identifier
   61 |             ans += (r+1)*(gR.F-gL.F) - (gR.S-gL.s);
      |  ^
Main.cpp:61:5: error: extended character   is not valid in an identifier
   61 |             ans += (r+1)*(gR.F-gL.F) - (gR.S-gL.s);
      |    ^
Main.cpp:61:8: error: extended character   is not valid in an identifier
   61 |             ans += (r+1)*(gR.F-gL.F) - (gR.S-gL.s);
      |      ^
Main.cpp:61:11: error: extended character   is not valid in an identifier
   61 |             ans += (r+1)*(gR.F-gL.F) - (gR.S-gL.s);
      |        ^
Main.cpp:61:14: error: extended character   is not valid in an identifier
   61 |             ans += (r+1)*(gR.F-gL.F) - (gR.S-gL.s);
      |          ^
Main.cpp:61:17: error: extended character   is not valid in an identifier
   61 |             ans += (r+1)*(gR.F-gL.F) - (gR.S-gL.s);
      |            ^
Main.cpp:36:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 |  main (){
      |  ^~~~
Main.cpp: In function 'int main()':
Main.cpp:41:2: error: '\U000000a0' was not declared in this scope
   41 |         L.upd(i , a[i]);
      |  ^
Main.cpp:51:2: error: '\U000000a0' was not declared in this scope
   51 |             for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
      |  ^
Main.cpp:51:34: error: 'i' was not declared in this scope
   51 |             for(int i = 0; i < k; ++i) L.upd(Y[i] , a[Y[i]]);
      |                            ^
Main.cpp:52:4: error: expected ';' before '\U000000a0'
   52 |         }else {
      |   ^~
      |   ;
Main.cpp:61:2: error: '\U000000a0' was not declared in this scope
   61 |             ans += (r+1)*(gR.F-gL.F) - (gR.S-gL.s);
      |  ^