codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1088C.md (1782B)


      1 Source: https://codeforces.com/problemset/problem/1088/C
      2 
      3 C. Ehab and a 2-operation task
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You're given an array $a$ of length $n$. You can perform the following operations on it:
     22 
     23 * choose an index $i$ $(1 \le i \le n)$, an integer $x$ $(0 \le x \le 10^6)$, and replace $a_j$ with $a_j+x$ for all $(1 \le j \le i)$, which means add $x$ to all the elements in the prefix ending at $i$.
     24 * choose an index $i$ $(1 \le i \le n)$, an integer $x$ $(1 \le x \le 10^6)$, and replace $a_j$ with $a_j \% x$ for all $(1 \le j \le i)$, which means replace every element in the prefix ending at $i$ with the remainder after dividing it by $x$.
     25 
     26 Can you make the array strictly increasing in no more than $n+1$ operations?
     27 
     28 Input
     29 
     30 The first line contains an integer $n$ $(1 \le n \le 2000)$, the number of elements in the array $a$.
     31 
     32 The second line contains $n$ space-separated integers $a_1$, $a_2$, $\dots$, $a_n$ $(0 \le a_i \le 10^5)$, the elements of the array $a$.
     33 
     34 Output
     35 
     36 On the first line, print the number of operations you wish to perform. On the next lines, you should print the operations.
     37 
     38 To print an adding operation, use the format "$1$ $i$ $x$"; to print a modding operation, use the format "$2$ $i$ $x$". If $i$ or $x$ don't satisfy the limitations above, or you use more than $n+1$ operations, you'll get wrong answer verdict.
     39 
     40 Examples
     41 
     42 Input
     43 
     44 ```
     45 3  
     46 1 2 3
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 0
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 3  
     59 7 6 3
     60 ```
     61 
     62 Output
     63 
     64 ```
     65 2  
     66 1 1 1  
     67 2 2 4
     68 ```
     69 
     70 Note
     71 
     72 In the first sample, the array is already increasing so we don't need any operations.
     73 
     74 In the second sample:
     75 
     76 In the first step: the array becomes $[8,6,3]$.
     77 
     78 In the second step: the array becomes $[0,2,3]$.