33OJ
登录 注册

#P14358. [CSP-J 2025] 座位

    ID: 16146 远端评测题 1000ms 512MiB 尝试: 67 已通过: 22 显示难度普及− 上传者: 标签>模拟数学2025O2优化排序CSP-J 入门级

[CSP-J 2025] 座位

Problem Description

The second round of CSP-J 2025 is underway. There are n×mn \times m contestants in the examination room where Little R is located, and the CSP-J 2025 first-round scores of all these contestants are pairwise distinct. All n×mn \times m contestants are assigned seats in a snake-like order from highest score to lowest score according to their CSP-J 2025 first-round scores, and are arranged into nn rows and mm columns. Specifically, let the scores of all contestants in Little R's examination room be s1>s2>⋯>sn×ms_1 > s_2 > \dots > s_{n \times m} from highest to lowest. Then the contestant with score s1s_1 sits at column 11, row 11; the contestant with score s2s_2 sits at column 11, row 22; …\dots; the contestant with score sns_n sits at column 11, row nn; the contestant with score sn+1s_{n+1} sits at column 22, row nn; …\dots; the contestant with score s2ns_{2n} sits at column 22, row 11; the contestant with score s2n+1s_{2n+1} sits at column 33, row 11; and so on.

For example, if n=4,m=5n = 4, m = 5, then all 4×5=204 \times 5 = 20 contestants are assigned seats in the order of the arrows in the figure below, according to their CSP-J 2025 first-round scores from highest to lowest.

:::align{center} :::

Given the number of rows nn and the number of columns mm of the seats in Little R's examination room, as well as the CSP-J 2025 first-round scores a1,a2,…,an×ma_1, a_2, \dots, a_{n \times m} of all contestants in that room, where a1a_1 is the CSP-J 2025 first-round score of Little R, you need to help Little R determine at which column and which row his seat is.

Input Format

The first line of input contains two positive integers n,mn, m, representing the number of rows and the number of columns of the seats in Little R's examination room, respectively.

The second line of input contains n×mn \times m positive integers a1,a2,…,an×ma_1, a_2, \dots, a_{n \times m}, representing the CSP-J 2025 first-round scores of all contestants in Little R's examination room, where a1a_1 is the CSP-J 2025 first-round score of Little R.

Output Format

Output two positive integers c,rc, r on a single line, representing that Little R's seat is at column cc, row rr.

2 2
99 100 97 98
1 2
2 2
98 99 100 97
2 2
3 3
94 95 96 97 98 99 100 93 92
3 1

Hint

Example 1 Explanation

In the order of scores from highest to lowest, the contestant with score 100100 sits at column 11, row 11; the contestant with score 9999 sits at column 11, row 22; the contestant with score 9898 sits at column 22, row 22; and the contestant with score 9797 sits at column 22, row 11. Little R's score is 9999, so his seat is at column 11, row 22.

Example 2 Explanation

In the order of scores from highest to lowest, the contestant with score 100100 sits at column 11, row 11; the contestant with score 9999 sits at column 11, row 22; the contestant with score 9898 sits at column 22, row 22; and the contestant with score 9797 sits at column 22, row 11. Little R's score is 9898, so his seat is at column 22, row 22.

Constraints

For all test data, it is guaranteed that:

  • 1≤n≤101 \leq n \leq 10, 1≤m≤101 \leq m \leq 10;
  • for all 1≤i≤n×m1 \leq i \leq n \times m, 1≤ai≤1001 \leq a_i \leq 100, and a1,a2,…,an×ma_1, a_2, \dots, a_{n \times m} are pairwise distinct.

::cute-table{tuack}

Test point n≤n \leq m≤m \leq Special property
11 AB
2,32, 3 ^ 1010 None
4,54, 5 1010 11 ^
66 22 A
77 ^ ^ B
8,98, 9 None
1010 1010 A
1111 ^ B
12∼1412 \sim 14 None
15∼1715 \sim 17 1010 22 ^
18∼2018 \sim 20 ^ 1010

Special property A: for all 1≤i≤n×m1 \leq i \leq n \times m, ai=ia_i = i.

Special property B: for all 1≤i≤n×m1 \leq i \leq n \times m, ai=n×m−i+1a_i = n \times m - i + 1.

Translated by QwenWork