ssl提高组周四备考赛【2018.11.1】
生活随笔
收集整理的這篇文章主要介紹了
ssl提高组周四备考赛【2018.11.1】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言
呆學校呆4天依舊不想復習期中,期中考涼透了。
成績
| 111 | 2014lyk2014lyk2014lyk | 200200200 | 100100100 | 707070 | 303030 |
| 222 | 2017wyc2017wyc2017wyc | 180180180 | 100100100 | 808080 | 000 |
| 333 | 2017xjq2017xjq2017xjq | 170170170 | 100100100 | 707070 | 000 |
| 444 | 2014lxf2014lxf2014lxf | 160160160 | 100100100 | 606060 | 000 |
| 555 | 2017lrz2017lrz2017lrz | 130130130 | 303030 | 100100100 | 000 |
| 555 | 2013yhl2013yhl2013yhl | 130130130 | 100100100 | 303030 | 000 |
| 555 | 2015zyf2015zyf2015zyf | 130130130 | 100100100 | 303030 | 000 |
| 888 | 2014lxh2014lxh2014lxh | 120120120 | 100100100 | 202020 | 000 |
| 999 | 2017hzb2017hzb2017hzb | 110110110 | 303030 | 808080 | 000 |
| 101010 | 2014lx2014lx2014lx | 100100100 | 100100100 | 000 | 000 |
| 101010 | 2015gjh2015gjh2015gjh | 100100100 | 100100100 | 000 | 000 |
| 101010 | 2014wwt2014wwt2014wwt | 100100100 | 100100100 | 000 | 000 |
正題
T1:nssl1268?T1:nssl1268-T1:nssl1268?可見點數【數論,,,歐拉】
和儀仗隊一樣,就直接放儀仗隊了
博客鏈接:
https://blog.csdn.net/Mr_wuyongcong/article/details/81071889
T2:nssl1269?T2:nssl1269-T2:nssl1269?射擊【貪心,,,堆】
博客鏈接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83618568
T3:nssl1270?T3:nssl1270-T3:nssl1270?創(chuàng)世紀【樹形dp,dp,dp,基環(huán)樹】
博客鏈接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83618655
someofcodesome\ of\ codesome?of?code
T2 80分code
#include<cstdio> #include<queue> #include<algorithm> #define ll long long #define N 200100 using namespace std; struct node{ll t,w; }a[N]; ll n,last,ans; priority_queue<ll> q; bool cmp(node x,node y) {return x.t==y.t?x.w>y.w:x.t>y.t;} int main() {scanf("%lld",&n);for(ll i=1;i<=n;i++)scanf("%lld%lld",&a[i].t,&a[i].w);sort(a+1,a+1+n,cmp);for(ll i=1;i<=n;i++){q.push(a[i].w);for(ll j=a[i+1].t;j<a[i].t&&!q.empty();j++){ans+=q.top();q.pop();}}printf("%lld",ans); }T3 0分code
#include<cstdio> #include<algorithm> #include<cstring> #define N 1000010 using namespace std; struct node{int to,next; }a[N]; int n,x,ans,tot,cnt,cr[N],f[N][2],dp[N][2]; int ls[N]; bool v[N],c[N],ic[N]; void addl(int x,int y) {a[++tot].to=y;a[tot].next=ls[x];ls[x]=tot; } void tree_dp(int x) {f[x][1]=2147483647;bool flag=true;for(int i=ls[x];i;i=a[i].next){int y=a[i].to;if(ic[y]) continue;tree_dp(y);flag=false;f[x][0]+=max(f[y][1],f[y][0]);f[x][1]=min(f[x][1],f[y][1]-f[y][0]);}if(flag) f[x][1]=0;f[x][1]=f[x][0]-max(f[x][1],0)+1; } void check() {for(int i=1;i<=cnt;i++)tree_dp(cr[i]);dp[0][0]=dp[0][1]=0;for(int i=1;i<=cnt;i++){dp[i][0]=max(dp[i-1][1],dp[i-1][0])+f[cr[i]][0];dp[i][1]=dp[i-1][0]+f[cr[i]][1];}int maxs=dp[cnt][0];dp[1][0]=f[cr[1]][0];dp[1][1]=0;for(int i=2;i<=cnt;i++){dp[i][0]=max(dp[i-1][1],dp[i-1][0])+f[cr[i]][0];dp[i][1]=dp[i-1][0]+f[cr[i]][1];}maxs=max(maxs,max(dp[cnt][0],dp[cnt][1]));ans+=maxs; } bool check_c(int x) {v[x]=true;c[x]=true;for(int i=ls[x];i;i=a[i].next){int y=a[i].to;if(c[y]||check_c(y)) {ic[x]=true;cr[++cnt]=x;return true;}}return false; } int main() {scanf("%d",&n);for(int i=1;i<=n;i++){scanf("%d",&x);addl(x,i);}for(int i=1;i<=n;i++){if(!v[i]){cnt=0;memset(c,0,sizeof(c));memset(ic,0,sizeof(ic));if(check_c(i))check();}}printf("%d",ans); }尾聲
沒了
總結
以上是生活随笔為你收集整理的ssl提高组周四备考赛【2018.11.1】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用键盘控制鼠标的方法如何用鼠标控制电脑
- 下一篇: P2468-[SDOI2010]粟粟的书