<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
        主站蜘蛛池模板: 亚洲国产精品99久久久久久| 久久中文字幕免费视频| 中文字幕无码免费久久99| 久久久久久亚洲AV无码专区| 亚洲午夜精品一区二区公牛电影院| 国内精品久久久久影院免费| 亚洲女初尝黑人巨高清| 手机看片国产免费永久| 久久精品国产亚洲麻豆| 在线涩涩免费观看国产精品| 久久综合日韩亚洲精品色| 国产精品免费无遮挡无码永久视频 | 亚洲中文字幕无码爆乳av中文 | 亚洲AV无码专区日韩| 免费国产在线精品一区| 亚洲日韩国产精品乱| 一进一出60分钟免费视频| 狠狠亚洲狠狠欧洲2019| 免费污视频在线观看| 在线电影你懂的亚洲| 国产精品美女午夜爽爽爽免费| 亚洲精品伦理熟女国产一区二区| 国产免费av片在线无码免费看 | 亚洲av午夜电影在线观看 | 亚洲av最新在线网址| 91制片厂制作传媒免费版樱花| 亚洲女人影院想要爱| 精品国产麻豆免费网站| 国产免费内射又粗又爽密桃视频 | 国产在线观看免费完整版中文版 | 免费观看的a级毛片的网站| 国产亚洲精品第一综合| 国产亚洲成AV人片在线观黄桃| 18禁成人网站免费观看| 亚洲国产精品无码久久98| 一本久久a久久精品亚洲| 精品成在人线AV无码免费看 | 亚洲午夜精品久久久久久人妖| 免费看美女裸露无档网站| 美女免费视频一区二区| 久久亚洲春色中文字幕久久久|