QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589403#6409. Classical Data Structure ProblemTobo#Compile Error//C++202.7kb2024-09-25 17:42:322024-09-25 17:42:33

Judging History

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

  • [2024-09-25 17:42:33]
  • 评测
  • [2024-09-25 17:42:32]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define int unsinged
using namespace std;

const int N = 1e6 + 10, mod = 1 << 30;
int n, m, all, tot, root;
mt19937 rnd(time(0));
int siz[N], w[N], ch[N][2], b[N];
int tree_siz[N], val[N], sum[N], tag[N], x;
int newnode(int x, int s, int l)
{
    int ret = ++tot;
    b[ret] = l;
    val[ret] = x, siz[ret] = s;
    tree_siz[ret] = s;
    sum[ret] = x * s;
    return ret;
}
void pushdown(int cur)
{
    if (!tag[cur])
        return;
    if (int lc = ch[cur][0]; lc)
    {
        tag[lc] += tag[cur];
        sum[lc] += tree_siz[lc] * tag[cur];
        val[lc] += tag[cur];
    }
    if (int rc = ch[cur][1]; rc)
    {
        tag[rc] += tag[cur];
        sum[rc] += tree_siz[rc] * tag[cur];
        val[rc] += tag[cur];
    }
    tag[cur] = 0;
}
void pushup(int cur)
{
    tree_siz[cur] = siz[cur] + tree_siz[ch[cur][0]] + tree_siz[ch[cur][1]];
    sum[cur] = val[cur] * siz[cur] + sum[ch[cur][0]] + sum[ch[cur][1]];
}
int merge(int x, int y)
{
    if (!x or !y)
        return x | y;

    pushdown(x), pushdown(y);
    int ret;
    if (w[x] < w[y])
    {
        ch[x][1] = merge(ch[x][1], y);
        ret = x;
    }
    else
    {
        ch[y][0] = merge(x, ch[y][0]);
        ret = y;
    }
    pushup(ret);
    return ret;
}
pair<int, int> split(int x, int z)
{
    if (!x)
        return {0, 0};

    pushdown(x);
    if (b[x] <= z and z < b[x] + siz[x] - 1)
    {
        int cur = newnode(val[x], siz[x] - (z + 1 - b[x]), z + 1);
        siz[x] = z + 1 - b[x];
        cur = merge(cur, ch[x][1]);
        ch[x][1] = 0;
        pushup(x);
        return {x, cur};
    }

    pair<int, int> ret;
    if (z < b[x])
    {
        ret = split(ch[x][0], z);
        ch[x][0] = ret.second;
        ret.second = x;
    }
    else
    {
        ret = split(ch[x][1], z);
        ch[x][1] = ret.first;
        ret.first = x;
    }
    pushup(x);
    return ret;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    for (int i = 1; i <= n * 2 + 1; i++)
        w[i] = rnd();
    all = 1 << m;
    root = newnode(0, all, 0);

    for (int i = 1, p, q; i <= n; i++)
    {
        cin >> p >> q;
        p = (p + x) % all, q = (q + x) % all;
        if (p > q)
            swap(p, q);

        auto r1 = split(root, p - 1);
        auto r2 = split(r1.second, q);
        tag[r2.first] += i;
        val[r2.first] += i;
        sum[r2.first] += tree_siz[r2.first] * i;
        x += sum[r2.first];
        root = merge(r1.first, merge(r2.first, r2.second));
    }
    cout << x << '\n';
}
/*
 5 2
 2 1
 1 3
 3 2
 1 0
 0 2
*/

详细

answer.code:3:13: error: ‘unsinged’ does not name a type; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:6:7: note: in expansion of macro ‘int’
    6 | const int N = 1e6 + 10, mod = 1 << 30;
      |       ^~~
answer.code:3:13: error: ‘unsinged’ does not name a type; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:7:1: note: in expansion of macro ‘int’
    7 | int n, m, all, tot, root;
      | ^~~
answer.code:3:13: error: ‘unsinged’ does not name a type; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:9:1: note: in expansion of macro ‘int’
    9 | int siz[N], w[N], ch[N][2], b[N];
      | ^~~
answer.code:3:13: error: ‘unsinged’ does not name a type; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:10:1: note: in expansion of macro ‘int’
   10 | int tree_siz[N], val[N], sum[N], tag[N], x;
      | ^~~
answer.code:3:13: error: ‘unsinged’ does not name a type; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:11:1: note: in expansion of macro ‘int’
   11 | int newnode(int x, int s, int l)
      | ^~~
answer.code:20:6: error: variable or field ‘pushdown’ declared void
   20 | void pushdown(int cur)
      |      ^~~~~~~~
answer.code:3:13: error: ‘unsinged’ was not declared in this scope; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:20:15: note: in expansion of macro ‘int’
   20 | void pushdown(int cur)
      |               ^~~
answer.code:38:6: error: variable or field ‘pushup’ declared void
   38 | void pushup(int cur)
      |      ^~~~~~
answer.code:3:13: error: ‘unsinged’ was not declared in this scope; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:38:13: note: in expansion of macro ‘int’
   38 | void pushup(int cur)
      |             ^~~
answer.code:3:13: error: ‘unsinged’ does not name a type; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:43:1: note: in expansion of macro ‘int’
   43 | int merge(int x, int y)
      | ^~~
answer.code:3:13: error: ‘unsinged’ was not declared in this scope; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:63:6: note: in expansion of macro ‘int’
   63 | pair<int, int> split(int x, int z)
      |      ^~~
answer.code:3:13: error: ‘unsinged’ was not declared in this scope; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:63:11: note: in expansion of macro ‘int’
   63 | pair<int, int> split(int x, int z)
      |           ^~~
answer.code:63:14: error: template argument 1 is invalid
   63 | pair<int, int> split(int x, int z)
      |              ^
answer.code:63:14: error: template argument 2 is invalid
answer.code:3:13: error: ‘unsinged’ was not declared in this scope; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:63:22: note: in expansion of macro ‘int’
   63 | pair<int, int> split(int x, int z)
      |                      ^~~
answer.code:3:13: error: ‘unsinged’ was not declared in this scope; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:63:29: note: in expansion of macro ‘int’
   63 | pair<int, int> split(int x, int z)
      |                             ^~~
answer.code:63:34: error: expression list treated as compound expression in initializer [-fpermissive]
   63 | pair<int, int> split(int x, int z)
      |                                  ^
answer.code: In function ‘int main()’:
answer.code:101:12: error: ‘n’ was not declared in this scope; did you mean ‘yn’?
  101 |     cin >> n >> m;
      |            ^
      |            yn
answer.code:101:17: error: ‘m’ was not declared in this scope; did you mean ‘tm’?
  101 |     cin >> n >> m;
      |                 ^
      |                 tm
answer.code:3:13: error: ‘unsinged’ was not declared in this scope; did you mean ‘unsigned’?
    3 | #define int unsinged
      |             ^~~~~~~~
answer.code:102:10: note: in expansion of macro ‘int’
  102 |     for (int i = 1; i <= n * 2 + 1; i++)
      |          ^~~
answer.code:102:21: error: ‘i’ was not declared in this scope
  102 |     for (int i = 1; i <= n * 2 + 1; i++)
      |                     ^
answer.code:103:9: error: ‘w’ was not declared in this scope
  103 |         w[i] = rnd();
      |         ^
answer.code:104:5: error: ‘all’ was not declared in this scope
  104 |     all = 1 << m;
      |     ^~~
answer.code:104:5: note: suggested alternatives:
In file included from /usr/include/c++/13/filesystem:48,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200,
                 from answer.code:2:
/usr/include/c++/13/bits/fs_fwd.h:154:7: note:   ‘std::filesystem::perms::all’
  154 |       ...