<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        codeforcesRound#241(div2)A解題報告

        來源:懂視網 責編:小采 時間:2020-11-09 08:02:28
        文檔

        codeforcesRound#241(div2)A解題報告

        codeforcesRound#241(div2)A解題報告:A. Guess a number! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A TV show called Guess a number! is gathering popularity. The whole Berland, the old and the young, are watchin
        推薦度:
        導讀codeforcesRound#241(div2)A解題報告:A. Guess a number! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A TV show called Guess a number! is gathering popularity. The whole Berland, the old and the young, are watchin

        A. Guess a number! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A TV show called Guess a number! is gathering popularity. The whole Berland, the old and the young, are watchin

        A. Guess a number!

        time limit per test

        1 second

        memory limit per test

        256 megabytes

        input

        standard input

        output

        standard output

        A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.

        The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:

      1. Is it true that y is strictly larger than number x?
      2. Is it true that y is strictly smaller than number x?
      3. Is it true that y is larger than or equal to number x?
      4. Is it true that y is smaller than or equal to number x?
      5. On each question the host answers truthfully, "yes" or "no".

        Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".

        Input

        The first line of the input contains a single integer n (1?≤?n?≤?10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:

      6. ">" (for the first type queries),
      7. "<" (for the second type queries),
      8. ">=" (for the third type queries),
      9. "<=" (for the fourth type queries).
      10. All values of x are integer and meet the inequation ?-?109?≤?x?≤?109. The answer is an English letter "Y" (for "yes") or "N" (for "no").

        Consequtive elements in lines are separated by a single space.

        Output

        Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation ?-?2·109?≤?y?≤?2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).

        Sample test(s)

        input

        4
        >= 1 Y
        < 3 N
        <= -3 N
        > 55 N
        

        output

        17
        

        input

        2
        > 100 Y
        < -100 Y
        

        output

        Impossible


        題目大意:

        猜數字,給出n個區(qū)間詢問,然后同時給出該區(qū)間是否正確,然后求出任何符合上述區(qū)間要求的數字.


        解法:

        先將答案范圍規(guī)定為: [l,r] ;其中 l = -2*10^9 r = 2*10^9

        每次讀入,更新一次上屆和下屆,l和r;

        讀入結束后,

        l > r Impossible

        l <= r 隨意輸出一個區(qū)間內的數字即可

        代碼:

        #include 
        #define INF 2000000000
        
        int n;
        
        int max(int a, int b) {
        	if (a > b) return(a);
        	return(b);
        }
        
        int min(int a, int b) {
        	if (a < b) return(a);
        	return(b);
        }
        
        void init() {
        	scanf("%d\n", &n);
        }
        
        void solve() {
        	int l = -INF, r = INF, x;
        	char ch1, ch2, ch3;
        
        	for (int i = 1; i <= n; i++) {
        	ch1 = getchar();
        	ch2 = getchar();
        
        	scanf("%d ", &x);
        	ch3 = getchar();
        	getchar();
        
        	if (ch3 == 'Y') {
        	if (ch1 == '>') {
        	if (ch2 == '=')
        	l = max(x, l);
        	else
        	l = max(x+1, l);
        	}
        
        	if (ch1 == '<') {
        	if (ch2 == '=')
        	r = min(r, x);
        	else
        	r = min(r, x-1);
        	}
        	}
        
        	if (ch3 == 'N') {
        	if (ch1 == '>') {
        	if (ch2 == '=')
        	r = min(r, x-1);
        	else
        	r = min(r, x);
        	}
        
        	if (ch1 == '<') {
        	if (ch2 == '=')
        	l = max(l, x+1);
        	else
        	l = max(l, x);
        	}
        	}
        
        	}
        
        	if (l <= r)
        	printf("%d", l);
        	else
        	printf("Impossible");
        }
        
        int main() {
        	init();
        	solve();
        }



        .

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        codeforcesRound#241(div2)A解題報告

        codeforcesRound#241(div2)A解題報告:A. Guess a number! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A TV show called Guess a number! is gathering popularity. The whole Berland, the old and the young, are watchin
        推薦度:
        標簽: aa 解題 round
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 国产妇乱子伦视频免费| 18禁超污无遮挡无码免费网站| 蜜桃AV无码免费看永久| 亚洲AV午夜成人片| 久久免费视频精品| 亚洲色WWW成人永久网址| 中中文字幕亚洲无线码| 精品久久久久成人码免费动漫| 亚洲欧洲精品国产区| 人禽杂交18禁网站免费| 亚洲av日韩综合一区二区三区| 免费的涩涩视频在线播放| 四虎影视在线看免费观看| 亚洲无人区一区二区三区| 久久成人免费播放网站| 久久久无码精品亚洲日韩按摩| 久草视频在线免费| 亚洲欧美日韩综合久久久| 亚洲va中文字幕无码| 免费人成毛片动漫在线播放| 亚洲系列中文字幕| 日本一道一区二区免费看| 精品多毛少妇人妻AV免费久久| 亚洲国产日韩一区高清在线 | 亚洲成av人片天堂网无码】| 免费一级毛片在线播放| 国产亚洲免费的视频看| 成全视频免费高清 | 亚洲精品无码成人片久久不卡| 在线不卡免费视频| 国产成人无码精品久久久久免费| 亚洲s色大片在线观看| 在线播放高清国语自产拍免费| igao激情在线视频免费| 亚洲日韩乱码中文无码蜜桃| 免费jjzz在线播放国产| 99久久久国产精品免费牛牛| 国产精品亚洲lv粉色| 亚洲va久久久噜噜噜久久天堂| 成人一a毛片免费视频| 久久一区二区三区免费|