首页 > 其他分享 >The 3rd Universal Cup. Stage 7: Warsaw 补题

The 3rd Universal Cup. Stage 7: Warsaw 补题

时间:2024-09-14 16:14:58浏览次数:11  
标签:10 ch const 3rd Cup int long 补题 define

A

太牛了。

复读 jiangly 题解。

先把代价除以二。

设 \(f_{i,j}\) 表示以 \(j\) 的代价覆盖前 \(i\) 个点最多还能覆盖多少距离。发现只有 \(f_{i,x},f_{i,x+1},f_{i,x+2}\) 的值是有意义的。其中 \(x\) 为覆盖的最小代价。因为 \(f_{i,x+3}\) 一定不优。不如你到下个点再买一张短时票。

类似于 ddp 一样的,把 \(f_{i,x},f_{i,x+1},f_{i,x+2}\) 计入 dp 状态。设 \(dp_{i,A,B,C}\) 表示当前考虑到了 \(a_i\), \(f_{i,x} = A,f_{i,x+1} = B,f_{i,x+2} = C\) 的方案数。统计答案计数考虑只在每次 \(x\) 增加的时候统计答案。

点击查看代码
#include<bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int mininf = 1e9 + 7;
#define int long long
#define pb emplace_back
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline void write(int x){if(x<0){x=~(x-1);putchar('-');}if(x>9)write(x/10);putchar(x%10+'0');}
#define put() putchar(' ')
#define endl puts("")
const int MAX = 1e3 + 10;
const int mod = 1e9 + 7;

int a[MAX];

int f[2][80][80][80];


int g[10];

int pre[MAX];

void solve(){
	int n = read();
	pre[0] = 1;
	for(int i = 1; i <= n; i++){
		a[i] = read();
		pre[i] = pre[i - 1] * 2 % mod;
	}
	
	f[0][0][0][0] = 1;
	
	int ans = 0;
	
	for(int i = 1; i <= n; i++){
		for(int A = 0; A <= 75; A++)	for(int B = 0; B <= 75; B++)	for(int C = 0; C <= 75; C++)	f[i & 1][A][B][C] = 0; 
		for(int A = 0; A <= 75; A++){
			for(int B = A; B <= 75; B++){
				for(int C = B; C <= 75; C++){
					if(!f[(i & 1) ^ 1][A][B][C])	continue;
					g[1] = max(0ll, A - (a[i] - a[i - 1])), g[2] = max(0ll, B - (a[i] - a[i - 1])), g[3] = max(0ll, C - (a[i] - a[i - 1])), g[4] = g[5] = g[6] = 0;
					for(int j = 1; j <= 6; j++){
						if(j + 1 <= 6)	g[j + 1] = max(g[j + 1], g[j] + 20);
						if(j + 3 <= 6){
							g[j + 3] = max(g[j + 3], g[j] + 75);
						}
						g[j] = max(g[j], g[j - 1]);
					}
					f[i & 1][g[1]][g[2]][g[3]] = (f[i & 1][g[1]][g[2]][g[3]] + f[(i & 1) ^ 1][A][B][C]) % mod;
					int now = 1;
					while(!g[now])	now++;
					ans = (ans + f[(i & 1) ^ 1][A][B][C] * pre[n - i] % mod * (now - 1) % mod) % mod;
					f[i & 1][g[now]][g[now + 1]][g[now + 2]] = (f[i & 1][g[now]][g[now + 1]][g[now + 2]] + f[(i & 1) ^ 1][A][B][C]) % mod;
				}
			}
		}
	}
	write(ans * 2 % mod), endl;
}

signed main(){
	int t = 1;
	while(t--)	solve();
	return 0;
}

标签:10,ch,const,3rd,Cup,int,long,补题,define
From: https://www.cnblogs.com/WRuperD/p/18414236

相关文章

  • KDD 2024 OAG-Challenge Cup赛道三项冠军技术方案解读 | 内含中秋福利
    大众点评技术部/搜索与内容智能团队组成的BlackPearl队伍,参加了2024年KDD2024OAG-ChallengeCup赛道的WhoIsWho-IND、PST、AQA三道赛题,以较大优势包揽了该赛道全部赛题的冠军。本文对这三个赛道的夺冠方案分别进行了解读,希望对大家有所帮助或启发。KDD2024OAG-ChallengeCup......
  • 补题记录
    TodoList(\(6/38\))[1]mine[2]序列[2]Legacy[2]DP搬运工2[2]DP搬运工3[3]abc猜想[3]简单的排列最优化题[3]简单的线性做法题[5]简单的序列[5]简单的博弈[5]困难的图论[6]合并r[6]回收波特[6]斗篷[8]简单的拉格朗日反演练习......
  • 九月补题计划
    暑假模拟赛(尤其是后半段题目难度上升)改题效率很低很低,隧导致咕了很多题没改,现在准备把暑假模拟赛的题只要是赛时没AC的再重新做一做写写题解,所以开启这个“九月补题计划”,简称“9B计划”。(共27场模拟赛)目前进度:1/27。CSP提高19.10A.start200行的大模拟,没什么看头,......
  • The 3rd Universal Cup. Stage 9: Xi'an
    A.AnEasyGeometryProblem差分之后条件相当于类似\(a_{i-1}+a_i=k+b\)且\(a_{i-r+1}+a_{i+r}=k\)的条件,线段树维护\(a_i\)和\(k-a_{n-i}\)的哈希值,查询直接二分即可。时间复杂度\(O(n+q\log^2n)\)。B.CountingMultisets考虑\(p(S)\)......
  • The 3rd Universal Cup. Stage 8: Cangqian
    C.ChallengeNPC考虑构造一个二分图,左边是\(1,3,5,7\)右侧是\(2,4,6,8\)。最优解肯定是一边全1,一边全2。如果\(1,2\)之间不连边,这\(2\)就会被染色为1,因此只要让\(2,3\)连边,\(3\)会被染色为\(2\),然后\(1,4\)连边,\(4\)也会被染色为\(5\),这时只要让\(2,5\)和\(4,5\)连边,\(5\)就......
  • AtCoder Beginner Contest 370 补题记录
    A-RaiseBothHands题意:给出Snuke举的左右手情况,如果只举左手,输出Yes,如果只举右手,输出No,否则输出Invalid思路:举左手:(l==1&&r==0)举右手:(l==1&&r==0)其他情况都是Invalidvoidsolve(){intl=read(),r=read();if(l==1&&r==0){......
  • The 3rd Universal Cup. Stage 8: Cangqian
    题解:https://files.cnblogs.com/files/clrs97/ZJCPC24_Tutorial.pdf Code:A.Bingo#include<bits/stdc++.h>usingnamespacestd;stringn;intm;typedeflonglongll;llsum[1000005];intpw[1000005];boolall[1000005];intsol[1000020];voidsolv()......
  • 2024ccpc网络赛补题
    L.网络预选赛题意:查询多少个2*2的子矩阵满足[c,c][p,c]输出个数Code:#include<bits/stdc++.h>usingnamespacestd;strings="ccpc";intdirs[4][2]={{0,0},{0,1},{1,0},{1,1}};chara[505][505];voidsolve(){intn,m;......
  • AtCoder Beginner Contest 370 补题记录(A~F)
    Asignedmain(){intl,r;cin>>l>>r;if(!(l==1&&r==1||l!=1&&r!=1)){if(l==1)cout<<"Yes\n";elsecout<<"No\n";}elsecout<<"Invalid\n";}Bsig......
  • The 2023 ICPC Asia Nanjing Regional Contest (The 2nd Universal Cup. Stage 11: Na
    C-PrimitiveRoot题意给定p与m(p为质数),已知(g^(P-1))%P==1且g<=m。求g的个数。思路由(g^(P-1))%P==1与异或性质a-b<=a^b<=a+b,可以推出g=((k*p+1)^(p-1))与p*(k-1)+2<=g<=p*(k+1)。又因为g<=m,则当p*(k+1)<=......