大一選拔賽 Day1

2021-09-27 11:59:25 字數 2773 閱讀 1382

傳送門 hyflshhl

a、b、e、f比較簡單

c、d難一些

a題:注意排序,如果l和r相等,優先刪除長度小的;比較簡單;

b題:是個很簡單的概率dp,注意狀態轉移;

c題:詳解在下面;

d題:詳解在下面;

e題:倒序處理一下就好了,有個思路很有趣,就是將字母序看作k進製數,然後從個位加1,進製……實現起來麻煩一些;

f題:可以把序列處理成乙個環,切割就是將環切斷,把序列處理為兩倍的長度等同於環;

a的**:

#include#include#include#includeusing namespace std;

struct hh a[600001];

int n,ans,inf=2147483647;

int calc_r()

bool cmp2(hh x,hh y)

void solve()

int main()

c的**:

維護乙個堆,記錄每個狀態(選n個數字)的概率;

每次取最大概率加到答案中,更新下乙個狀態,即把每行數字的頭移向前乙個;

cnt.head[i]:在cnt這個狀態下,第i行數字頭的位置;

#include#include#include#include#includeusing namespace std;

const int maxn=105;

double ma[maxn][maxn];

int n,m,k;

double ans;

struct hh cnt;

bool operator < (hh x,hh y)

priority_queueq;

void solve()

q.push(cnt);

while(!q.empty() && k) }

printf("%.8lf ",ans);

return;

}int main()

d的**:

參考:兩遍dijkstra處理最短路,記錄每個點被最短路經過的次數;

在陣列第二維中,0表示以1為起點,1表示以n為起點

dis[i][0/1]:起點到i點的最短路長度;

num[i][0/1]:起點到終點的最短路,以1/n為起點經過i點的次數;

則i點經過的概率為(num[i][1]*num[i][0])/最短路總條數;

注意對於麻花圖,可能存在2^100000條最短路;

因此取ln為底,e^a+e^b=e^( a+ln (1+e^(b-a)) ) 

wa了16次,剛開始是因為沒有注意到特殊圖的存在;

後來是因為沒有開long long?第二次了……

#include#include#include#include#include#include#includeusing namespace std;

typedef long long ll;

const ll maxn=300001;

const ll inf=2e18;

ll fst[maxn<<1],nxt[maxn<<1];

ll dis[maxn][2];

ll n,m,tot;

bool vis[maxn];

double cnt[maxn][2];

struct hh ma[maxn<<1];

struct sh ;

bool operator < (sh x,sh y)

priority_queueq;

void build(ll f,ll t,ll c)

; nxt[tot]=fst[f];

fst[f]=tot;

return;

}double calc(double x,double y)

); }

else if(dis[v][st]==dis[x][st]+ma[i].c)

cnt[v][st]=calc(cnt[v][st],cnt[x][st]);

} }return;

}void solve()

dijkstra(1,0),dijkstra(n,1);

for(ll i=1;i<=n;i++)

return;

}int main()

e的**:

#include#include#include#include#includeusing namespace std;

const int maxn=200001;

char a[maxn];

int vis[maxn];

int n,m;

string s;

int maxx=-1,minn=214748444,cnt;

int f(int x)

void solve()

if(n=1;i--)

n=s.size();

for(int i=1;i<=n;i++)

a[i+n]=a[i];

int i=2;

while(i<=n*2)

i++,cnt++;

}i--;

} ans=max(ans,cnt);

i++;

} cout<}int main()

大一東北賽選拔賽(2019 4 30)(未完待續)

include using namespace std typedef long long ll struct node a 1010 b 1010 ll n,ansx,ansy intmain ansx ansx n ansy ansy n printf lld lld n ansx,ansy r...

個人選拔賽1總結

比賽鏈結 今天又全跪了,0題,我想哭,不過比賽就是這樣,生活還得繼續,不能放棄,真的,沒關係,好好總結,以後多做總結,多看看以前做的題,溫故而知新,手腦要配合一起思考,每天總結當天的收穫,不足要加以改進,嚴格對待自己的缺點,每天與自己比,不要和別人比,每個人的情況都不相同,每天要贏自己一把,注意休息...

SDUT 2012省賽選拔賽1

a bfs 優先佇列。第一天只能感染defence小於等於1的並且與之連線的機器,第二天只能感染defence小於等於2的並且與之連線的機器.依次往後推。include include include include define maxn 505 using namespace std int g...