Ural 1971 (Graphics settings-latency calculation)

Source: Internet
Author: User

1971. Graphics settingstime limit: 2.0 second
Memory limit: 64 MB
Given n options and M operations, ask the image generation speed = P/(w * H * ∏ ki (The I option is enabled) in which interval. First input Behavior N(0 ≤ N≤ 100 000). The next line I contains the command name S I, And integer K I(2 ≤ K I≤ 100), the command name is a lowercase letter string with a length of [1, 10], and the next line is W, H, And P(Less than or equal to 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. The initial options are all open. The next step is the number of commands. M  (1 ≤ M≤ 100 000) . Next MThe following command is provided:
  • "On s"-EnabledS;
  • "Off s"-closeS;
  • "Resolution w h"-set the screen resolutionW×HPixels (320 ≤WLess than or equal to 2 560; 200 less than or equalH≤ 1 600 ).
Make sure that the option is disabled only when it is enabled. outputthe first line shoshould describe the performance of the game before changes in the settings. Then next MLines shocould 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
Input Output
1vsync 10640 480 100000002Off vsyncResolution 320 240
SlideshowSo-soPerfect
Problem Author:Denis dublennykh
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)

It is not difficult to understand the idea of this question. The problem is that when the I option is enabled, it will overflow.

Therefore, we use queue storage to delay its computing and prevent overflow.


# 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 --) # define repd (I, n) for (INT I = N; I> = 0; I --) # define forp (x) for (int P = pre [X]; 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 ()); # 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 (1000000 000) # define maxm (100000 + 10) long MUL (long a, long B) {return (A * B) % F ;} long long add (long a, long B) {return (a + B) % F;} long sub (long a, long B) {return (a-B + (a-B)/f * F + F) % F;} typedef 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 indicates the current shard K // question: 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 ;}








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.