Assessment Disruption

시간 제한2초메모리 제한1024 MB

요약
교수가 파레토 지배 관계로 논문을 채점하는 알고리즘이 최소 N^3/20번의 비교를 하도록, 서로 다른 (w, q) 쌍 N개를 구성해 출력한다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 구현, 수학
정답자
아직 제출이 없습니다

문제

It is finally time to submit your essays on economics for assessment!

Each essay is characterised by its word count ww and its quality qq. The required word count is WW, so the closer ww to WW is in your essay, the better mark you may expect. And, surely, the higher the quality, the better. However, one essay can have a better quality and a bigger deviation from WW than another, so it is not clear which one is better.

As an economics student, you may know that this kind of situation is captured by Pareto dominance. Formally, essay AA is said to dominate essay BB in the Pareto sense if ∣w_A−W∣≤∣w_B−W∣|w\_A - W| \le |w\_B - W|, q_A≥q_Bq\_A \ge q\_B, and at least one of these inequalities is strict.

The professor is known to use this relation to mark the essays. First, she finds all the best essays: those that are not dominated by any other essay. These essays receive the same mark, which is the highest among this year's students (but still can fall below their expectations!). Then she removes the marked essays and repeats the procedure, but the mark will be lower this time, and so on. More precisely, she uses the following algorithm:

  • All the essays are numbered from 1 to NN.

  • Each essay can be either in work, postponed, or marked. Initially, all essays are in work.

  • A variable rr captures the rank of an essay, the lower, the better. Initially, r←1r \gets 1.

  • While there are any essays that are in work:

    • Iterate over all essay numbers from 1 to NN. If the ii-th essay is in work:

      • Iterate over all essay numbers from i+1i+1 to NN. If the jj-th essay is in work, compare essays ii and jj for dominance:

        • If ii dominates jj, turn jj into postponed.
        • If jj dominates ii, turn ii into postponed and break the loop.
      • If the ii-th essay is still in work, it receives rank rr and turns into marked.

    • All postponed essays become in work again.

    • The rank is increased: r←r+1r \gets r + 1.

You are afraid that you, and everyone else, will get low marks, but someone told you that if it took the professor too long to perform the entire assessment, the department would take it over, and the final marks would be based on a simple multiple-choice quiz. By rigorous computations you found out that the number of essay comparisons should be at least N3/20N^3 / 20 for this to happen. Find the way to disrupt the assessment procedure.

입력

The first and only line of the input file contains two numbers, NN (2≤N≤103)(2 \le N \le 10^3) and WW (0≤W≤104)(0 \le W \le 10^4), separated by a whitespace.

출력

Output NN lines. The ii-th line, 1≤i≤N1 \le i \le N, should contain the word count w_iw\_i and the quality q_iq\_i of the ii-th essay. They should be integers that satisfy 0≤w_i≤1040 \le w\_i \le 10^4 and 0≤q_i≤1030 \le q\_i \le 10^3. No two essays should be described by the same pair of numbers, because this counts as collusion, which you would want to avoid at all costs.

예제1

  1. 예제 1

    입력
    3 2500
    
    예상 출력
    2500 528
    2480 543
    2520 511