标签:des style http color strong width
input | output |
---|---|
1 vsync 10 640 480 10000000 2 Off vsync Resolution 320 240 |
Slideshow So-so Perfect |
本题思路不难理解,问题在于∏ki(第i个选项开启)会溢出
所以我们用队列存储,延迟它的计算,防止溢出
#include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<functional> #include<iostream> #include<cmath> #include<cctype> #include<ctime> #include<map> using namespace std; #define For(i,n) for(int i=1;i<=n;i++) #define Fork(i,k,n) for(int i=k;i<=n;i++) #define Rep(i,n) for(int i=0;i<n;i++) #define ForD(i,n) for(int i=n;i;i--) #define RepD(i,n) for(int i=n;i>=0;i--) #define Forp(x) for(int p=pre[x];p;p=next[p]) #define Lson (x<<1) #define Rson ((x<<1)+1) #define MEM(a) memset(a,0,sizeof(a)); #define MEMI(a) memset(a,127,sizeof(a)); #define MEMi(a) memset(a,128,sizeof(a)); #define INF (2139062143) #define F (100000007) #define MAXN (100000+10) #define MAXKi (100+10) #define MAXLen (10+10) #define MAXW (2560+10) #define MAXH (1600+10) #define MINW (320+10) #define MINH (200+10) #define MAXP (1000000000) #define MAXM (100000+10) long long mul(long long a,long long b){return (a*b)%F;} long long add(long long a,long long b){return (a+b)%F;} long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;} typedef long long ll; map<string,int> h; int n,m,val[MAXN],q[MAXM],head=1,tail=0; bool inq[MAXM]={0}; ll W,H,p,res=1; //res表示当前∏k //题意:image generation speed(v)=p/res/W/H<10 / >=60 => res*W*H*10>p res*W*H*60<=p void print() { while (res*W*H*10<=p&&head<=tail) { int now=q[head++]; if (!inq[now]) continue; inq[now]=0;res*=val[now]; } if (p<res*W*H*10) printf("Slideshow\n"); else if (p<res*W*H*60) printf("So-so\n"); else printf("Perfect\n"); } int main() { // freopen("ural1971.in","r",stdin); // freopen(".out","w",stdout); cin>>n; For(i,n) { string s; cin>>s>>val[i]; h[s]=i; q[++tail]=i;inq[i]=1; } cin>>W>>H>>p; cin>>m; print(); For(i,m) { char s[20]; scanf("%s",s); switch (s[1]) { case'n': { string s; cin>>s; int p=h[s]; inq[p]=1;q[++tail]=p; break; } case'f': { string s; cin>>s; int p=h[s]; if (inq[p]) inq[p]=0; else res/=val[p]; break; } default: { cin>>W>>H; } } print(); } return 0; }
Ural 1971(Graphics Settings-延迟计算),布布扣,bubuko.com
Ural 1971(Graphics Settings-延迟计算)
标签:des style http color strong width
原文地址:http://blog.csdn.net/nike0good/article/details/36187563