CF792F.Mages and Monsters

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vova plays a computer game known as Mages and Monsters. Vova's character is a mage. Though as he has just started, his character knows no spells.

Vova's character can learn new spells during the game. Every spell is characterized by two values xix_{i} and yiy_{i} — damage per second and mana cost per second, respectively. Vova doesn't have to use a spell for an integer amount of seconds. More formally, if he uses a spell with damage xx and mana cost yy for zz seconds, then he will deal xzx·z damage and spend yzy·z mana (no rounding). If there is no mana left (mana amount is set in the start of the game and it remains the same at the beginning of every fight), then character won't be able to use any spells. It is prohibited to use multiple spells simultaneously.

Also Vova can fight monsters. Every monster is characterized by two values tjt_{j} and hjh_{j} — monster kills Vova's character in tjt_{j} seconds and has hjh_{j} health points. Mana refills after every fight (or Vova's character revives with full mana reserve), so previous fights have no influence on further ones.

Vova's character kills a monster, if he deals hjh_{j} damage to it in no more than tjt_{j} seconds using his spells (it is allowed to use more than one spell in a fight) and spending no more mana than he had at the beginning of the fight. If monster's health becomes zero exactly in tjt_{j} seconds (it means that the monster and Vova's character kill each other at the same time), then Vova wins the fight.

You have to write a program which can answer two types of queries:

  • 11 xx yy — Vova's character learns new spell which deals xx damage per second and costs yy mana per second.
  • 22 tt hh — Vova fights the monster which kills his character in tt seconds and has hh health points.

Note that queries are given in a different form. Also remember that Vova's character knows no spells at the beginning of the game.

For every query of second type you have to determine if Vova is able to win the fight with corresponding monster.

输入格式

The first line contains two integer numbers qq and mm (2<=q<=105,1<=m<=1012)(2<=q<=10^{5},1<=m<=10^{12}) — the number of queries and the amount of mana at the beginning of every fight.

ii -th of each next qq lines contains three numbers kik_{i} , aia_{i} and bib_{i} (1<=ki<=2,1<=ai,bi<=106)(1<=k_{i}<=2,1<=a_{i},b_{i}<=10^{6}) .

Using them you can restore queries this way: let jj be the index of the last query of second type with positive answer ( j=0j=0 if there were none of these).

  • If ki=1k_{i}=1 , then character learns spell with x=(ai+j)x=(a_{i}+j) modmod 106+110^{6}+1 , y=(bi+j)y=(b_{i}+j) modmod 106+110^{6}+1 .
  • If ki=2k_{i}=2 , then you have to determine if Vova is able to win the fight against monster with t=(ai+j)t=(a_{i}+j) modmod 106+110^{6}+1 , h=(bi+j)h=(b_{i}+j) modmod 106+110^{6}+1 .

输出格式

For every query of second type print YES if Vova is able to win the fight with corresponding monster and NO otherwise.

输入输出样例

  • 输入#1

    3 100
    1 4 9
    2 19 49
    2 19 49
    

    输出#1

    YES
    NO
    

说明/提示

In first example Vova's character at first learns the spell with 55 damage and 1010 mana cost per second. Next query is a fight with monster which can kill character in 2020 seconds and has 5050 health points. Vova kills it in 1010 seconds (spending 100100 mana). Next monster has 5252 health, so Vova can't deal that much damage with only 100100 mana.

首页