又双叒叕炸了。
T1 lucky
从x + 1 枚举到 10 ^ 6 - 1即可
T2 gcd
一般思路:O(n ^ 2)求gcd(a[i], b[j] )
文艺思路:不知道
2B思路:O(n ^ 2)求gcd(a[i], b[i] ) (然后就只过了两个点(还能过两个点))
T3 purchase
一看只有五个品牌,想写个可并堆骗分
然后是个可并堆的都被我忘了
然后就写了个priority queue
暴力查找完就T飞了
for (int i = 1 ; i <= q ; i++)
{
int d = read();
priority_queue < int , vector<int> , greater<int> > q;
for (int i = 1 ; i <= d ; i++)
{
int l = read();
for (int j = 1 ; j <= t [l] ; j++)
q.push( v[l][j] );
}
int k = read();
if (q.size() < k)
{
printf("-1\n");
continue;
}
for (int i = 1 ; i < k ; i ++)
q.pop();
printf("%d\n", q.top() );
}
T4 string
一般思路:暴力
文艺思路:DP
2B思路:输出-1(还有10分)
文艺思路:DP
2B思路:输出-1(还有10分)
T5 array
这道LJ线段树调了两个半小时然后就全炸了
(分数跟暴力一样)
为了纪念这道LJ线段树还是将代码贴上来
#include <bits/stdc++.h>
using namespace std;
const long long m[10] = { 1,2,6,24,120,720,5040,40320,362880,3628800 };
inline int read()
{
int sum = 0, flag = 1;
char c = getchar();
for (; c < '0' || c > '9'; c = getchar() )
if ( ! ( c ^ '-') ) flag = -1;
for (; c >= '0' && c <= '9'; c = getchar() )
sum = (sum << 3) + (sum << 1) + (c ^ 48);
return sum * flag;
}
int n = read(), q = read();
int x, y;
int a[500005];
struct hazaking
{
long long sum, mul, add;
int cs;
}tr[500005];
inline void mull(int p, int x)
{
while (x > 9)
{
x /= 10;
tr[p].mul = ( tr[p].mul * m[9] ) % 1000000000;
}
tr[p].mul = (tr[p].mul * m[ x - 1 ] ) % 1000000000;
}
inline void pushup(int p)
{
int lson = p << 1, rson = p << 1 | 1;
tr[p].sum = tr[lson].sum + tr[rson].sum;
tr[p].mul = tr[lson].mul + tr[rson].mul;
return;
}
void build(int p, int l, int r)
{
tr[p].sum = 0;
tr[p].add = 0;
tr[p].mul = 0;
tr[p].cs = 0;
if ( ! (l ^ r) )
{
tr[p].sum = ( long long ) (a[l]);
tr[p].mul = 1;
tr[p].cs = a[l];
//printf("l:%d r:%d p:%d tr[p].cs:%d tr[p].add:%lld tr[p].mul:%lld tr[p].sum:%lld\n",l,r,p,tr[p].cs,tr[p].add,tr[p].mul, tr[p].sum);
mull(p, a[l]);
return;
}
int mid = l + r >> 1;
build(p << 1, l, mid);
build(p << 1 | 1, mid + 1, r);
pushup(p);
}
inline void pushdown(int p, int l, int r)
{
int lson = p << 1, rson = p << 1 | 1;
int mid = l + r >> 1;
if (tr[p].add)
{
tr[lson].add += tr[p].add;
tr[rson].add += tr[p].add;
tr[lson].sum += tr[p].add * (mid - l + 1);
tr[rson].sum += tr[p].add * (r - mid);
tr[p].add = 0;
}
return;
}
void change0(int p, int l, int r)
{
if (r < x || l > y) return;
if (l >= x && r <= y)
{
//printf("CHANGEQQ:l:%d r:%d p:%d tr[p].cs:%d tr[p].add:%lld tr[p].mul:%lld tr[p].sum:%lld\n",l,r,p,tr[p].cs,tr[p].add,tr[p].mul, tr[p].sum);
tr[p].add++;
tr[p].sum += r - l + 1;
//printf("CHANGEQ:l:%d r:%d p:%d tr[p].cs:%d tr[p].add:%lld tr[p].mul:%lld tr[p].sum:%lld\n",l,r,p,tr[p].cs,tr[p].add,tr[p].mul, tr[p].sum);
/*if ( ! (l ^ r) )
{
for (int i = tr[p].cs + 1; i <= tr[p].cs + tr[p].add ; i ++)
{
tr[p].mul = (tr[p].mul * i) % 1000000000;
}
tr[p].add = 0;
printf("CHANGEH:l:%d r:%d p:%d tr[p].cs:%d tr[p].add:%lld tr[p].mul:%lld tr[p].sum:%lld\n",l,r,p,tr[p].cs,tr[p].add,tr[p].mul, tr[p].sum);
}*/
return;
}
//printf("PDQ:l:%d r:%d p:%d tr[p].cs:%d tr[p].add:%lld tr[p].mul:%lld tr[p].sum:%lld\n",l,r,p,tr[p].cs,tr[p].add,tr[p].mul, tr[p].sum);
pushdown(p, l, r);
//printf("PDH:l:%d r:%d p:%d tr[p].cs:%d tr[p].add:%lld tr[p].mul:%lld tr[p].sum:%lld\n",l,r,p,tr[p].cs,tr[p].add,tr[p].mul, tr[p].sum);
int mid = l + r >> 1;
change0(p << 1, l, mid);
change0(p << 1 | 1, mid + 1, r);
pushup(p);
//printf("UP:l:%d r:%d p:%d tr[p].cs:%d tr[p].add:%lld tr[p].mul:%lld tr[p].sum:%lld\n",l,r,p,tr[p].cs,tr[p].add,tr[p].mul, tr[p].sum);
}
void change1(int p, int l, int r)
{
if (l > x || r < x) return;
if ( ! (l ^ r) )
{
int now = tr[p].sum;
tr[p].sum = y;
tr[p].add += y - now;
/*int now = tr[p].sum;
if (now < y)
for (int i = now + 1 ; i < y; i++)
tr[p].mul = (tr[p].mul * i) % 1000000000;
else
if (now > y)
for (int i = y + 1; i < now ; i++)
{
if (tr[p].mul >= i)
tr[p].mul /= i;
else
tr[p].mul = (tr[p].mul * 1000000000) / i;
}*/
return;
}
pushdown(p, l, r);
int mid = l + r >> 1;
change1(p << 1, l, mid);
change1(p << 1 | 1, mid + 1, r);
pushup(p);
}
long long query(int p, int l, int r)
{
if (r < x || l > y) return 0;
if ( ! (l ^ r ) )
{
int now = tr[p].cs;
int y = tr[p].add;
if (y > 0)
for (int i = now + 1 ; i <= now + y; i++)
tr[p].mul = (tr[p].mul * i) % 1000000000;
else
if (y < 0)
for (int i = now; i > now + y ; i--)
{
if (tr[p].mul >= (long long)(i))
tr[p].mul /= (long long)(i);
else
tr[p].mul = (tr[p].mul * (long long)(1000000000) ) / ( long long )(i);
}
tr[p].cs = now + y;
tr[p].add = 0;
return tr[p].mul;
}
pushdown(p, l, r);
int mid = l + r >> 1;
int a = query(p << 1, l, mid);
int b = query(p << 1 | 1, mid +1, r);
return a + b;
}
inline void init()
{
for (int i = 1; i <= n; i++)
a[i] = read();
build(1, 1, n);
}
inline void work()
{
for (int i = 1 ; i <= q ; i++)
{
int flag = read();
x = read();
y = read();
if ( ! (flag ^ 1) )
{
change0(1, 1, n);
}
else
if ( ! (flag ^ 2) )
{
printf("%lld\n", query(1, 1, n) );
}
else
{
change1(1, 1, n);
}
}
}
int main()
{
init();
work();
return 0;
}
T6 二进制操作数组
又SB了---
写个暴力,ans统计时想到了longlong,结果觉得会出事就改成了int(突然觉得a[i]只有10^5)
【然后就真出事了】
神奇统计:
这场考试总计被SB了:21 + 86 + 40 = 147分