20190926CF训练
Posted oneman233
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了20190926CF训练相关的知识,希望对你有一定的参考价值。
大翻车局,被憨憨二维前缀和卡死
A、Radio Station
大模拟,没什么好说的,输出对应ip地址的名字即可
代码:
#include <bits/stdc++.h> #define int long long #define sc(a) scanf("%lld",&a) #define scc(a,b) scanf("%lld %lld",&a,&b) #define sccc(a,b,c) scanf("%lld %lld %lld",&a,&b,&c) #define scs(a) scanf("%s",a) #define schar(a) scanf("%c",&a) #define pr(a) printf("%lld",a) #define fo(i,a,b) for(int i=a;i<b;++i) #define re(i,a,b) for(int i=a;i<=b;++i) #define rfo(i,a,b) for(int i=a;i>b;--i) #define rre(i,a,b) for(int i=a;i>=b;--i) #define prn() printf("\\n") #define prs() printf(" ") #define mkp make_pair #define pii pair<int,int> #define pub(a) push_back(a) #define pob() pop_back() #define puf(a) push_front(a) #define pof() pop_front() #define fst first #define snd second #define frt front() #define bak back() #define mem0(a) memset(a,0,sizeof(a)) #define memmx(a) memset(a,0x3f3f,sizeof(a)) #define memmn(a) memset(a,-0x3f3f,sizeof(a)) #define debug #define db double #define yyes cout<<"YES"<<endl; #define nno cout<<"NO"<<endl; #define all(i,a) for(auto i=a.begin();i!=a.end();++i) using namespace std; typedef vector<int> vei; typedef vector<pii> vep; typedef map<int,int> mpii; typedef map<char,int> mpci; typedef map<string,int> mpsi; typedef deque<int> deqi; typedef deque<char> deqc; typedef priority_queue<int> mxpq; typedef priority_queue<int,vector<int>,greater<int> > mnpq; typedef priority_queue<pii> mxpqii; typedef priority_queue<pii,vector<pii>,greater<pii> > mnpqii; const int maxn=500005; const int inf=0x3f3f3f3f3f3f3f3f; const int MOD=100000007; const db eps=1e-10; const db pi=3.1415926535; int qpow(int a,int b)int tmp=a%MOD,ans=1;while(b)if(b&1)ans*=tmp,ans%=MOD;tmp*=tmp,tmp%=MOD,b>>=1;return ans; int lowbit(int x)return x&-x; int max(int a,int b)return a>b?a:b; int min(int a,int b)return a<b?a:b; int mmax(int a,int b,int c)return max(a,max(b,c)); int mmin(int a,int b,int c)return min(a,min(b,c)); void mod(int &a)a+=MOD;a%=MOD; bool chk(int now) int half(int l,int r)while(l<=r)int m=(l+r)/2;if(chk(m))r=m-1;else l=m+1;return l; int ll(int p)return p<<1; int rr(int p)return p<<1|1; int mm(int l,int r)return (l+r)/2; int lg(int x)if(x==0) return 1;return (int)log2(x)+1; bool smleql(db a,db b)if(a<b||fabs(a-b)<=eps)return true;return false; bool bigeql(db a,db b)if(a>b||fabs(a-b)<=eps)return true;return false; bool eql(db a,db b)if(fabs(a-b)<eps) return 1;return 0; db len(db a,db b,db c,db d)return sqrt((a-c)*(a-c)+(b-d)*(b-d)); bool isp(int x)if(x==1)return false;if(x==2)return true;for(int i=2;i*i<=x;++i)if(x%i==0)return false;return true; inline int read() char ch=getchar();int s=0,w=1; while(ch<48||ch>57)if(ch==‘-‘)w=-1;ch=getchar(); while(ch>=48&&ch<=57)s=(s<<1)+(s<<3)+ch-48;ch=getchar(); return s*w; inline void write(int x) if(x<0)putchar(‘-‘),x=-x; if(x>9)write(x/10); putchar(x%10+48); int gcd(int a, int b) if(a==0) return b; if(b==0) return a; if(!(a&1)&&!(b&1)) return gcd(a>>1,b>>1)<<1; else if(!(b&1)) return gcd(a,b>>1); else if(!(a&1)) return gcd(a>>1,b); else return gcd(abs(a-b),min(a,b)); int lcm(int x,int y)return x*y/gcd(x,y); int n,m; string name[1005],ip[1005]; string ord,iip; signed main() ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n>>m; re(i,1,n) cin>>name[i]>>ip[i]; re(i,1,m) cin>>ord>>iip; int pos=-1; re(j,1,n) if(iip==ip[j]+‘;‘) pos=j; break; cout<<ord<<‘ ‘<<iip<<" #"<<name[pos]<<endl; return 0;
B、Star sky
看错题一号,我以为nmd最多100个点,没想到是坐标最大100
给你10w个点,每个点有一个发光值,你需要回答10w个询问,每次询问某时刻一个矩形内所有点的发光值总和
发光值会随着时间改变,0,1,2,...,c往复循环,c最大不超过10
二维前缀和做的是某区域某发光值的点个数,然后把这些点个数乘以这一时刻他们的发光值即可
很巧妙的思维转换
代码:
#include <bits/stdc++.h> #define int long long #define sc(a) scanf("%lld",&a) #define scc(a,b) scanf("%lld %lld",&a,&b) #define sccc(a,b,c) scanf("%lld %lld %lld",&a,&b,&c) #define scs(a) scanf("%s",a) #define schar(a) scanf("%c",&a) #define pr(a) printf("%lld",a) #define fo(i,a,b) for(int i=a;i<b;++i) #define re(i,a,b) for(int i=a;i<=b;++i) #define rfo(i,a,b) for(int i=a;i>b;--i) #define rre(i,a,b) for(int i=a;i>=b;--i) #define prn() printf("\\n") #define prs() printf(" ") #define mkp make_pair #define pii pair<int,int> #define pub(a) push_back(a) #define pob() pop_back() #define puf(a) push_front(a) #define pof() pop_front() #define fst first #define snd second #define frt front() #define bak back() #define mem0(a) memset(a,0,sizeof(a)) #define memmx(a) memset(a,0x3f3f,sizeof(a)) #define memmn(a) memset(a,-0x3f3f,sizeof(a)) #define debug #define db double #define yyes cout<<"YES"<<endl; #define nno cout<<"NO"<<endl; #define all(i,a) for(auto i=a.begin();i!=a.end();++i) using namespace std; typedef vector<int> vei; typedef vector<pii> vep; typedef map<int,int> mpii; typedef map<char,int> mpci; typedef map<string,int> mpsi; typedef deque<int> deqi; typedef deque<char> deqc; typedef priority_queue<int> mxpq; typedef priority_queue<int,vector<int>,greater<int> > mnpq; typedef priority_queue<pii> mxpqii; typedef priority_queue<pii,vector<pii>,greater<pii> > mnpqii; const int maxn=500005; const int inf=0x3f3f3f3f3f3f3f3f; const int MOD=100000007; const db eps=1e-10; const db pi=3.1415926535; int qpow(int a,int b)int tmp=a%MOD,ans=1;while(b)if(b&1)ans*=tmp,ans%=MOD;tmp*=tmp,tmp%=MOD,b>>=1;return ans; int lowbit(int x)return x&-x; int max(int a,int b)return a>b?a:b; int min(int a,int b)return a<b?a:b; int mmax(int a,int b,int c)return max(a,max(b,c)); int mmin(int a,int b,int c)return min(a,min(b,c)); void mod(int &a)a+=MOD;a%=MOD; bool chk(int now) int half(int l,int r)while(l<=r)int m=(l+r)/2;if(chk(m))r=m-1;else l=m+1;return l; int ll(int p)return p<<1; int rr(int p)return p<<1|1; int mm(int l,int r)return (l+r)/2; int lg(int x)if(x==0) return 1;return (int)log2(x)+1; bool smleql(db a,db b)if(a<b||fabs(a-b)<=eps)return true;return false; bool bigeql(db a,db b)if(a>b||fabs(a-b)<=eps)return true;return false; bool eql(db a,db b)if(fabs(a-b)<eps) return 1;return 0; db len(db a,db b,db c,db d)return sqrt((a-c)*(a-c)+(b-d)*(b-d)); bool isp(int x)if(x==1)return false;if(x==2)return true;for(int i=2;i*i<=x;++i)if(x%i==0)return false;return true; inline int read() char ch=getchar();int s=0,w=1; while(ch<48||ch>57)if(ch==‘-‘)w=-1;ch=getchar(); while(ch>=48&&ch<=57)s=(s<<1)+(s<<3)+ch-48;ch=getchar(); return s*w; inline void write(int x) if(x<0)putchar(‘-‘),x=-x; if(x>9)write(x/10); putchar(x%10+48); int gcd(int a, int b) if(a==0) return b; if(b==0) return a; if(!(a&1)&&!(b&1)) return gcd(a>>1,b>>1)<<1; else if(!(b&1)) return gcd(a,b>>1); else if(!(a&1)) return gcd(a>>1,b); else return gcd(abs(a-b),min(a,b)); int lcm(int x,int y)return x*y/gcd(x,y); int n,q,c; int sum[105][105][15]; int x,y,s; void pre() re(k,0,c) re(i,1,100) re(j,1,100) sum[i][j][k]=sum[i][j][k] +sum[i-1][j][k]+sum[i][j-1][k] -sum[i-1][j-1][k]; int get(int x1,int y1,int x2,int y2,int cc) return sum[x2][y2][cc] -sum[x1-1][y2][cc]-sum[x2][y1-1][cc] +sum[x1-1][y1-1][cc]; signed main() ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n>>q>>c; re(i,1,n) cin>>x>>y>>s; sum[x][y][s]++; pre(); int t,x1,y1,x2,y2; while(q--) cin>>t>>x1>>y1>>x2>>y2; t%=(c+1); int ans=0; re(i,0,c) ans+=get(x1,y1,x2,y2,i)*((i+t)%(c+1)); cout<<ans<<endl; return 0;
C.、Tell Your World
看错题二号,是找两条平行线使得他们经过所有点并且没有某个点位于两条直线上
说白了就是不要重合
检查三个斜率,第一第二点,第二第三点,第一第三点
把不在这条直线上的点拎出来单独检查,看是否满足平行且不重合的条件
代码:
#include <bits/stdc++.h> #define int long long #define sc(a) scanf("%lld",&a) #define scc(a,b) scanf("%lld %lld",&a,&b) #define sccc(a,b,c) scanf("%lld %lld %lld",&a,&b,&c) #define scs(a) scanf("%s",a) #define schar(a) scanf("%c",&a) #define pr(a) printf("%lld",a) #define fo(i,a,b) for(int i=a;i<b;++i) #define re(i,a,b) for(int i=a;i<=b;++i) #define rfo(i,a,b) for(int i=a;i>b;--i) #define rre(i,a,b) for(int i=a;i>=b;--i) #define prn() printf("\\n") #define prs() printf(" ") #define mkp make_pair #define pii pair<int,int> #define pub(a) push_back(a) #define pob() pop_back() #define puf(a) push_front(a) #define pof() pop_front() #define fst first #define snd second #define frt front() #define bak back() #define mem0(a) memset(a,0,sizeof(a)) #define memmx(a) memset(a,0x3f3f,sizeof(a)) #define memmn(a) memset(a,-0x3f3f,sizeof(a)) #define debug #define db double #define yyes cout<<"Yes"<<endl; #define nno cout<<"No"<<endl; #define all(i,a) for(auto i=a.begin();i!=a.end();++i) using namespace std; typedef vector<int> vei; typedef vector<pii> vep; typedef map<int,int> mpii; typedef map<char,int> mpci; typedef map<string,int> mpsi; typedef deque<int> deqi; typedef deque<char> deqc; typedef priority_queue<int> mxpq; typedef priority_queue<int,vector<int>,greater<int> > mnpq; typedef priority_queue<pii> mxpqii; typedef priority_queue<pii,vector<pii>,greater<pii> > mnpqii; const int maxn=500005; const int inf=0x3f3f3f3f3f3f3f3f; const int MOD=100000007; const db eps=1e-10; const db pi=3.1415926535; int qpow(int a,int b)int tmp=a%MOD,ans=1;while(b)if(b&1)ans*=tmp,ans%=MOD;tmp*=tmp,tmp%=MOD,b>>=1;return ans; int lowbit(int x)return x&-x; int max(int a,int b)return a>b?a:b; int min(int a,int b)return a<b?a:b; int mmax(int a,int b,int c)return max(a,max(b,c)); int mmin(int a,int b,int c)return min(a,min(b,c)); void mod(int &a)a+=MOD;a%=MOD; bool chk(int now) int half(int l,int r)while(l<=r)int m=(l+r)/2;if(chk(m))r=m-1;else l=m+1;return l; int ll(int p)return p<<1; int rr(int p)return p<<1|1; int mm(int l,int r)return (l+r)/2; int lg(int x)if(x==0) return 1;return (int)log2(x)+1; bool smleql(db a,db b)if(a<b||fabs(a-b)<=eps)return true;return false; bool bigeql(db a,db b)if(a>b||fabs(a-b)<=eps)return true;return false; bool eql(db a,db b)if(fabs(a-b)<eps) return 1;return 0; db len(db a,db b,db c,db d)return sqrt((a-c)*(a-c)+(b-d)*(b-d)); bool isp(int x)if(x==1)return false;if(x==2)return true;for(int i=2;i*i<=x;++i)if(x%i==0)return false;return true; inline int read() char ch=getchar();int s=0,w=1; while(ch<48||ch>57)if(ch==‘-‘)w=-1;ch=getchar(); while(ch>=48&&ch<=57)s=(s<<1)+(s<<3)+ch-48;ch=getchar(); return s*w; inline void write(int x) if(x<0)putchar(‘-‘),x=-x; if(x>9)write(x/10); putchar(x%10+48); int gcd(int a, int b) if(a==0) return b; if(b==0) return a; if(!(a&1)&&!(b&1)) return gcd(a>>1,b>>1)<<1; else if(!(b&1)) return gcd(a,b>>1); else if(!(a&1)) return gcd(a>>1,b); else return gcd(abs(a-b),min(a,b)); int lcm(int x,int y)return x*y/gcd(x,y); int n,y[maxn]; mpii mp; bool ok(db k) db b=y[1]-k*1; vector<pii> v; re(i,1,n) if(!eql(y[i],i*k+b)) v.pub(mkp(i,y[i])); // cout<<v.size()<<endl; if(v.size()==0) return 0; else if(v.size()==1) return 1; db k2=((db)v[0].snd-(db)v[1].snd)/((db)v[0].fst-(db)v[1].fst); db b2=v[0].snd-k2*v[0].fst; if(!eql(k2,k)||eql(b2,b)) return 0; all(i,v) if(!eql(i->snd,i->fst*k2+b2)) return 0; return 1; signed main() ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n;re(i,1,n) cin>>y[i],mp[y[i]]++; if(mp.size()==1) nno return 0; else if(mp.size()==2) yyes return 0; if(ok(y[2]-y[1])||ok(y[3]-y[2])||ok((y[3]-y[1])/2.0)) yyes else nno return 0;
D、 From Y to Y
你需要构造一堆字符,每把两个字符和并成一个字符串时,对答案的贡献为:
就是每个字母在第一个字符串中的出现次数乘以在第二个字符串中的出现次数,再把二十六个字母的贡献加起来
你需要不断做上述操作直到所有字符都合并成一个字符串,并且你要使构成这个字符串的最小花费等于给定的k
考虑以下情况的最小花费:
a 0
aa 1
aaa 3
aaaa 6
aaaaa 10
不难发现如果按照aaabbb这样的方式构造,答案就是aaa+bbb,因为前后没有任何重合部分
那么把上面这个函数打个表,对每个k枚举一下能拆分成哪几个数字,就做完了
上面函数的规律是f[n]=f[n-1]+n-1
代码:
#include <bits/stdc++.h> #define int long long #define sc(a) scanf("%lld",&a) #define scc(a,b) scanf("%lld %lld",&a,&b) #define sccc(a,b,c) scanf("%lld %lld %lld",&a,&b,&c) #define scs(a) scanf("%s",a) #define schar(a) scanf("%c",&a) #define pr(a) printf("%lld",a) #define fo(i,a,b) for(int i=a;i<b;++i) #define re(i,a,b) for(int i=a;i<=b;++i) #define rfo(i,a,b) for(int i=a;i>b;--i) #define rre(i,a,b) for(int i=a;i>=b;--i) #define prn() printf("\\n") #define prs() printf(" ") #define mkp make_pair #define pii pair<int,int> #define pub(a) push_back(a) #define pob() pop_back() #define puf(a) push_front(a) #define pof() pop_front() #define fst first #define snd second #define frt front() #define bak back() #define mem0(a) memset(a,0,sizeof(a)) #define memmx(a) memset(a,0x3f3f,sizeof(a)) #define memmn(a) memset(a,-0x3f3f,sizeof(a)) #define debug #define db double #define yyes cout<<"YES"<<endl; #define nno cout<<"NO"<<endl; #define all(i,a) for(auto i=a.begin();i!=a.end();++i) using namespace std; typedef vector<int> vei; typedef vector<pii> vep; typedef map<int,int> mpii; typedef map<char,int> mpci; typedef map<string,int> mpsi; typedef deque<int> deqi; typedef deque<char> deqc; typedef priority_queue<int> mxpq; typedef priority_queue<int,vector<int>,greater<int> > mnpq; typedef priority_queue<pii> mxpqii; typedef priority_queue<pii,vector<pii>,greater<pii> > mnpqii; const int maxn=500005; const int inf=0x3f3f3f3f3f3f3f3f; const int MOD=100000007; const db eps=1e-10; const db pi=3.1415926535; int qpow(int a,int b)int tmp=a%MOD,ans=1;while(b)if(b&1)ans*=tmp,ans%=MOD;tmp*=tmp,tmp%=MOD,b>>=1;return ans; int lowbit(int x)return x&-x; int max(int a,int b)return a>b?a:b; int min(int a,int b)return a<b?a:b; int mmax(int a,int b,int c)return max(a,max(b,c)); int mmin(int a,int b,int c)return min(a,min(b,c)); void mod(int &a)a+=MOD;a%=MOD; bool chk(int now) int half(int l,int r)while(l<=r)int m=(l+r)/2;if(chk(m))r=m-1;else l=m+1;return l; int ll(int p)return p<<1; int rr(int p)return p<<1|1; int mm(int l,int r)return (l+r)/2; int lg(int x)if(x==0) return 1;return (int)log2(x)+1; bool smleql(db a,db b)if(a<b||fabs(a-b)<=eps)return true;return false; bool bigeql(db a,db b)if(a>b||fabs(a-b)<=eps)return true;return false; bool eql(db a,db b)if(fabs(a-b)<eps) return 1;return 0; db len(db a,db b,db c,db d)return sqrt((a-c)*(a-c)+(b-d)*(b-d)); bool isp(int x)if(x==1)return false;if(x==2)return true;for(int i=2;i*i<=x;++i)if(x%i==0)return false;return true; inline int read() char ch=getchar();int s=0,w=1; while(ch<48||ch>57)if(ch==‘-‘)w=-1;ch=getchar(); while(ch>=48&&ch<=57)s=(s<<1)+(s<<3)+ch-48;ch=getchar(); return s*w; inline void write(int x) if(x<0)putchar(‘-‘),x=-x; if(x>9)write(x/10); putchar(x%10+48); int gcd(int a, int b) if(a==0) return b; if(b==0) return a; if(!(a&1)&&!(b&1)) return gcd(a>>1,b>>1)<<1; else if(!(b&1)) return gcd(a,b>>1); else if(!(a&1)) return gcd(a>>1,b); else return gcd(abs(a-b),min(a,b)); int lcm(int x,int y)return x*y/gcd(x,y); int k; int f[maxn]; signed main() ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); int cnt=2; while(1) f[cnt]=f[cnt-1]+cnt-1; if(f[cnt]+cnt>150000) break; cnt++; // cout<<cnt<<endl;re(i,1,cnt) cout<<f[i]<<endl; cin>>k; if(k==0) cout<<‘a‘; else char c=‘a‘; while(k!=0) int p=upper_bound(f+1,f+1+cnt,k)-f; p--; k-=f[p]; re(i,1,p) cout<<c; c++; return 0;
E、Dynamic Problem Scoring
究极大模拟,杀死double人
题面太抽象了,说有个人开挂,然后给你介绍了一大堆CF的规则
问你他最少需要几个小号才能把AC率拉低并且胜过另一个人
枚举10w个小号即可,注意不要用double,因为分数除以250都除的尽
代码:
#include <bits/stdc++.h> #define int long long #define sc(a) scanf("%lld",&a) #define scc(a,b) scanf("%lld %lld",&a,&b) #define sccc(a,b,c) scanf("%lld %lld %lld",&a,&b,&c) #define scs(a) scanf("%s",a) #define schar(a) scanf("%c",&a) #define pr(a) printf("%lld",a) #define fo(i,a,b) for(int i=a;i<b;++i) #define re(i,a,b) for(int i=a;i<=b;++i) #define rfo(i,a,b) for(int i=a;i>b;--i) #define rre(i,a,b) for(int i=a;i>=b;--i) #define prn() printf("\\n") #define prs() printf(" ") #define mkp make_pair #define pii pair<int,int> #define pub(a) push_back(a) #define pob() pop_back() #define puf(a) push_front(a) #define pof() pop_front() #define fst first #define snd second #define frt front() #define bak back() #define mem0(a) memset(a,0,sizeof(a)) #define memmx(a) memset(a,0x3f3f,sizeof(a)) #define memmn(a) memset(a,-0x3f3f,sizeof(a)) #define debug #define db double #define yyes cout<<"YES"<<endl; #define nno cout<<"NO"<<endl; #define all(i,a) for(auto i=a.begin();i!=a.end();++i) using namespace std; typedef vector<int> vei; typedef vector<pii> vep; typedef map<int,int> mpii; typedef map<char,int> mpci; typedef map<string,int> mpsi; typedef deque<int> deqi; typedef deque<char> deqc; typedef priority_queue<int> mxpq; typedef priority_queue<int,vector<int>,greater<int> > mnpq; typedef priority_queue<pii> mxpqii; typedef priority_queue<pii,vector<pii>,greater<pii> > mnpqii; const int maxn=500005; const int inf=0x3f3f3f3f3f3f3f3f; const int MOD=100000007; const db eps=1e-10; const db pi=3.1415926535; int qpow(int a,int b)int tmp=a%MOD,ans=1;while(b)if(b&1)ans*=tmp,ans%=MOD;tmp*=tmp,tmp%=MOD,b>>=1;return ans; int lowbit(int x)return x&-x; int max(int a,int b)return a>b?a:b; int min(int a,int b)return a<b?a:b; int mmax(int a,int b,int c)return max(a,max(b,c)); int mmin(int a,int b,int c)return min(a,min(b,c)); void mod(int &a)a+=MOD;a%=MOD; bool chk(int now) int half(int l,int r)while(l<=r)int m=(l+r)/2;if(chk(m))r=m-1;else l=m+1;return l; int ll(int p)return p<<1; int rr(int p)return p<<1|1; int mm(int l,int r)return (l+r)/2; int lg(int x)if(x==0) return 1;return (int)log2(x)+1; bool smleql(db a,db b)if(a<b||fabs(a-b)<=eps)return true;return false; bool bigeql(db a,db b)if(a>b||fabs(a-b)<=eps)return true;return false; bool eql(db a,db b)if(fabs(a-b)<eps) return 1;return 0; db len(db a,db b,db c,db d)return sqrt((a-c)*(a-c)+(b-d)*(b-d)); bool isp(int x)if(x==1)return false;if(x==2)return true;for(int i=2;i*i<=x;++i)if(x%i==0)return false;return true; inline int read() char ch=getchar();int s=0,w=1; while(ch<48||ch>57)if(ch==‘-‘)w=-1;ch=getchar(); while(ch>=48&&ch<=57)s=(s<<1)+(s<<3)+ch-48;ch=getchar(); return s*w; inline void write(int x) if(x<0)putchar(‘-‘),x=-x; if(x>9)write(x/10); putchar(x%10+48); int gcd(int a, int b) if(a==0) return b; if(b==0) return a; if(!(a&1)&&!(b&1)) return gcd(a>>1,b>>1)<<1; else if(!(b&1)) return gcd(a,b>>1); else if(!(a&1)) return gcd(a>>1,b); else return gcd(abs(a-b),min(a,b)); int lcm(int x,int y)return x*y/gcd(x,y); int n; int a[125][10],cnt[10],tmp[10]; int score(int time,int ac,int tot) if(time==-1) return 0; if(2*ac>tot) return 2*(250-time); if(4*ac>tot) return 4*(250-time); if(8*ac>tot) return 6*(250-time); if(16*ac>tot) return 8*(250-time); if(32*ac>tot) return 10*(250-time); return 12*(250-time); bool ok(int num) re(i,1,5) tmp[i]=cnt[i]; re(i,1,5) if(a[1][i]!=-1&&a[2][i]!=-1) if(a[1][i]>a[2][i]) tmp[i]+=num; int V=0,P=0; re(i,1,5) V+=score(a[1][i],tmp[i],n+num); P+=score(a[2][i],tmp[i],n+num); return V>P; signed main() ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n; re(i,1,n) re(j,1,5) cin>>a[i][j]; if(a[i][j]!=-1) cnt[j]++; re(num,0,100000) if(ok(num)) cout<<num; return 0; cout<<-1; return 0;
以上是关于20190926CF训练的主要内容,如果未能解决你的问题,请参考以下文章