QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#248238#7627. Phonyucup-team037#Compile Error//C++173.7kb2023-11-11 17:59:132023-11-11 17:59:15

Judging History

你现在查看的是最新测评结果

  • [2023-11-11 17:59:15]
  • 评测
  • [2023-11-11 17:59:13]
  • 提交

answer


// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 500005;

int n, m;
ll k;
ll a[MAXN];
map<ll, vll> ev;

indexed_set st;

int main() {
#ifndef DEBUG
    ios::sync_with_stdio(0), cin.tie(0);
#endif
    cin >> n >> m >> k;
    REP (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    ll mxd = 0;
    REP (i, 0, n) {
        ll d = a[i] / k, r = a[i] % k;
        ev[d].pb(r);
        mxto(mxd, d);
    }
    for (ll r : ev[mxd]) {
        st.insert(r);
    }
    ev.erase(mxd);
    for (auto [d, vr] : ev) {
        sort(ALL(vr));
    }
    int off = 0;
    while (m--) {
        char t; ll x; cin >> t >> x;
        if (t == 'C') {
            ll xd = x / SZ(st), xr = x % SZ(st);
            if (off && xd) {
                xr += SZ(st);
                xd--;
            }
            if (xr + off >= SZ(st)) {
                x -= SZ(st) - off;
                mxd--;
                off = 0;
                if (ev.find(mxd) != ev.end()) {
                    for (ll r : ev[mxd]) {
                        st.insert(r);
                    }
                    ev.erase(mxd);
                }
            }
            xd = x / SZ(st), xr = x % SZ(st);
            while (!ev.empty() && mxd - xd <= prev(ev.end()) -> FI) {
                auto [d, vr] = *prev(ev.end());
                assert(off == 0);
                x -= SZ(st) * (mxd - d);
                mxd = d;
                for (ll r : ev[mxd]) {
                    st.insert(r);
                }
                ev.erase(mxd);
                xd = x / SZ(st), xr = x % SZ(st);
            }
            mxd -= xd;
            x -= xd * SZ(st);
            xd = 0;
            off += xr;
            x -= xr;
            assert(x == 0);
            assert(off < SZ(st));
            if (off) {
                while (!ev[mxd - 1].empty() && ev[mxd - 1].back() >
                        *st.find_by_order(SZ(st) - off)) {
                    ll nr = ev[mxd - 1].back(); ev[mxd - 1].pop_back();
                    st.insert(nr);
                    off++;
                }
            }
        } else {
            if (x > SZ(st)) {
                cout << a[n - x] << '\n';
            } else {
                if (off + x <= SZ(st)) {
                    int id = SZ(st) - (off + x);
                    ll r = *st.find_by_order(id);
                    cout << mxd * k + r << '\n';
                } else {
                    int id = SZ(st) - (off + x - SZ(st));
                    ll r = *st.find_by_order(id);
                    cout << (mxd - 1) * k + r << '\n';
                }
            }
        }
    }
}

Details

answer.code:12:14: error: ‘ll’ was not declared in this scope
   12 | typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
      |              ^~
answer.code:12:40: error: ‘ll’ was not declared in this scope
   12 | typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
      |                                        ^~
answer.code:12:42: error: template argument 1 is invalid
   12 | typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
      |                                          ^
answer.code:12:91: error: template argument 1 is invalid
   12 | typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
      |                                                                                           ^
answer.code:12:91: error: template argument 3 is invalid
answer.code: In function ‘int main()’:
answer.code:68:12: error: request for member ‘insert’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   68 |         st.insert(r);
      |            ^~~~~~
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:78:25: note: in expansion of macro ‘SZ’
   78 |             ll xd = x / SZ(st), xr = x % SZ(st);
      |                         ^~
answer.code:80:17: error: ‘xr’ was not declared in this scope; did you mean ‘xd’?
   80 |                 xr += SZ(st);
      |                 ^~
      |                 xd
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:80:23: note: in expansion of macro ‘SZ’
   80 |                 xr += SZ(st);
      |                       ^~
answer.code:83:17: error: ‘xr’ was not declared in this scope; did you mean ‘xd’?
   83 |             if (xr + off >= SZ(st)) {
      |                 ^~
      |                 xd
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:83:29: note: in expansion of macro ‘SZ’
   83 |             if (xr + off >= SZ(st)) {
      |                             ^~
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:84:22: note: in expansion of macro ‘SZ’
   84 |                 x -= SZ(st) - off;
      |                      ^~
answer.code:89:28: error: request for member ‘insert’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   89 |                         st.insert(r);
      |                            ^~~~~~
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:94:22: note: in expansion of macro ‘SZ’
   94 |             xd = x / SZ(st), xr = x % SZ(st);
      |                      ^~
answer.code:94:30: error: ‘xr’ was not declared in this scope; did you mean ‘xd’?
   94 |             xd = x / SZ(st), xr = x % SZ(st);
      |                              ^~
      |                              xd
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:94:39: note: in expansion of macro ‘SZ’
   94 |             xd = x / SZ(st), xr = x % SZ(st);
      |                                       ^~
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:98:22: note: in expansion of macro ‘SZ’
   98 |                 x -= SZ(st) * (mxd - d);
      |                      ^~
answer.code:101:24: error: request for member ‘insert’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
  101 |                     st.insert(r);
      |                        ^~~~~~
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:104:26: note: in expansion of macro ‘SZ’
  104 |                 xd = x / SZ(st), xr = x % SZ(st);
      |                          ^~
answer.code:30:25: error: request for member ‘size’ in ‘st’, which is of non-class type ‘indexed_set’ {aka ‘int’}
   30 | #define SZ(_a) (int) _a.size()
      |                         ^~~~
answer.code:104:43: note: in e...