change b1,b2,… ,bn permits a stretch [l′,r′] to holds its shape if for any pair of integers (x,y) with the end goal that l′≤x

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else downvoted. Computer science.

 

 change b1,b2,… ,bn permits a stretch [l′,r′] to holds its shape if for any pair of integers (x,y) with the end goal that l′≤x<y≤r′, we have bx<by if and provided that ax<ay. 

 

A change b1,b2,… ,bn is k-comparative if b permits all stretches [li,ri] for all 1≤i≤k to hold their shapes. 

 

Yuu needs to sort out all k-comparable changes for Touko, however it turns out this is an exceptionally hard undertaking; all things considered, Yuu will encode the arrangement of all k-comparable stages with coordinated acylic diagrams (DAG). Yuu likewise authored the accompanying definitions for herself: 

 

A change b1,b2,… ,bn fulfills a DAG G′ if for all edge u→v in G′, we should have bu<bv. 

 

A k-encoding is a DAG Gk on the arrangement of vertices 1,2,… ,n with the end goal that a stage b1,b2,… ,bn fulfills Gk if and provided that b is k-comparative. 

 

Since Yuu is free today, she needs to sort out the base number of edges among all k-encodings for every k from 1 to q. 

 

Input 

 

The principal line contains two integers n and q (1≤n≤25000, 1≤q≤100000). 

 

The subsequent line contains n integers a1,a2,… ,a which structure a stage of 1,2,… ,n. 

 

The I-th of the accompanying q lines contains two integers li and ri. (1≤li≤ri≤n). 

 

Output 

 

Print q lines. The k-th of them ought to contain a solitary integer — The base number of edges among every single k-encoding

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Algebraic Expression
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education