国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答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:

  • Is it true that y is strictly larger than number x?
  • Is it true that y is strictly smaller than number x?
  • Is it true that y is larger than or equal to number x?
  • Is it true that y is smaller than or equal to number x?
  • 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:

  • ">" (for the first type queries),
  • "<" (for the second type queries),
  • ">=" (for the third type queries),
  • "<=" (for the fourth type queries).
  • 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個區間詢問,然后同時給出該區間是否正確,然后求出任何符合上述區間要求的數字.


    解法:

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

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

    讀入結束后,

    l > r Impossible

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

    代碼:

    #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
    主站蜘蛛池模板: 国产一区二区三区成人久久片 | 亚洲欧美日韩另类在线专区 | 国产麻豆精品 | 国产短视频精品一区二区三区 | 五月天婷婷视频在线观看 | 精品欧美一区二区三区精品久久 | 日韩国产免费一区二区三区 | 日韩欧美视频在线 | 人人爽天天碰天天躁夜夜躁 | 日韩欧美视频一区二区 | 欧美日韩国产码高清综合人成 | 国产激情一区二区三区成人91 | 一道本一区二区三区 | 亚洲一区中文字幕 | 日韩综合在线 | 国产成人免费高清激情明星 | 91久久精品国产免费一区 | 美女视频黄a视频全免费网站色 | 222aaa免费国产在线观看 | 国产一区三区二区中文在线 | 国产精品香蕉在线观看 | 91导航在线观看 | 久久免费国产精品一区二区 | 国产免费高清视频在线观看不卡 | 国产69精品久久久久999 | 在线观看亚洲欧美 | 日韩欧美国产一区二区三区 | 国产成人精品一区二区免费 | 亚洲欧美影视 | 91中文字幕在线视频 | 欧美精品在线看 | 精品欧美一区二区在线观看欧美熟 | 日本高清天码一区在线播放 | 国内精品免费 | 国产精品激情综合久久 | 在线一区二区三区 | 亚洲色图欧美自拍 | 在线播放一区二区 | 亚洲三级电影在线 | 久久久国产精品视频 | 亚洲欧美日韩色图 |