CUC-SUMMER-1-I

I - Is it rated?
CodeForces - 807A

Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.

Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.

It's known that if at least one participant's rating has changed, then the round was rated for sure.

It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.

In this problem, you should not make any other assumptions about the rating system.

Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.

Input
The first line contains a single integer n (2?≤?n?≤?1000) — the number of round participants.

Each of the next n lines contains two integers ai and bi (1?≤?ai,?bi?≤?4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.

Output
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".

Example

Input
6
3060 3060
2194 2194
2876 2903
2624 2624
3007 2991
2884 2884
Output
rated

Input
4
1500 1500
1300 1300
1200 1200
1400 1400
Output
unrated
Input
5
3123 3123
2777 2777
2246 2246
2246 2246
1699 1699
Output
maybe

Note
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.

In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.

In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.


解法:評分改變的為rated,沒改變且降序排列的為maybe,其他為unrated

代碼:

#include<iostream>
using namespace std;
int main()
{
    int s;
    cin>>s;
    int temp;
    int rank=2;
    for(int i=0;i<s;i++){
        int a,b;
        cin>>a;
        cin>>b;
        if(i==0)
            temp=a;
        if(rank!=1)
        {
            if(a!=b)
                rank = 1;
            else{
                if(a>temp)
                    rank = 3;
                temp = a;
            }
        }       
    }
    if(rank==1)
        cout<<"rated";
    else if(rank==3)
        cout<<"unrated";
    else
        cout<<"maybe";
    return 0;
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市爱沟,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌救崔,老刑警劉巖琉挖,帶你破解...
    沈念sama閱讀 221,576評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件凌受,死亡現(xiàn)場離奇詭異店雅,居然都是意外死亡政基,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,515評論 3 399
  • 文/潘曉璐 我一進店門闹啦,熙熙樓的掌柜王于貴愁眉苦臉地迎上來沮明,“玉大人,你說我怎么就攤上這事窍奋〖鼋。” “怎么了?”我有些...
    開封第一講書人閱讀 168,017評論 0 360
  • 文/不壞的土叔 我叫張陵费变,是天一觀的道長摧扇。 經(jīng)常有香客問我,道長挚歧,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,626評論 1 296
  • 正文 為了忘掉前任吁峻,我火速辦了婚禮滑负,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘用含。我一直安慰自己矮慕,他們只是感情好,可當我...
    茶點故事閱讀 68,625評論 6 397
  • 文/花漫 我一把揭開白布啄骇。 她就那樣靜靜地躺著痴鳄,像睡著了一般。 火紅的嫁衣襯著肌膚如雪缸夹。 梳的紋絲不亂的頭發(fā)上痪寻,一...
    開封第一講書人閱讀 52,255評論 1 308
  • 那天,我揣著相機與錄音虽惭,去河邊找鬼橡类。 笑死,一個胖子當著我的面吹牛芽唇,可吹牛的內(nèi)容都是我干的顾画。 我是一名探鬼主播,決...
    沈念sama閱讀 40,825評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼研侣!你這毒婦竟也來了谱邪?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,729評論 0 276
  • 序言:老撾萬榮一對情侶失蹤庶诡,失蹤者是張志新(化名)和其女友劉穎惦银,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體灌砖,經(jīng)...
    沈念sama閱讀 46,271評論 1 320
  • 正文 獨居荒郊野嶺守林人離奇死亡璧函,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,363評論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了基显。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片蘸吓。...
    茶點故事閱讀 40,498評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖撩幽,靈堂內(nèi)的尸體忽然破棺而出库继,到底是詐尸還是另有隱情,我是刑警寧澤窜醉,帶...
    沈念sama閱讀 36,183評論 5 350
  • 正文 年R本政府宣布宪萄,位于F島的核電站,受9級特大地震影響榨惰,放射性物質(zhì)發(fā)生泄漏拜英。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,867評論 3 333
  • 文/蒙蒙 一琅催、第九天 我趴在偏房一處隱蔽的房頂上張望居凶。 院中可真熱鬧,春花似錦藤抡、人聲如沸侠碧。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,338評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽弄兜。三九已至,卻和暖如春瓷式,著一層夾襖步出監(jiān)牢的瞬間替饿,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,458評論 1 272
  • 我被黑心中介騙來泰國打工蒿往, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留盛垦,地道東北人。 一個月前我還...
    沈念sama閱讀 48,906評論 3 376
  • 正文 我出身青樓瓤漏,卻偏偏與公主長得像腾夯,于是被迫代替她去往敵國和親颊埃。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,507評論 2 359

推薦閱讀更多精彩內(nèi)容