K. Jpeg

Codeforces
IDCF10094K
Time2000ms
Memory64MB
Difficulty
English · Original
Formal · Original
In computing, JPEG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography . The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality,and JPEG typically achieves 10:1 compression with little perceptible loss in image quality. Entropy coding is a special form of lossless data compression. It involves arranging the image components in a "zigzag" order employing run-length encoding (RLE) algorithm that groups similar frequencies together, inserting length coding zeros, and then using Huffman coding on what is left. Now i am so busy ,so i will give you a square matrix that represents pixel intensities of the image. Your task is simple: reconstruct the image so that the value in the ith row and jth column of the resulting image is the value of the (i * N + j)th pixel visited in the zigzag sequence . Your program will be tested on one or more test cases. The first line of the input contains a single integer *T* (1  ≤  *T*  ≤  100) the number of test cases. Followed by *T* test cases. Each test case consists of *N+1* lines. The first line contains an integer *N* (2  ≤  *N*  ≤  100). The next lines consists of an squared pixel matrix. For each test case print the required transformed matrix. ## Input Your program will be tested on one or more test cases. The first line of the input contains a single integer *T* (1  ≤  *T*  ≤  100) the number of test cases. Followed by *T* test cases. Each test case consists of *N+1* lines. The first line contains an integer *N* (2  ≤  *N*  ≤  100). The next lines consists of an squared pixel matrix. ## Output For each test case print the required transformed matrix. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case $ k \in \{1, \dots, T\} $: - Let $ N_k \in \mathbb{Z} $ denote the side length of the square matrix. - Let $ M_k = (m_{i,j}^{(k)})_{i,j=1}^{N_k} $ be the input $ N_k \times N_k $ matrix of pixel intensities. - Let $ P_k = (p_1^{(k)}, p_2^{(k)}, \dots, p_{N_k^2}^{(k)}) $ be the zigzag traversal of $ M_k $, where $ p_\ell^{(k)} $ is the $ \ell $-th pixel visited in zigzag order. **Constraints** 1. $ 1 \le T \le 100 $ 2. For each $ k \in \{1, \dots, T\} $: - $ 2 \le N_k \le 100 $ - $ m_{i,j}^{(k)} \in \mathbb{R} $ (pixel intensities, unspecified domain) **Objective** For each test case $ k $, construct the output matrix $ R_k = (r_{i,j}^{(k)})_{i,j=1}^{N_k} $ such that: $$ r_{i,j}^{(k)} = p_{i \cdot N_k + j}^{(k)} \quad \text{for all } i,j \in \{1, \dots, N_k\} $$ where $ p_{i \cdot N_k + j}^{(k)} $ is the pixel value at position $ i \cdot N_k + j $ in the zigzag sequence of $ M_k $. *(Note: Indexing assumes 1-based row/column indices and 1-based zigzag sequence indexing.)*
API Response (JSON)
{
  "problem": {
    "name": "K. Jpeg",
    "description": {
      "content": "In computing, JPEG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography . The degree of compression can be adjusted, allowin",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10094K"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "In computing, JPEG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography . The degree of compression can be adjusted, allowin...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ N_k \\in \\mathbb{Z} $ denote the side length of the square matrix.  \n- ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments