Ural 1971(Graphics Settings-延迟计算)
来源:互联网 发布:8051单片机引脚 编辑:程序博客网 时间:2024/06/05 21:09
1971. Graphics Settings
Time limit: 2.0 second
Memory limit: 64 MB
Memory limit: 64 MB
给定n个选项,m个操作,问the image generation speed=p/(W*H*∏ki(第i个选项开启))在哪个区间。
Input
第一行为 n (0 ≤ n ≤ 100 000). 接下来第i行分别有指令名 si, 和整数 ki(2 ≤ ki ≤ 100),指令名为长度在[1,10]的小写字母字符串,下一行为 W, H,和 p (320 ≤ W ≤ 2 560; 200 ≤ H ≤ 1 600; 1 ≤ p ≤ 109). They are the initial width and height of the screen in pixels and the clock rate of the GPU in cycles per second. 最初选项全开. 接下来为指令数 m (1 ≤ m ≤ 100 000) . 接下来 m 行有如下的指令:
- “On s” — 开启 s;
- “Off s” — 关闭 s;
- “Resolution w h” — set the screen resolution to w × h pixels (320 ≤ w ≤ 2 560; 200 ≤ h≤ 1 600).
保证选项只在开启时关闭,只在关闭时开启.
Output
The first line should describe the performance of the game before changes in the settings. Then nextm lines should describe the performance of the game after each change in the settings. Output “Slideshow” if the image generation speed is less than 10 frames per second, “Perfect” if it is 60 frames per second or greater, and “So-so” otherwise.
Sample
1vsync 10640 480 100000002Off vsyncResolution 320 240
SlideshowSo-soPerfect
Problem Author: Denis Dublennykh
Problem Source: Ural Sport Programming Championship 2013
Problem Source: Ural Sport Programming Championship 2013
Tags: none
)Difficulty: 406 Printable version Submit solution Discussion (9)
My submissions All submissions (2909) All accepted submissions (309) Solutions rating (198)
My submissions All submissions (2909) All accepted submissions (309) Solutions rating (198)
本题思路不难理解,问题在于∏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;}
0 0
- Ural 1971(Graphics Settings-延迟计算)
- URAL 1971 Graphics Settings
- URAL 1971 Graphics Settings 取对数(高精度易超时)
- Graphics Settings
- Unity说明文档翻译-Graphics Settings
- ural 1207 计算几何
- 计算几何 ural 1753
- 计算几何 ural 1874
- clojure编程-延迟计算
- Java 8:延迟计算
- python3 实现延迟计算
- URAL 1436. Billboard(计算几何)
- 如何计算x264编码延迟
- 用Scala实现延迟计算
- 如何计算x264编码延迟
- Lambda计算延迟或是计算错误
- 计算平均非内核请求延迟计算
- 计算几何 ural 1793Tray 2
- hdu 1163 Eddy's digital Roots (数论)
- 1111
- CloudShare.IM 云享,享受云端文档以及即时通讯服务
- Linux内核链表的研究与应用
- 带图标的列表对话框
- Ural 1971(Graphics Settings-延迟计算)
- UNIX下的Matlab的下载 与 安装 (ubuntu系统下可用)
- 8款超酷而实用的CSS3按钮动画
- ABAP程序中的统计求和
- 条件编译(#ifdef #else #endif #if)
- maximo基础信息配置
- FZU1752快速幂取模+乘法的加速
- struts2+spring+maven
- POJ 1742 Coins 多重背包题解