9-11NOIP模拟赛总结
来源:互联网 发布:唐山it培训 编辑:程序博客网 时间:2024/06/05 03:10
今天尽力了考了110,还算好吧,能拿的分都拿了。
T1
第一题是一道状压dp,可能是我状态没定好, 我的转移的复杂度有
T2
第二题没什么思路,打了个暴力。第二题就是个分治,问题是求
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<algorithm>using namespace std;typedef long long LL;#define REP(i, a, b) for(register LL i = (a), i##_end_ = (b); i <= i##_end_; ++ i)#define DREP(i, a, b) for(register LL i = (a), i##_end_ = (b); i >= i##_end_; -- i)#define mem(a, b) memset((a), b, sizeof(a))LL read(){ register LL fg = 1,sum = 0;char c = getchar(); while(!isdigit(c)) { if(c == '-')fg = -1; c = getchar(); } while(isdigit(c)) { sum = sum * 10 + c - '0'; c = getchar(); } return fg * sum;}template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }const int maxn = 500000+10;const LL mod = 1e9 + 7;const LL INF = 1e14;LL n;LL a[maxn];LL smx[maxn],smn[maxn],sm[maxn];LL ans;#define fl(a,n) fill(a+1,a+1+n,0);void work(LL l,LL r){ if(l == r) { (ans += (a[l] * a[l]) % mod) %= mod; return; } LL mid = (l + r) >> 1; work(l,mid); work(mid+1,r); LL x = -1e14,y = 1e14; REP(i,mid+1,r) { x = max(x,a[i]);y = min(y,a[i]); smx[i] = (smx[i-1] + x)%mod; smn[i] = (smn[i-1] + y)%mod; sm[i] = (sm[i-1] + (x * y)%mod)%mod; } LL j = mid + 1,k = mid+1; x = -1e14, y = 1e14; DREP(i,mid,l) { x = max(x, a[i]); y = min(y, a[i]); for(; j <= r && a[j] <= x; ++j); for(; k <= r && a[k] >= y; ++k); LL L = min(j, k), R = max(j, k); (ans += ((x * y) % mod * (L - mid - 1)) % mod) %= mod; (ans += (sm[r] - sm[R - 1] + mod) % mod) %= mod; if(j <= k) (ans += (y * (smx[R - 1] - smx[L - 1])) % mod) %= mod; else (ans += (x * (smn[R - 1] - smn[L - 1])) % mod) %= mod; }}int main(){#ifndef ONLINE_JUDGE freopen("seq.in","r",stdin); freopen("seq.out","w",stdout);#endif n = read(); REP(i,1,n) a[i] = read(); work(1, n); printf("%lld\n", (ans + mod) % mod); return 0;}
T3
同样暴力.60pt其实不难想,根据期望的一些线性,我们可以把期望分开来算,算这个位置的期望的位置,然后暴力统计就好了.
经验与不足
该拿的分都拿到,不能拿的尽量骗,先看题,打暴力,节奏要稳,不能因为题目难度乱了节奏,跟着今天这种节奏就很好的。
阅读全文
0 0
- 9-11NOIP模拟赛总结
- 9-9NOIP模拟赛总结
- 9-1NOIP模拟赛总结
- 9-2NOIP模拟赛总结
- 9-3NOIP模拟赛总结
- 9-4NOIP模拟赛总结
- 9-7NOIP模拟赛总结
- 9-10NOIP模拟赛总结
- 9-14NOIP模拟赛总结
- 9-14NOIP模拟赛总结
- 9-16NOIP模拟赛总结
- 9-17NOIP模拟赛总结
- 9-18NOIp模拟赛总结
- 9-21NOIp模拟赛总结
- 9-23NOIP模拟赛总结
- 9-24NOIP模拟赛总结
- 9-25NOIP模拟赛总结
- 9-26NOIP模拟赛总结
- 设计模式之享元模式
- 面试题02:Delete occurrences of an element if it occurs more than n times
- NoSQL基础理论
- OpenSSL及CA加密
- Java SE 、Java EE和 Java ME的区别
- 9-11NOIP模拟赛总结
- 缓存系统之 Memcache
- FFmpeg源码剖析-通用:avcodec_register_all()
- HDU 6203 ping ping ping (LCA+DFS序)
- 关于axis2使用wsdl2java.bat注意点
- 两种升序排序的方法
- CSS3实现文字3D效果
- Unity中Input 方法总结
- Python3 [爬虫实战] Redis+Flask 动态维护cookies池(上)