EndSaH @ 2018-12-05 13:21:39
就差 #18 一个点了
代码:
/**********************************************************
* Author : EndSaH
* Email : [email protected]
* Created Time : 2018-12-04 19:45
* FileName : temp.cpp
* Website : https://endsah.cf
* *******************************************************/
%:pragma GCC optimize("Ofast")
#include <unistd.h>
#include <sys/mman.h>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <stack>
#define read(x)\
x = 0;\
while(!isdigit(*ipos))\
++ipos;\
while(x = (x << 3) + (x << 1) + (*ipos & 15), isdigit(*++ipos));
#define write(x)\
do\
{\
*++stkpos = x % 10 ^ 48;\
x /= 10;\
} while(x);\
while(stkpos != stk)\
*opos++ = *stkpos--;
typedef unsigned int uint;
char stk[10], obuf[1 << 20];
uint a[40001], b[40001], val[40001], buk[40001];
int main()
{
#ifndef ONLINE_JUDGE
freopen("temp.in", "r", stdin);
freopen("temp.out", "w", stdout);
#endif
register char *ipos = (char*)mmap(NULL, 1 << 20, PROT_READ, MAP_PRIVATE, 0, 0), *opos = obuf, *stkpos = stk;
register uint n, m, lastans = 0, tmp1, tmp2, nn, l, r;
read(n); read(m);
for(register uint i = 1, *p = a + 1; i <= n; ++i, ++p)
{
read(a[i]);
b[i] = *p;
}
std::sort(b + 1, b + n + 1);
nn = std::unique(b + 1, b + n + 1) - b - 1;
for(register uint i = 1; i <= n; ++i)
val[i] = std::lower_bound(b + 1, b + nn + 1, a[i]) - b;
while(m--)
{
read(l); read(r);
l = (l + lastans - 1) % n + 1, r = (r + lastans - 1) % n + 1;
if(l > r)
std::swap(l, r);
tmp1 = tmp2 = 0;
memset(buk + 1, 0, nn << 2);
for(register uint i = l; i <= r; ++i)
{
register uint *p = &buk[val[i]];
++*p;
if(*p > tmp1)
{
tmp1 = *p;
tmp2 = val[i];
}
else if(*p == tmp1 and tmp2 > val[i])
tmp2 = val[i];
}
lastans = b[tmp2];
tmp1 = lastans;
write(tmp1); *opos++ = '\n';
}
fwrite(obuf, 1, opos - obuf, stdout);
return 0;
}
by Aleph1022 @ 2018-12-05 13:29:20
……写个分块会死嘛
by EndSaH @ 2018-12-05 13:30:42
@alpha1022 会
by 吹雪吹雪吹 @ 2018-12-05 14:25:08
卡常?再见。我自带大常数。
by Blaze @ 2018-12-07 21:39:28
asm
by DengTJ @ 2018-12-22 09:06:40
%%%
by EndSaH @ 2018-12-24 21:11:41
好吧 我的写法有点问题- -换了个暴力写法就过了