标签:2-2 open 今天 str cst closed vector stdin oid
#include<iostream> #include<cstdio> using namespace std; int n,m; int main(){ freopen("star.in","r",stdin);freopen("star.out","w",stdout); while(1){ scanf("%d%d",&n,&m); if(n==0&&m==0)return 0; if((n*m)%2==0)puts("Yuri"); else puts("Chito"); } }
#include<iostream> #include<cstdio> #include<vector> #include<algorithm> #define maxn 50010 #define mod 1000000007 using namespace std; int n,k,a[maxn],mx; vector<int>b; long long ans; bool cmp(int x,int y){return x>y;} int main(){ freopen("war.in","r",stdin);freopen("war.out","w",stdout); // freopen("Cola.txt","r",stdin); scanf("%d%d",&n,&k); for(int i=1;i<=n;i++)scanf("%d",&a[i]); for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++){ int w=a[i]^a[j]; b.push_back(w); } sort(b.begin(),b.end(),cmp); for(int i=0;i<k;i++){ ans+=b[i]; while(ans>=mod)ans-=mod; } cout<<ans; }
#include<iostream> #include<cstdio> #include<algorithm> #define maxn 100010 using namespace std; int n,m,a[maxn],b[maxn]; struct node{ int l,r,v,lazy; }tr[100010*2]; struct Nde{ int opt,x,y,z; }qu[maxn]; bool flag=1; int opl,opr,opv; bool cmp(int x,int y){return x>y;} void build(int l,int r,int k){ tr[k].l=l;tr[k].r=r; if(l==r){tr[k].v=a[l];return;} int mid=(l+r)>>1; build(l,mid,k<<1); build(mid+1,r,k<<1|1); tr[k].v=max(tr[k<<1].v,tr[k<<1|1].v); } void update(int k){ tr[k<<1].lazy+=tr[k].lazy; tr[k<<1].v+=tr[k].lazy; tr[k<<1|1].lazy+=tr[k].lazy; tr[k<<1|1].v+=tr[k].lazy; tr[k].lazy=0; } int query(int l,int r,int k){ if(tr[k].l>=opl&&tr[k].r<=opr)return tr[k].v; if(tr[k].lazy)update(k); int mid=(l+r)>>1; int res=0; if(opl<=mid)res=max(res,query(l,mid,k<<1)); if(opr>mid)res=max(res,query(mid+1,r,k<<1|1)); tr[k].v=max(tr[k<<1].v,tr[k<<1|1].v); return res; } void change(int l,int r,int k){ if(tr[k].l>=opl&&tr[k].r<=opr){ tr[k].v+=opv; tr[k].lazy+=opv; return; } if(tr[k].lazy)update(k); int mid=(l+r)>>1; if(opl<=mid)change(l,mid,k<<1); if(opr>mid)change(mid+1,r,k<<1|1); tr[k].v=max(tr[k<<1].v,tr[k<<1|1].v); } int main(){ freopen("noname.in","r",stdin);freopen("noname.out","w",stdout); // freopen("Cola.txt","r",stdin); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)scanf("%d",&a[i]); for(int i=1;i<=m;i++){ scanf("%d%d%d%d",&qu[i].opt,&qu[i].x,&qu[i].y,&qu[i].z); if(qu[i].opt==0&&qu[i].z!=1)flag=0; } if(flag){ build(1,n,1); for(int i=1;i<=m;i++){ opl=qu[i].x;opr=qu[i].y; if(qu[i].opt==0){ printf("%d\n",query(1,n,1)); } else { opv=qu[i].z; change(1,n,1); } } } else{ for(int i=1;i<=m;i++){ if(qu[i].opt==1) for(int j=qu[i].x;j<=qu[i].y;j++)a[j]+=qu[i].z; if(qu[i].opt==0){ int cnt=0; for(int j=qu[i].x;j<=qu[i].y;j++)b[++cnt]=a[j]; sort(b+1,b+cnt+1,cmp); if(cnt<k)printf("-1"); else printf("%d\n",b[qu[i].z]); } } } }
预计得分0+40+50 实际得分100+0+20 T1看起来应该是个结论题,我博弈论很弱所以就找了半个小时规律,就写出来了,但是不会证明。T2不会正解,就直接枚举了,但是非常不小心的是在排序之前取了模,所以排序有误,报零了。T3没看到输出-1的情况,少了30分,很可惜 今天上午精神状态不好,发挥不佳,有很多细节出了错误,导致成绩与预计得分差距较大,以后要认真审题,谨慎写代码,考场上调整好状态
标签:2-2 open 今天 str cst closed vector stdin oid
原文地址:http://www.cnblogs.com/thmyl/p/7753316.html