校内模拟赛 ——— 2019.10.31 7:40至11.10
作者:互联网
期望得分:100+40+0
实际得分:0+40+0
awa(我讨厌大模拟!!!
T1:沙雕大模拟!!!ccc
题面如下:
思路:直接模拟着做呗,注意一定要细心!耐心!认真!!!!!
我的零蛋代码:(零蛋还好意思贴出来?!)
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int inf=100001; int N,M,T,P,Q; struct node { int id,val,weizhi; char name[16],x[5]; } A[100005],B[100005]; int tota[6],totb[6]; int topa[6],topb[6]; int sa[6],sb[6]; int ca[100005],cb[100006]; inline int read() { int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')w=-1; ch=getchar(); } while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar(); return s*w; } bool cmp(node a,node b) { if(a.weizhi!=b.weizhi)return a.weizhi<b.weizhi; return a.val>b.val; } void finda() { int k,z=-inf,l=0; for(int i=1; i<=5; i++) { if(tota[i]==1)continue; if(topa[i]==topa[i+1]-1)continue; // if(ca[i]==inf)continue; if(topa[i]+1>N)continue; if(ca[topa[i]+1]>z) z=ca[topa[i]+1],k=topa[i]+1,l=i; if(ca[topa[i]+1]==z&&A[topa[i]+1].id<A[k].id)z=ca[topa[i]+1],k=topa[i]+1,l=i; } topa[l]++; cout<<"Substitution by A,No."<<A[k].id<<" "<<A[k].name<<" is coming up to change No."; cout<<A[k-1].id<<" "<<A[k-1].name<<".\n"; } void findb() { int k,z=-inf,l=0; for(int i=1; i<=5; i++) { if(totb[i]==1)continue; if(topb[i]+1==topb[i+1])continue; // if(cb[topb[i]]==inf)continue; if(topb[i]+1>M)continue; if(cb[topb[i]+1]>z)z=cb[topb[i]+1],k=topb[i]+1,l=i; if(cb[topb[i]+1]==z&&B[topb[i]+1].id<B[k].id)z=cb[topb[i]+1],k=topb[i]+1,l=i; } topb[l]++; cout<<"Substitution by B,No."<<B[k].id<<" "<<B[k].name<<" is coming up to change No."<<B[k-1].id<<" "<<B[k-1].name<<".\n"; } void awa(); void init(); int main() { // freopen("match.in","r",stdin); // freopen("match.out","w",stdout); init(); sort(A+1,A+1+N,cmp); sort(B+1,B+1+M,cmp); awa(); for(int i=1; i<T; i++) { if(i%P&&i%Q)continue; if(i%P==0) finda(); if(i%Q==0) findb(); } // fclose stdin; // fclose stdout; return 0; } void init() { N=read(),M=read(),T=read(),P=read(),Q=read(); for(int i=1; i<=N; i++) { cin>>A[i].name; A[i].id=read(); cin>>A[i].x+1; if(A[i].x[1]=='p'&&A[i].x[2]=='g')A[i].weizhi=1; if(A[i].x[1]=='s'&&A[i].x[2]=='g')A[i].weizhi=2; if(A[i].x[1]=='s'&&A[i].x[2]=='f')A[i].weizhi=3; if(A[i].x[1]=='p'&&A[i].x[2]=='f')A[i].weizhi=4; if(A[i].x[1]=='c')A[i].weizhi=5; A[i].val=read(); } for(int i=1; i<=M; i++) { cin>>B[i].name; B[i].id=read(); cin>>B[i].x+1; if(B[i].x[1]=='p'&&B[i].x[2]=='g')B[i].weizhi=1; if(B[i].x[1]=='s'&&B[i].x[2]=='g')B[i].weizhi=2; if(B[i].x[1]=='s'&&B[i].x[2]=='f')B[i].weizhi=3; if(B[i].x[1]=='p'&&B[i].x[2]=='f')B[i].weizhi=4; if(B[i].x[1]=='c')B[i].weizhi=5; B[i].val=read(); } } void awa() { for(int i=1; i<=N; i++) { tota[A[i].weizhi]++; if(A[i].weizhi!=A[i-1].weizhi)topa[A[i].weizhi]=i; } for(int i=1; i<=M; i++) { totb[B[i].weizhi]++; if(B[i].weizhi!=B[i-1].weizhi)topb[B[i].weizhi]=i; } for(int i=1; i<=N; i++) ca[i]=A[i].val-A[i-1].val; for(int i=1; i<=M; i++) cb[i]=B[i].val-B[i-1].val; return ; }View Code
zzh大佬的四十分代码
//T1 by zzh 40 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std ; const int MAXN = 1e5 + 7 ; int n , m , t , p , q , num , sor ; int ta , tb , ka , kb ; int numa[ 6 ] , numb[ 6 ] ; bool visa[ MAXN ] , visb[ MAXN ] ; char nam[ 20 ] , pos[ 10 ] ; char s[ 10 ][ 3 ] = { " " , "pg" , "sg" , "sf" , "pf" , "c" } ; struct opp { int sorce , number ; string name ; } a[ MAXN ][ 6 ] , b[ MAXN ][ 6 ] ; opp nowa[ 6 ] , nowb[ 6 ] ; int main() { // freopen( "match.in" , "r" , stdin ) ; // freopen( "match.out" , "w" , stdout ) ; scanf( "%d%d%d%d%d" , &n , &m , &t , &p , &q ) ; for ( int i = 1 ; i <= n ; i++ ) { scanf( "%s%d%s%d" , nam , &num , pos , &sor ) ; for ( int j = 1 ; j <= 5 ; j++ ) { if ( strcmp( s[ j ] , pos ) == 0 ) { a[ ++numa[ j ] ][ j ].name = nam ; a[ numa[ j ] ][ j ].number = num ; a[ numa[ j ] ][ j ].sorce = sor ; if ( a[ numa[ j ] ][ j ].sorce > nowa[ j ].sorce ) { visa[ nowa[ j ].number ] = false ; nowa[ j ].name = a[ numa[ j ] ][ j ].name ; nowa[ j ].sorce = a[ numa[ j ] ][ j ].sorce ; nowa[ j ].number = a[ numa[ j ] ][ j ].number ; // nowa[ j ] = a[ numa[ j ] ][ j ] ; visa[ nowa[ j ].number ] = true ; } else if ( a[ numa[ j ] ][ j ].sorce == nowa[ j ].sorce && a[ numa[ j ] ][ j ].number < nowa[ j ].number ) { visa[ nowa[ j ].number ] = false ; nowa[ j ].name = a[ numa[ j ] ][ j ].name ; nowa[ j ].number = a[ numa[ j ] ][ j ].number ; // nowa[ j ] = a[ numa[ j ] ][ j ] ; visa[ nowa[ j ].number ] = true ; } break ; } // cout << nowa[ j ].name << " " << nowa[ j ].number << " " << nowa[ j ].sorce << '\n' ; } } for ( int i = 1 ; i <= m ; i++ ) { scanf( "%s%d%s%d" , nam , &num , pos , &sor ) ; for ( int j = 1 ; j <= 5 ; j++ ) { if ( strcmp( s[ j ] , pos ) == 0 ) { b[ ++numb[ j ] ][ j ].name = nam ; b[ numb[ j ] ][ j ].number = num ; b[ numb[ j ] ][ j ].sorce = sor ; if ( b[ numb[ j ] ][ j ].sorce > nowb[ j ].sorce ) { visb[ nowb[ j ].number ] = false ; nowb[ j ].name = b[ numb[ j ] ][ j ].name ; nowb[ j ].sorce = b[ numb[ j ] ][ j ].sorce ; nowb[ j ].number = b[ numb[ j ] ][ j ].number ; // nowb[ j ] = b[ numb[ j ] ][ j ] ; visb[ nowb[ j ].number ] = true ; } else if ( b[ numb[ j ] ][ j ].sorce == nowb[ j ].sorce && b[ numb[ j ] ][ j ].number < nowb[ j ].number ) { visb[ nowb[ j ].number ] = false ; nowb[ j ].name = b[ numb[ j ] ][ j ].name ; nowb[ j ].number = b[ numb[ j ] ][ j ].number ; // nowb[ j ] = b[ numb[ j ] ][ j ] ; visb[ nowb[ j ].number ] = true ; } break ; } } } for ( int i = 1 ; i < t ; i++ ) { ta++ ; tb++ ; if ( ta == p ) { int r = 0 ; opp h = opp { -10000 , 0 , " " } ; for ( int k = 1 ; k <= 5 ; k++ ) { opp maxx = opp { 0 , 0 , " " }; for ( int j = 1 ; j <= numa[ k ] ; j++ ) { if ( !visa[ a[ j ][ k ].number ] && a[ j ][ k ].sorce > maxx.sorce ) { maxx.name = a[ j ][ k ].name ; maxx.sorce = a[ j ][ k ].sorce ; maxx.number = a[ j ][ k ].number ; } else if ( !visa[ a[ j ][ k ].number ] && a[ j ][ k ].sorce == maxx.sorce && a[ j ][ k ].number < maxx.number ) { maxx.name = a[ j ][ k ].name ; maxx.number = a[ j ][ k ].number ; } } if ( maxx.sorce == 0 ) continue ; if ( nowa[ k ].sorce - maxx.sorce < nowa[ r ].sorce - h.sorce ) { visa[ h.number ] = false ; h.name = maxx.name ; h.sorce = maxx.sorce ; h.number = maxx.number ; r = k ; visa[ h.number ] = true ; } else if ( nowa[ k ].sorce - maxx.sorce == nowa[ r ].sorce - h.sorce && maxx.number < h.number ) { visa[ h.number ] = false ; h.name = maxx.name ; h.sorce = maxx.sorce ; h.number = maxx.number ; r = k ; visa[ h.number ] = true ; } } cout << "Substitution by A,No." << h.number << " " << h.name << " is coming up to change No." ; cout << nowa[ r ].number << " " << nowa[ r ].name << "." << '\n' ; nowa[ r ].name = h.name ; nowa[ r ].sorce = h.sorce ; nowa[ r ].number = h.number ; ta = 0 ; // Substitution by A,No.8 LiChun is coming up to change No.3 LiQiang. // Substitution by A,No.0 is coming up to change No.0 . } if ( tb == q ) { int r = 0 ; opp h = opp { -10000 , 0 , " " } ; for ( int k = 1 ; k <= 5 ; k++ ) { opp maxx = opp { 0 , 0 , " " }; for ( int j = 1 ; j <= numb[ k ] ; j++ ) { if ( !visb[ b[ j ][ k ].number ] && b[ j ][ k ].sorce > maxx.sorce ) { maxx.name = b[ j ][ k ].name ; maxx.sorce = b[ j ][ k ].sorce ; maxx.number = b[ j ][ k ].number ; } else if ( !visb[ b[ j ][ k ].number ] && b[ j ][ k ].sorce == maxx.sorce && b[ j ][ k ].number < maxx.number ) { maxx.name = b[ j ][ k ].name ; maxx.number = b[ j ][ k ].number ; } } if ( maxx.sorce == 0 ) continue ; if ( nowb[ k ].sorce - maxx.sorce < nowb[ r ].sorce - h.sorce ) { visb[ h.number ] = false ; h.name = maxx.name ; h.sorce = maxx.sorce ; h.number = maxx.number ; r = k ; visb[ h.number ] = true ; } else if ( nowb[ k ].sorce - maxx.sorce == nowb[ r ].sorce - h.sorce && maxx.number < h.number ) { visb[ h.number ] = false ; h.name = maxx.name ; h.sorce = maxx.sorce ; h.number = maxx.number ; r = k ; visb[ h.number ] = true ; } } cout << "Substitution by B,No." << h.number << " " << h.name << " is coming up to change No." ; cout << nowb[ r ].number << " " << nowb[ r ].name << "." << '\n' ; nowb[ r ].name = h.name ; nowb[ r ].sorce = h.sorce ; nowb[ r ].number = h.number ; tb = 0 ; } } return 0 ; }View Code
孙土蛋tql
#include<bits/stdc++.h> using namespace std; struct player { char name[16]; int num,ttt; } a[2][5][500100]; int n, m, t, p, q, turn[2][5], sum[2][5], psum, qsum, num, ttt, team, pos; char sname[16], spos[16]; bool cmp(player a, player b) { return (a.ttt==b.ttt?a.num<b.num:a.ttt>b.ttt); } int main() { scanf("%d%d%d%d%d",&n,&m,&t,&p,&q); for (int i=1; i<=n+m; i++) { team=(i<=n?0:1); scanf("%s%d%s%d",sname,&num,spos,&ttt); if(spos[0]=='p'&&spos[1]=='g') pos=0; if(spos[0]=='s'&&spos[1]=='g') pos=1; if(spos[0]=='s'&&spos[1]=='f') pos=2; if(spos[0]=='p'&&spos[1]=='f') pos=3; if(spos[0]=='c') pos=4; a[team][pos][++sum[team][pos]]=(player) { "",num,ttt }; strcpy(a[team][pos][sum[team][pos]].name,sname); } for(int i=0; i<=4; i++) { sort(a[0][i]+1,a[0][i]+sum[0][i]+1,cmp); sort(a[1][i]+1,a[1][i]+sum[1][i]+1,cmp); } for(int i=0; i<=4; i++) turn[0][i]=turn[1][i]=1; psum=1,qsum=1; while(p*psum<t||q*qsum<t) { if(p*psum<=q*qsum) team=0,psum++; else team=1,qsum++; int mn=999,pm; player up,down; for(int i=0; i<=4; i++) { int k=turn[team][i],c=a[team][i][k].ttt-a[team][i][k+1].ttt; if(k==sum[team][i]) continue; if(c<mn||(c==mn&&a[team][i][k+1].num<up.num)) mn=c,pm=i,up=a[team][i][k+1],down=a[team][i][k]; } turn[team][pm]++; char ct=(team==0?'A':'B'); printf("Substitution by %c,No.%d %s is coming up to change No.%d %s.\n",ct,up.num,up.name,down.num,down.name); } return 0; }View Code
T2:题面如下
思路:暴力枚举选每一个点作为开始的积木点会有40分
注意处理旁边积木点被搬空的情况
还有第一个点和最后一个点只能向一个方向的积木点走,去搬积木
蒟蒻的暴力代码:
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std; int n,T; struct node { int x,a; int maxx; } f[500005]; bool vis[500005]; int ans=0; void qiu(int k) { memset(vis,true,sizeof vis); int t,sum; int i=k+1,j=k-1,z; int zzz=T; while(zzz) { while(!vis[i])i++; while(!vis[j])j--; if(f[k].x-f[j].x>f[i].x-f[k].x&&j) { z=i,t=f[i].x-f[k].x; } else z=j,t=f[k].x-f[j].x; if(j==0)z=i,t=f[i].x-f[k].x; else if(i==n+1)z=j,t=f[k].x-f[j].x; if(j==0&&i==n+1)break; vis[z]=false; int l=zzz/(t*2); if(l>f[z].a)l=f[z].a; zzz-=t*2*l; f[k].maxx+=l; } ans=max(ans,f[k].maxx); } inline int read() { int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')w=-1; ch=getchar(); } while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar(); return s*w; } int main() { freopen("block.in","r",stdin); freopen("block.out","w",stdout); n=read(),T=read(); for(int i=1; i<=n; i++) f[i].x=read(); for(int i=1; i<=n; i++) f[i].a=read(),f[i].maxx=f[i].a; for(int i=1; i<=n; i++) qiu(i); printf("%d",ans); fclose stdin; fclose stdout; return 0; }View Code
日模孙土蛋:
#include<bits/stdc++.h> #define N 500010 using namespace std; typedef long long ll; ll s[N], T; int x[N], a[N], n; bool check(ll H) { ll nowh = 0, tim = 0; int lc = 0, rc = 0, l = 1, r = n + 1; for (int i = 1; i <= n; i++) if (nowh + a[i] <= H) nowh += a[i], tim += (ll)(x[i] - x[1]) * a[i]; else { r = i, rc = H - nowh, tim += (ll)(x[i] - x[1]) * rc; break; } if (tim <= T) return 1; for (int i = 2; i <= n; i++) { ll suml = s[i - 1] - s[l - 1] - lc; ll sumr = s[r - 1] - s[i - 1] + rc; tim += (x[i] - x[i - 1]) * (suml - sumr); while (r <= n && x[i] - x[l] > x[r] - x[i]) { int can = min(a[l] - lc, a[r] - rc); tim += (x[r] - x[i] - x[i] + x[l]) * can; lc += can, rc += can; if (lc >= a[l]) ++l, lc = 0; if (rc >= a[r]) ++r, rc = 0; } if (tim <= T) return 1; } return 0; } int main() { freopen("block.in", "r", stdin); freopen("block.out", "w", stdout); scanf("%d%I64d", &n, &T); T /= 2; for (int i = 1; i <= n; i++) scanf("%d", &x[i]); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i]; ll l = 0, r = s[n], ans; while (l <= r) { ll mid = (l + r) >> 1; if (check(mid)) l = mid + 1, ans = mid; else r = mid - 1; } printf("%I64d\n", ans); return 0; }View Code
T3:鬼畜题,蒟蒻看不懂
std::
#include<bits/stdc++.h> #define N 500010 #define ls (x << 1) #define rs (x << 1 | 1) using namespace std; typedef long long ll; struct intv{ int s, i; } a[N], b[N]; int p[N], rc[N << 2], f[N], n, m, type, anss, sum[N << 2]; ll ansf; char s[N]; bool cmp(intv a, intv b) { return a.s < b.s; } inline void updata(int x, int l, int r, int p) { if (l == r) { rc[x] = r, sum[x] = 1; return; } int mid = (l + r) >> 1; if (p <= mid) updata(ls, l, mid, p); else updata(rs, mid + 1, r, p); sum[x] = sum[ls] + sum[rs]; rc[x] = (rc[rs] == -1 ? rc[ls] : rc[rs]); } inline intv query(int x, int l, int r, int xl, int xr) { if (l == xl && r == xr) return (intv) {sum[x], rc[x]}; int mid = (l + r) >> 1; if (xr <= mid) return query(ls, l, mid, xl, xr); else if (xl > mid) return query(rs, mid + 1, r, xl, xr); else { intv ql = query(ls, l, mid, xl, mid), qr = query(rs, mid + 1, r, mid + 1, xr); return (intv) {ql.s + qr.s, qr.i == -1 ? ql.i : qr.i}; } } int main() { freopen("htstr.in", "r", stdin); freopen("htstr.out", "w", stdout); scanf("%s%d", s + 1, &type); n = strlen(s + 1); s[0] = '#'; int mx = 0, id, now = 1; for (int i = 1; i <= n; i++) { if (mx >= i) p[i] = min(mx - i, p[2 * id - i]); for (; s[i + p[i] + 1] == s[i - p[i]]; p[i]++); if (p[i] + i < mx) id = i, mx = p[i] + i; } for (int i = 1; i <= n; i++) a[i] = (intv) {i - p[i], i}; sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n << 2; i++) rc[i] = -1; for (int i = 1; i <= n; i++) { while (now <= n && a[now].s <= i) updata(1, 1, n, a[now].i), now++; if (p[i] <= 1) continue; intv qs = query(1, 1, n, i + 1, i + p[i] / 2); ansf += (ll)qs.s; if (qs.i != -1) b[++m] = (intv) {3 * i - 2 * qs.i + 1, 2 * qs.i - i}; } if (type == 1) {printf("%I64d\n", ansf + n); return 0;} sort(b + 1, b + m + 1, cmp); id = 1, mx = 0; for (int r = 1; r <= n; r++) { while (b[id].s <= r && id <= m) mx = max(mx, b[id].i), id++; if (mx < r) ++anss, mx = r; else r = mx, ++anss; } if (type == 2) printf("%d\n", anss); else printf("%I64d %d\n", ansf + n, anss); return 0; }View Code
标签:maxx,name,int,31,number,40,11.10,&&,sorce 来源: https://www.cnblogs.com/ydclyq/p/11771135.html