1653: [Usaco2006 Feb]Backward Digit Sums Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 285 Solved: 215[Submit][Status] Description FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain orde…
1653: [Usaco2006 Feb]Backward Digit Sums Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 207 Solved: 161[Submit][Status][Discuss] Description FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a cer…
Backward Digit Sums Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4487 Accepted: 2575 Description FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum ad…
严格次短路模板,用两个数组分别维护最短路和次短路,用dijskstra,每次更新的时候先更新最短路再更新次短路 写了spfa版的不知道为啥不对-- #include<iostream> #include<cstdio> #include<queue> using namespace std; const int N=5005,inf=1e9; int n,m,h[N],cnt,d1[N],d2[N]; struct qwe { int ne,to,va; }e[2000…
t记录每个格子最早被砸的时间,bfs(x,y,t)表示当前状态为(x,y)格子,时间为t.因为bfs,所以先搜到的t一定小于后搜到的,所以一个格子搜一次就行 #include<iostream> #include<cstdio> #include<queue> using namespace std; const int N=505,inf=1e9,dx[]={-1,1,0,0,0},dy[]={0,0,-1,1,0}; int n,m,t[N][N]; bool v[…
DAG上的dp 因为本身升序就是拓扑序,所以建出图来直接从1到ndp即可,设f[i][j]为到i花费了j #include<iostream> #include<cstdio> using namespace std; const int N=1005,inf=1e9+7; int n,m,b,h[N],cnt,f[N][N],ans=-inf; struct qwe { int ne,to,va,c; }e[N*10]; int read() { int r=0,f=1; cha…