[Ynoi2000] pri

Luogu
IDLGP10028
Time5000ms
Memory512MB
DifficultyP7
2000O2优化Ynoi
给定 $1,\dots,n$ 的排列 $a_1,\dots,a_n$ ; 共 $m$ 次操作,每次操作给出 $x$ ,首先进行修改,将 $a_1,a_2,\dots,a_x$ 翻转为 $a_x,\dots,a_2,a_1$ ,然后查询有多少组不同的 $(i,j)$ ,满足 $1\le i<j\le x$ 使得 $a_i<a_j$ 。 ## Input 第一行两个整数 $n,m$ ; 第二行 $n$ 个整数依次表示 $a_1,\dots,a_n$ ; 接下来 $m$ 行,每行一个整数 $x$ ,表示一次操作。 ## Output 共 $m$ 行,每行一个整数,依次表示每次操作的查询的答案。 [samples] ## Note Idea:ccz181078,Solution:ccz181078,Code:ccz181078,Data:ccz181078 所有数值为整数。 对于 $100\%$ 的数据,满足 $1\le a_i\le n$,$1\le x\le n$,$1\le n\le 2\times 10^5,\;1\le m\le 5\times 10^4$。
Samples
Input #1
6 5
5 4 2 3 1 6
3
5
6
3
6
Output #1
3
6
4
2
10
API Response (JSON)
{
  "problem": {
    "name": "[Ynoi2000] pri",
    "description": {
      "content": "给定 $1,\\dots,n$ 的排列 $a_1,\\dots,a_n$ ; 共 $m$ 次操作,每次操作给出 $x$ ,首先进行修改,将 $a_1,a_2,\\dots,a_x$ 翻转为 $a_x,\\dots,a_2,a_1$ ,然后查询有多少组不同的 $(i,j)$ ,满足 $1\\le i<j\\le x$ 使得 $a_i<a_j$ 。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 5000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P7"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10028"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定 $1,\\dots,n$ 的排列 $a_1,\\dots,a_n$ ;\n\n共 $m$ 次操作,每次操作给出 $x$ ,首先进行修改,将 $a_1,a_2,\\dots,a_x$ 翻转为 $a_x,\\dots,a_2,a_1$ ,然后查询有多少组不同的 $(i,j)$ ,满足 $1\\le i<j\\le x$ 使得 $a_i<a_j$ 。\n\n## Input\n\n第一行两个整数 $n,m$ ;\n\n第二行...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments