prob_desc_description stringlengths 63 3.8k | prob_desc_output_spec stringlengths 17 1.47k ⌀ | lang_cluster stringclasses 2
values | src_uid stringlengths 32 32 | code_uid stringlengths 32 32 | lang stringclasses 7
values | prob_desc_output_to stringclasses 3
values | prob_desc_memory_limit stringclasses 19
values | file_name stringclasses 111
values | tags listlengths 0 11 | prob_desc_created_at stringlengths 10 10 | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_notes stringlengths 4 3k ⌀ | exec_outcome stringclasses 1
value | difficulty int64 -1 3.5k ⌀ | prob_desc_input_from stringclasses 3
values | prob_desc_time_limit stringclasses 27
values | prob_desc_input_spec stringlengths 28 2.42k ⌀ | prob_desc_sample_outputs stringlengths 2 796 | source_code stringlengths 42 65.5k | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 7a4420ee192c433c5223b4e28af6ac44 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
#include<string.h>
int ans[305][305] = {};
int main()
{
int n;
scanf("%d", &n);
int tt=n*n;
for (int j = 0; j < n; j++)
{
for (int i = 0; i < n; i++)
{
ans[i][j] = tt;
tt--;
}
j++;
for (int i = n-1; i >= 0; i--)
{
ans[i][j] = tt;
tt--;
}
}
for (int i = 0; i < n; i+... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 4ada43ae5b1c95f653863034585e77b1 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
int main(int arg, char** argv){
int n;
scanf("%d", &n);
int ans[n][n];
int dir = -1;
int i = 0;
int place = 1;
for(int j = 0; j < n; j++){
for(int k = 0; k < n; k++){
ans[i][j] = place;
place++;
if(dir == -1 && i < n-1)
i++;
if(dir == 1 && i > 0)
i--;
}
dir *= -1;
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | fc2416a4669a8463965f4a92159924e8 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
long int n;
scanf("%ld",&n);
for(int i=0;i<n;i++)
{
for(int j=0;j<(n+1)/2;j++)
{
printf("%ld",n*n-i-n*j);
printf(" ");
}
for(int j=0;j<n/2;j++)
{
printf("%ld",1+n*j+i);
printf(" ");
}
printf("\n");
}
return 0;
}
| |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 48763415efab423f96aecd37a3317534 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
int main()
{
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; ++i)
{
for (j = 0; j < n; ++j)
printf("%d ", n * j + ((j % 2 == 0) ? i : n - 1 - i) + 1);
printf("\n");
}
return 0;
} | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 9acf8c6f616d10cdc4e1d9ffbf500f7b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
int main()
{
int a, b;
int n;
scanf("%d", &n);
for (a = 1; a <= n; a++)
{
printf("%d", a);
for (b = 1; b < n; b++)
{
if (b & 1)
{
printf(" %d", n + 1 - a + n * b);
}
else
{
printf(" %d", a + n * b);
}
}
printf("\n");
}
return 0;
} | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | dfe39d6fa5111bc106e8b76fead08dd4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n, i, j;
scanf("%d", &n);
for(i = 0; i < n; i++){
printf("%d ", i+1);
for(j = 0; j < n-1; j += 2){
printf("%d ", n*(2+j) - i);
if(j < n-2)
printf("%d ", n*(3+j) - (n-i-1));
}
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 5d474aca794f8bd6c9a0443e2c0beb18 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define pr 0.0000001
typedef long long ll;
long long max(long long a, long long b);
long long min(long long a, long long b);
int comparetor (const void * a, const void * b);//for qsort in ascending order
unsigned long long greatestpowerof2less... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 86047e547c9848e01e7df10962b3d70a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
int n,flag=0;
scanf("%d",&n);
int diff=2*n-1;
for(int r=1;r<n+1;r++)
{
int p=r;
flag=0;
printf("%d ",p);
for(int x=0;x<n-1;x++)
{
if(flag==0)
{
p=p+diff;
flag=1;
}
else
{
p=p+2*n-diff;
flag=0;
}
printf("%d ",p);
}
printf("\n");
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 2811aceadfa11c11631e1ceb8af16faf | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
#include <stdlib.h>
#define N 300
// int cmpfunc (const void * a, const void * b) {
// return ( *(int*)a - *(int*)b );
// }
// qsort(values, 5, sizeof(int), cmpfunc);
int main() {
int n, i, j;
scanf("%d", &n);
int A[N][N];
j = -1;
while (++j < n){
if (j%2 == 0){... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 3ab0cc53e3f9a24409eb89ebb7a6634a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n, i, j;
scanf("%d", &n);
for(i = 0; i < n; i++){
printf("%d ", i+1);
for(j = 0; j < n-1; j += 2){
printf("%d ", n*(2+j) - i);
if(j < n-2)
printf("%d ", n*(3+j) - (n-i-1));
}
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 9559a3474d2c9f9dbe0a5a73f36165cd | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
for(int j=0;j<n;j++){
if(j%2==1) printf("%d ",n*j+i);
else{
printf("%d ",n*(j+1)-i+1);
}
}
printf("\n");
}
}
| |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | de87930169b35408773b9180c07e5378 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | n;
id(i, j) { return (i - 1) * n + j; }
main(i, j) {
scanf("%d", &n);
for (i = 1; i <= n / 2; i++) {
for (j = 1; j <= n; j++)
printf("%d%c", id(j, j % 2 ? i : n - i + 1), " \n"[j == n]);
for (j = 1; j <= n; j++)
printf("%d%c", id(j, j % 2 ? n - i + 1 : i), " \n"[j == n]);
}
if (n % 2)
for (j = 1; j <= n... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 6e27f954f964aef45fb2c6f3c9779888 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | /* practice with Dukkha */
#include <stdio.h>
int main() {
int n, k, i, j;
scanf("%d", &n);
k = n / 2;
for (i = 0; i < n; i++) {
for (j = i * k; j < i * k + k; j++)
printf("%d ", j + 1);
if (n % 2 == 1)
printf("%d ", k * n + i + 1);
for (j = i * k; j < i * k + k; j++)
printf("%d ", n * n - j);
pr... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 25f4ebc89a9d6dcea015bd642228b283 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
int m;
int x=1;
int n;
scanf("%d",&n);
int s=n*n;
int t=s;
int a[300000];
int i,j;
if(n%2==0)
{
for(i=1,j=1;i<=s;i++,j++)
{
if(n/j>=2)
a[i]=x++;
else
a[i]=t--;
if(j==n)
j=0;
}
}
else
{
m=(n/2);
m=m*n+1;
for(i=1,j=1;i<=s;i++,j++)
{
if(n/... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 847b65e797002868dd19fafb558b93ca | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int WTF[302][302];
int main(){
int n;scanf("%d",&n);
for(int j=0;j<n;j++){
if(j%2==0){
for(int i=0;i<n;i++)WTF[i][j]=j*n+i;
}
else{
for(int i=0;i<n;i++)WTF[n-i-1][j]=j*n+i;
}
}
for(int i=0;i<n;i++){for(int j=0;j<n;j++)printf("%d ",WTF[i][j]+1);printf("\n");}
return 0;
}
| |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | c74a88076396fd2ade39707232c6a4e5 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
#ifndef ONLINE_JUDGE
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
#endif
int n, i, s, x, y, c=0;
scanf("%d", &n);
x=(n*2)-1;
y=1;
for(i=1; i<=n; i++)
{
s=i;
c=0;
while(s<=(n*n))
{
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 8e967662c46e8fafb3877ab78ae3ed81 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
typedef long long int ll;
int main()
{
ll n;
scanf("%lld", &n);
ll arr[n][n];
int i = 1;
int j;
while (i <= n)
{
j = 1;
while (j <= n)
{
if (j % 2 == 0)
{
arr[i - 1][j - 1] = ((j - 1) * n + i);
}... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 31769ab7e99551e2ad70682177fb026b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
int n, i, j;
scanf("%d", &n);
for(i=1; i<=n; i++)
{
for(j=0; j<n; j++)
{
if(j&1)
{
printf("%d ", n*(j+1)-i+1);
}
else
{
printf("%d ", n*j + i);
}
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | f6e3c9a88d21134196ccad76aee58b1a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
#include<string.h>
#define int long long
signed main()
{
int n;
scanf("%lld",&n);
int k=n*n;
int arr[n+1][n+1];
int num=1;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
arr[i][j]=num;
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 16fbeeac879899d7efed46319459491f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int a,b,c,i,j,m,n,ans,l,g1=0,g=0,h;
scanf("%d",&n);
for(i=1; i<=n; i++)
{
for(j=0;j<n;j++)
{
if(j%2==0)
{
l=(n*j)+i;
printf("%d ",l);
}
else
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 7c0727a8b2fbb96d400a655e6a2c246a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int square = n*n;
int arr[n][n];
for(int i=0; i<n; i++)
{
if(i%2 == 0)
{
for(int j=0; j<n; j++)
{
arr[i][j] = square;
square--;
}
}
else
{
for(int j=n-1; j>=0; j--)
{
arr[i][j] = square;
square--;
}
}
}
f... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 243351c56ae3e38aacc92c30bbcc3c7f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
int main(void) {
// your code goes here
int n;
scanf("%d",&n);
int arr[n][n];
int k=1;
int i=0;
int c=0;
int flag=1;
while(i<n && c<n)
{
if(flag==1)
{
//printf("%d",k);
arr[i][c]=k;
i++;
}
else
{
//printf("%d",k);
arr[i][c]=k;
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 13f0a217e88af94cf4b52700cfc565b1 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
int n,i,j,x=0,ara[400][400],z=1;
scanf("%d",&n);
while(1){
if(x==n){
break;
}
if(x%2==0){
for(i=0;i<n;i++){
ara[i][x]=z;
z++;
}
x++;
}
else{
for(... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 5846a4da8644ba2c8b6344f3d31be4cb | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
#include<stdlib.h>
void main()
{
int i,n,mark,check,pos;
scanf("%d",&n);
int arr[n][n];
mark = 0;
check = 0;
pos = 0;
i = n*n;
while(i>0)
{
arr[mark][pos] = i;
i--;
if(i%n==0)
{
pos++;
if(check == 0)
{
check = 1;
mark++;
}
else
{
check = 0;
mark--;
... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | d67b22851fcf3d7ae85108f2e8778499 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int group[302][302], ans[302][302], len[302];
int main(){
int n, i, j;
scanf("%d", &n);
for(i = 0;i < n;i++){
for(j = 0;j < n/2;j++)group[j][i] = i;
for(;j < n;j++)group[j][n - 1 - i] = i;
}
for(i = 0;i < n;i++)for(j = 0;j < n;j++){
int x = group[i][j];
ans[x][len... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 2c1cc2ce5a02c2cc2a14f52337fe79a1 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
int main() {
int n,k,i,j,p[300][300];
scanf("%d", &n);
k=1;
for(i=0;i<n;i++) {
for(j=0;j<n;j++,k++) {
p[(i%2==0)?j:(n-1-j)][i]=k;
}
}
for(i=0;i<n;i++) {
for(j=0;j<n;j++) printf("%d ", p[i][j]);
printf("\n");
}
return 0;
}
| |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 2c0062587addd067ee4cebf6d9e1eeb7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int ar[n][n],a=1;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(i%2==0)
ar[i][j]=a++;
else
ar[i][n-1-j]=a++;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
printf("%d ",ar[j][i]);
prin... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | c8c3116515526ac91a9b94117c4e0895 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
long long int n,temp;
scanf("%lld",&n);
long long int a[n][n];
temp=n*n;
long long int i=0,j=0;
while(temp>0)
{
i=0;
while(i<n)
{
a[i][j] = temp;
temp--;
//printf("%d %d\n",temp,a[i][j]);
i++;
}
j++;
i--;
if(j<n)
{
while(i>=0)
{
a[i][j]=tem... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | 13db70164ce3fe8cfbaef65689363eb0 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include<stdio.h>
int main()
{
int i,n,j,k=1;
int a[305][305] = {0};
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i%2==0)
{
a[i][j] = k;
k++;
}
else
{
a[i][n-1-j] = k;
k++;
}
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[j][i]);
}
print... | |
In order to do some research, $$$n^2$$$ labs are built on different heights of a mountain. Let's enumerate them with integers from $$$1$$$ to $$$n^2$$$, such that the lab with the number $$$1$$$ is at the lowest place, the lab with the number $$$2$$$ is at the second-lowest place, $$$\ldots$$$, the lab with the number ... | Output $$$n$$$ lines: In the $$$i$$$-th line print $$$n$$$ numbers, the numbers of labs of the $$$i$$$-th group, in any order you want. If there are multiple answers, that maximize the minimum number of the sum of units of water that can be transported from one group the another, you can print any. | C | d5ae278ad52a4ab55d732b27a91c2620 | eb3e80fdf8d723f7f9a40e35703302f0 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation",
"greedy"
] | 1571319300 | ["3"] | NoteIn the first test we can divide $$$9$$$ labs into groups $$$\{2, 8, 5\}, \{9, 3, 4\}, \{7, 6, 1\}$$$.From the first group to the second group we can transport $$$4$$$ units of water ($$$8 \rightarrow 3, 8 \rightarrow 4, 5 \rightarrow 3, 5 \rightarrow 4$$$).From the first group to the third group we can transport $$... | PASSED | 1,300 | standard input | 1 second | The only line contains one number $$$n$$$ ($$$2 \leq n \leq 300$$$). | ["2 8 5\n9 3 4\n7 6 1"] | #include <stdio.h>
int main() {
int n,i,j,c=1,a[301][301];
scanf("%d",&n);
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{if(i%2==0)
a[j][i]=c++;
else a[n-j-1][i]=c++;}}
for(i=0;i<n;i++){for(j=0;j<n;j++){printf("%d ",a[i][j]);}printf("\n");}
return 0;} | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | c689aca3a17ffb63b87994dfcbccf9a8 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include<stdio.h>
typedef long long int L;
L gcd(L a,L b)
{
if(b==0)
return a;
else
return gcd(b,a%b);
}
int main()
{
L a,b,g;
int n;
scanf("%I64d%I64d",&a,&b);
g=gcd(a,b);
scanf("%d",&n);
while(n--)
{
scanf("%I64d%I64d",&a,&b);
if(g<a)
printf("-1\n");... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | 2bf7820617a5e6d76d3fedee40e0ecad | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long PGCD(long a,long b){
if (a == b ){
return a ;
}else {
if ( a > b ){
return PGCD (a- b ,b);
}else {
return PGCD ( a , b-a );
}
}
}
int main() {
long long n,... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | 5dabf19ca86423f08ec47b5d0d1b284b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
int pgcd(int a, int b) {
while (b != 0) {
int t = a % b;
a = b;
b = t;
}
return a;
}
int main() {
int a, b,n,l,h,k=0;
int i, dn = 0, Tab[10000];
scanf("%d%d", &a, &b);
scanf("%d", &n);
int c = pgcd(a, b);
for (i = 1; i*i <= c; i++)
if (c % i == 0)
{
Tab[k++] = i... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | a5e71a0bce96765b2903351405f98fa1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include<stdio.h>
int gcd(int a, int b){
if(a==0) return b;
else return gcd(b%a, a);
}
int f(int h, int l, int p, int q){
int n, x;
//x = gcd(p, q);
//if(h<p) return -1;
if(l>q) return -1;
else if(l>p) return -1;
else if(h>p) h=p;
for(n=h; n>=l; ){
if(p%n==0 && q%n==0){
... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | 7bcb904f585b868229d9f6def82b5199 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
#include <stdlib.h>
int gcd(int a, int b)
{
if (a < b) return gcd(b, a);
if (a % b == 0) {
return b;
} else {
return gcd(b, a % b);
}
}
int cmp(const void *a, const void *b)
{
return *((int *)b) - *((int *)a);
}
int main()
{
int a, b, g, n, p = 0, i, j;
in... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | e6dfc8a4872bbd6750c3584af5d26e48 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
int d[50000];
int t[50000];
int calc(int g)
{
int i, j, m, n;
m = n = 0;
for (i = 1; i * i <= g; i ++)
{
if (g % i == 0)
{
d[m ++] = i;
if (g / i != i)
{
t[n ++] = g / i;
}
}
}
for (j = n... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | d51820568349a532456b96fd212ba697 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int main() {
int a, b, g, i, n, max;
scanf("%d%d%d", &a, &b, &n);
g = gcd(a, b);
while (n-- > 0) {
int low, high;
scanf("%d%d", &low, &high);
max = -1;
for (i = 1; i * i <= g; i++) {
if (g % i == 0 && i >= low && i <= hi... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | ea3eb09f0ba54883d3b0308322943910 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
int pgcd(int x, int y) {
while (y != 0) {
int t = x % y;
x = y;
y = t;
}
return x;
}
int main() {
int a, b,n,l,h,k=0;
int i, dn = 0, Tab[10000];
scanf("%d%d", &a, &b);
scanf("%d", &n);
int c = pgcd(a, b);
for (i = 1; i*i <= c; i++)
if (c % i == 0)
{
Tab[k++] = i... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | 63e936b2630aba7d9ab9778d37076dec | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <strings.h>
int *divisors;
long mgcd(long a, long b);
long gcd (long a, long b);
int compare(const void *a, const void *b);
long search(long low, long high, long max);
int main (int argc, char *argv[]) {
long a, b;
long low, high;
long n, i, max;
... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | 25aa02c95c44c925241fecd2e5e3bc3d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include<stdio.h>
#include<math.h>
#define MAX 100000
main()
{
int a,b,i,temp;
scanf("%d%d",&a,&b);
int arr[MAX],act_arr[MAX],no=0,no_of_elem=0;if(a>b){temp=a;a=b;b=temp;}
for(i=1;i<=(int)floor(sqrt(a));i++){if(a%i==0)arr[no_of_elem++]=i;}
for(i=no_of_elem-1;i>=0;i--){if(arr[i]!=a/arr[i])arr[no_of_elem++]=a/arr[i];}
fo... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | e10c122c8e25c993fe7b4d80ac2cdd6a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int main()
{
int i ,j,ans,a,b,l,h,n,temp;
scanf("%d%d%d",&a,&b,&n);
temp=gcd(a,b);
while(n--)
{ans=-1;
scanf("%d%d",&l,&h);
for(i=1;i*i<=temp;i++)
{
if(temp%i==0 && (i>=l && i<=h) && temp/i>ans)
ans=i;
if(temp%i==0 && (temp/... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | b763d9bdfa73030a06ae3a7129bcf4c4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include<stdio.h>
int gcd(int a, int b){
if(a==0) return b;
else return gcd(b%a, a);
}
int f(int h, int l, int p, int q){
int n, x;
//x = gcd(p, q);
//if(h<p) return -1;
if(l>q) return -1;
else if(l>p) return -1;
else if(h>p) h=p;
for(n=h; n>=l; ){
if(p%n==0 && q%n==0){
... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | eb68d7b60ff5b8a56eb0452d954555c1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
int a,b,high,low,k=0,arr[100001],t[1010];
int gcd(int x,int y){
if(y==0) return x;
else return gcd(y,x%y);
}
int bsearch(int left,int right,int g){
int mid,c=-1,r=k,l=0;
while(r>=l){
mid=(r+l)/2;
if(arr[mid]<=right&&arr[mid]>=left){
l=mid+1;
c=arr[mid... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | 4aa9c723d7ddcdfa01914b23f31bf247 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
int gcd(int a, int b) {
while (b != 0) {
int t = a % b;
a = b;
b = t;
}
return a;
}
int main() {
int a, b; scanf("%d%d", &a, &b);
int c = gcd(a, b);
int i, dn = 0, d[10000];
for (i = 1; i*i <= c; i++)
if (c % i == 0) {
d[dn++] = i;
d[dn++] = c/i;
}
int n; scanf("%d", &n)... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | 6cdfc876620c7d1dfb5c1778a6e569c3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int gcd(int a,int b)
{
if(a==0)
return b;
gcd(b%a,a);
}
int max(int a,int b)
{
if(a>b)
return a;
return b;
}
int main()
{
int x,b,n,a[100005],i=0,j=0;
scanf("%d%d%d",&x,&b,&n);
int p=gcd(x,b);
int q=sqrt(p);
for(i=1;i<=q+2;i++)... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | 3efdb864c6b4a65677d9a94829ed0f3a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include<stdio.h>
#include<stdlib.h>
int gcd(int a,int b) {
return b?gcd(b,a%b):a;
}
int p[64],r[64];
int cnt,n,cnt1;
int f[1000000];
void factor(int m) {
int i;
for(i=2;i*i<=m;i++) if (m%i==0) {
p[cnt]=i,r[cnt]=0;
for(;m%i==0;m/=i) r[cnt]++;
cnt++;
}
if (m>1) p[cnt]=m,r[cnt]=1,cnt++;
}
void dfs(int t,in... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | e19c6987904aed37e857561c9bdc3e42 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include <stdio.h>
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int main()
{
int i ,j,ans,a,b,l,h,n,temp;
scanf("%d%d%d",&a,&b,&n);
temp=gcd(a,b);
while(n--)
{ans=-1;
scanf("%d%d",&l,&h);
for(i=1;i*i<=temp;i++)
{
if(temp%i==0 && (i>=l && i<=h) && temp/i>ans)
ans=i;
if(temp%i==0 && (temp/... | |
Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you... | Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query. | C | 6551be8f4000da2288bf835169662aa2 | b73560841f31dd74fff1775311126231 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"number theory"
] | 1302706800 | ["9 27\n3\n1 5\n10 11\n9 11"] | null | PASSED | 1,600 | standard input | 2 seconds | The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109). | ["3\n-1\n9"] | #include "stdio.h"
int gcd(int a, int b)
{
return (b > 0) ? gcd(b, a % b) : a;
}
int divs[100000];
int divsc;
int main()
{
int a, b;
scanf("%d %d", &a, &b);
int gcdbuf = gcd(a, b);
int i, j;
divsc = 0;
for(i = 1; i * i <= gcdbuf; i++)
{
if(gcdbuf % i == 0)
{
... | |
There are k sensors located in the rectangular room of size n × m meters. The i-th sensor is located at point (xi, yi). All sensors are located at distinct points strictly inside the rectangle. Opposite corners of the room are located at points (0, 0) and (n, m). Walls of the room are parallel to coordinate axes.At the... | Print k integers. The i-th of them should be equal to the number of seconds when the ray first passes through the point where the i-th sensor is located, or - 1 if this will never happen. | C | 27a521d4d59066e50e870e7934d4b190 | b9e48ef8257ebdb962bc663976ac05fe | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"number theory",
"math",
"implementation",
"sortings"
] | 1475928900 | ["3 3 4\n1 1\n1 2\n2 1\n2 2", "3 4 6\n1 1\n2 1\n1 2\n2 2\n1 3\n2 3", "7 4 5\n1 3\n2 2\n5 1\n5 3\n4 3"] | NoteIn the first sample, the ray will consequently pass through the points (0, 0), (1, 1), (2, 2), (3, 3). Thus, it will stop at the point (3, 3) after 3 seconds. In the second sample, the ray will consequently pass through the following points: (0, 0), (1, 1), (2, 2), (3, 3), (2, 4), (1, 3), (0, 2), (1, 1), (2, 0), (... | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains three integers n, m and k (2 ≤ n, m ≤ 100 000, 1 ≤ k ≤ 100 000) — lengths of the room's walls and the number of sensors. Each of the following k lines contains two integers xi and yi (1 ≤ xi ≤ n - 1, 1 ≤ yi ≤ m - 1) — coordinates of the sensors. It's guaranteed that no two sensors a... | ["1\n-1\n-1\n2", "1\n-1\n-1\n2\n5\n-1", "13\n2\n9\n5\n-1"] | #include <stdio.h>
long long xy[2];
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int xygcd(int a, int b) {
if (b == 0) {
xy[0] = 1;
xy[1] = 0;
return a;
} else {
int g = xygcd(b, a % b);
long t = xy[0] - a / b * xy[1];
xy[0] = xy[1];
xy[1] = t;
return g;
}
}
int main() {
int n... | |
There are k sensors located in the rectangular room of size n × m meters. The i-th sensor is located at point (xi, yi). All sensors are located at distinct points strictly inside the rectangle. Opposite corners of the room are located at points (0, 0) and (n, m). Walls of the room are parallel to coordinate axes.At the... | Print k integers. The i-th of them should be equal to the number of seconds when the ray first passes through the point where the i-th sensor is located, or - 1 if this will never happen. | C | 27a521d4d59066e50e870e7934d4b190 | e5c866bde76b5aad52cfc57e31459844 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"number theory",
"math",
"implementation",
"sortings"
] | 1475928900 | ["3 3 4\n1 1\n1 2\n2 1\n2 2", "3 4 6\n1 1\n2 1\n1 2\n2 2\n1 3\n2 3", "7 4 5\n1 3\n2 2\n5 1\n5 3\n4 3"] | NoteIn the first sample, the ray will consequently pass through the points (0, 0), (1, 1), (2, 2), (3, 3). Thus, it will stop at the point (3, 3) after 3 seconds. In the second sample, the ray will consequently pass through the following points: (0, 0), (1, 1), (2, 2), (3, 3), (2, 4), (1, 3), (0, 2), (1, 1), (2, 0), (... | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains three integers n, m and k (2 ≤ n, m ≤ 100 000, 1 ≤ k ≤ 100 000) — lengths of the room's walls and the number of sensors. Each of the following k lines contains two integers xi and yi (1 ≤ xi ≤ n - 1, 1 ≤ yi ≤ m - 1) — coordinates of the sensors. It's guaranteed that no two sensors a... | ["1\n-1\n-1\n2", "1\n-1\n-1\n2\n5\n-1", "13\n2\n9\n5\n-1"] | #include<stdio.h>
#include<stdlib.h>
typedef long long unsigned llu;
typedef unsigned u;
u G(u a,u b){return b?G(b,a%b):a;}
u egcd(u a,u b)
{
u m=b,q,r,x=0,lx=1;
while(b)
{
r=x;x=lx-(q=a/b)*x;lx=r;
r=b;b=a-b*q;a=r;
}
return(lx>m)?lx+m:lx;
}
llu F(u a,u b,u x,u y)
{
u g,j,ja,k;llu p,r;
g=G(x,y);
ja=j=G(g,G(a... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 7feb0d8fed10314b5c61b16750d9fcf5 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include <stdio.h>
int main(){
int n ,i,j,k,m,p=0;
scanf("%d", &n);
//n = 9;
n = n+ 1 ;
for(i=0;i < n ;i++){
for(j= n-i-1;j>0;j--){
printf(" ");
}
for(k=0;k<=i;k++){
if(k==0 && p==0){
printf("0");
p++ ;... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | bd22e83801e23138e2a5329fda2929e7 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main()
{
int n,a[105][105],z=0,z1,z2=2;
scanf("%d",&n);
int tong=(n*2+1+n*2)/2+(n*2+1)%2;
for (int i=0;i<n*2+1;i++)
{
if (i<=tong/2)
{
for (int j=1;j<=tong+i*2;j++)
{
if (j%2!=0)
{
if (t... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | ff217eb71779d91629d21f303513586e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main()
{
int n,i,space,j,l=0;
scanf("%d",&n);
space=n*2;
for(i=1;i<=n+1;i++)
{
for(j=1;j<=space;j++)
{
printf(" ");
}
space=space-2;
for(j=1;j<=i;j++)
{
printf("%d",l);
if(j<i)
{
... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 75de48857ddc35f6893ddd8d43231d03 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main() {
int n;
int i, j, ki, kj, ind;
scanf("%d", &n);
for(ki = 1, i = 1; i <= 2*n+1; i++) {
ind = 0;
for(kj = 1, j = 1; j <= 2*n+1; j++) {
if(ki + kj - n - 2 == 0 && (ind == 1 || i == 1 || i == 2*n+1))
printf("%d", ki + kj - n- 2);
else if(ki + kj -... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 87b886bf70800436e79ac50285f6c4b3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main(){
int i,j,k,n,l,star,s,d,q,w,e,r,p,t;
int count=0;
scanf("%d",&t);
n=2*t+1;
p=n;
star=(n-1)/2;
s=star;
for(i=0;i<=s;i++){
d=2*i+1;
for(k=0;k<star;k++){
printf(" ");
}
for(j=0;j<d-1;j++){
... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 23e54e090f90b1ae4b97611c51654d08 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
#include<math.h>
int main()
{
int n;
int i,j,k,z,y;
scanf("%d",&n);
//upper part
for(i=1;i<=(n+1);i++)
{
//space of the left part
for(j=1;j<=(n+1-i);j++)
{
printf(" ");
... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | c189a7a99b0b2417807d33b623939489 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main()
{
int i,j,k,n,m;
scanf("%d",&n);
for(i=0;i<n+1;i++)
{
for(j=... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 19687c628bbdfe469cdd747c4effb24f | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include <stdio.h>
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=n;j>=i;j--)
{
printf(" ");
}
printf("0");
for(j=1;j<i;j++)
{
printf(" %d",j);
}
if(i>2)
{
for(j=(i-2);j>=1;j--)
{
printf(" %d",j);
}
}
if(i>1)
{
printf(" 0");
}
printf("\n");
}
for(i=(n+1);i>=1;i--)
{
for(j=i;j<(n+1);j++)
{
... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 9547b88c8d5e425846fa8c09d6243fed | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include <stdio.h>
int i,j,n;
int main()
{
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=n;j>=i+1;j--)
printf(" ");
for(j=0;j<=i;j++)
{
printf("%d",j);
if(j!=i)
printf(" ");
}
for(j=i-1;j>=0;j--)
... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 8efb8ccf754d770f72fef86657db3c90 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main ()
{
int n,c,i,j,d,x;
char b[25];
scanf("%d",&n);
for(i=0;i<n*2+2;i++)b[i]=32;
c=n+1;
for(i=0;i<n+1;i++)
{
d=48+i;
b[c]=d;
for(j=1;j<=i;j++)
{
b[c+j]=d-1,b[c-j]=d-1;
d=d-1;
}
x=j;
for(j... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | e486f58590169f61fa3f9d2ea9011ddd | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include <stdio.h>
int main()
{
int n,i,j,p;
scanf("%d",&n);
for (j=0;j<=n-1;j++){
for (i=1;i<(n-j)*2;i++){
printf(" ");
}
for (i=0;i<=j;i++){
printf(" %d",i);
}
p=j-1;
//printf("%d ",p);
while(p>=0){
printf(" %d",p... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | ecce7f17ee455420fd207e4413293e6b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main()
{
int i,j,n,k,l;
scanf("%d",&n);
for(i=1;i<=n+1;i++){
for(j=n+1-i;j>=1;j--){
printf(" ");}
for(k=0;k<=i-1;k++){
if(i==1)
printf("%d",k);
else
printf("%d ",k);
}
for(l=2*i-1-i;l>0;l--){
if(l!=1){printf("%d ",l-1);}
... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | d4e93f5ccaa59a6b1d075b0837ae8a09 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j,n,k,l;
scanf("%d",&n);
for (i=0; i<n; i++)
{
for (j=n-i; j>0; j--)
printf(" ");
for(k=0; k<=i; k++)
{
if(i==0)
printf("%d",k);
else
printf("%d ",k);... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | c50a08afa3dd0f7fadbc6fb4295311fc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main()
{
int a,i,j,k;
scanf("%d",&a);
for(i=0;i<=a;i++)
{
for(j=0;j<a-i;j++)
printf(" ");
for(j=0;j<=i;j++)
{
if(i==0)
printf("%d",j);
else
printf("%d ",j);
}
j--;
for(;j>1;... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 9bf0d5f31d4aa7202815ff09fb27e182 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include <stdio.h>
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(" ");
}
for(j=0;j<i;j++)
{
printf("%d ", j);
}
for(j=i;j>=0;j--)
{
if(j==0){
... | |
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handk... | Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line. | C | 7896740b6f35010af751d3261b5ef718 | 6751896ebfc285a39e4d019cbc2e86ef | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1317999600 | ["2", "3"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains the single integer n (2 ≤ n ≤ 9). | ["0\n 0 1 0\n0 1 2 1 0\n 0 1 0\n 0", "0\n 0 1 0\n 0 1 2 1 0\n0 1 2 3 2 1 0\n 0 1 2 1 0\n 0 1 0\n 0"] | #include<stdio.h>
int main()
{
int i,j,k,l,n,p;
scanf("%d",&n);
for(j=0;j<=n;j++)
{
for(l=j;l<n;l++)
{printf(" ");
printf(" ");
}
for(p=0;p<j;p++)
printf("%d ",p);
printf("%d",j);
if(j!=0)
... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | c0d146cee6132244462a1a353f7a5a12 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include<stdio.h>
#include<string.h>
#define MAX 100001
int temp[MAX];
void mergesort(int Array[],int first,int last)
{
if(first>=last) return;
int middle=(first+last)/2;
mergesort(Array,first,middle);
mergesort(Array,middle+1,last);
int i,j,k;
for(i=first,j=first,k=middle+1;i<=last;i++)
{
... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 77c17055083fb685df7a2b9ca3d8bcea | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | //practice with dukkha
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
void merge(int arr[], int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
int L[n1], R[n2];
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 726e74a109d215f9503e333739eb6cf6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include <stdio.h>
#include <stdlib.h>
#define MAX_N 10000000
int n, m, k;
int a[MAX_N];
int b[MAX_N];
int min(int a, int b) {
return (a < b) ? a : b;
}
int cmp(const void* x, const void* y) {
return *(int*)y - *(int*)x;
}
int main() {
scanf("%d%d%d", &n, &m, &k);
for (int i = 0; i < n; ++i)
scanf("%d", ... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | f0da724e7886ef68d88884b7f7112f86 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include<stdio.h>
void merge(int arr[], int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
int L[n1], R[n2];
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
R[j] = arr[m + 1+ j];
i = 0;
j = 0;
k = l;
while (i... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | f69004b9cd353f86af8867244220b2d5 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include <stdio.h>
#include<stdlib.h>
int com(const void *a,const void *b){
int c=*(int *)a;
int d=*(int *)b;
if(c<d)
return -1;
if(c==d)
return 0;
return 1;
}
int main(void){
int n,m,k;
int a[100000];
int diff[100000];
int i;
int result;
scanf("%d %d %d",&n,&m,&k);
result=n;
for(i=0;i<n... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 4fb0e5d94fa915c4c5cf5ac295cea2f6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int i, n, m, x, b, k, t[1000000], w, p, a;
int war(const void*c, const void*d)
{
return(*(int*)d-*(int*)c);
}
char s[400000];
int main()
{
scanf("%d%d%d", &n, &m, &k);
w=m;
scanf("%d", &a);
w=w-a+1;
k--;
for(i... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 47a5c7ad849b8410a8c54a432d68752b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
typedef int64_t i64;
typedef int32_t i32;
static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){i... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 454ca0ae442488af708dab8d58fec2f4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include <stdio.h>
#include <stdlib.h>
int comp(const void * elem1, const void * elem2)
{
int f = *((int*)elem1);
int s = *((int*)elem2);
if (f > s) return 1;
if (f < s) return -1;
return 0;
}
int main() {
int a, b, c, swap;
scanf("%d %d %d", &a, &b, &c);
int d[a];
for (size_t i = 0; i < a;... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 74c1754888c6a27a23e61e598106417a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include <stdio.h>
#include <stdlib.h>
int t[1000000];
int cmp(const void*a, const void*b)
{
return(*(int*)b-*(int*)a);
}
int main(void)
{
int n,m,x,b,k,w,p,a;
scanf("%d%d%d",&n,&m,&k);
w = m;
scanf("%d", &a);
w = w - a + 1;
for(int i=0;i<n-1;i++){
p = a;
scanf("%d",&a);
... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 0db2cd81f5a4ce788a2aa5e6e2df413f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include<stdio.h>
int compare(const void *a, const void *b)
{
return *(int *)b - *(int *)a;
}
int main(){
int n, m, k, first, last, prev, res;
scanf("%d %d %d", &n, &m, &k);
int *w = (int *)malloc(sizeof(int) * (n - 1));
scanf("%d", &first);
prev = last = first;
for(int i = 0;i < n - 1; ++i)... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 07bafbc416d3089425a3862988975e61 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h> //for bool
#include <stdlib.h> // abs,labs,llabs
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld; //%Lf
void swap(int* a, int* b){
int temp = *a;
*a = *b;
*b = temp;
}
int partition(int a... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 168e2babdad33a1b249a657d60c82dbf | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | //Codeforces 1110B -- Tape
#include <stdio.h>
#include <stdlib.h>
int cpr(const void * n1, const void * n2){
int u= *((int*)n1);
int v = *((int*)n2);
if (u > v) return 1;
if (u < v) return -1;
return 0;
}
int main(){
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int ar[a];
for(size_t i = 0; i... | |
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired.You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments. ... | Print the minimum total length of the pieces. | C | 6b2b56a423c247d42493d01e06e4b1d2 | 5720de8d0b3e2403a41ff68372414bbe | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1549546500 | ["4 100 2\n20 30 75 80", "5 100 3\n1 2 4 60 87"] | NoteIn the first example, you can use a piece of length $$$11$$$ to cover the broken segments $$$20$$$ and $$$30$$$, and another piece of length $$$6$$$ to cover $$$75$$$ and $$$80$$$, for a total length of $$$17$$$.In the second example, you can use a piece of length $$$4$$$ to cover broken segments $$$1$$$, $$$2$$$ a... | PASSED | 1,400 | standard input | 1 second | The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$n \le m \le 10^9$$$, $$$1 \le k \le n$$$) — the number of broken segments, the length of the stick and the maximum number of pieces you can use. The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le... | ["17", "6"] | #include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b)
{
int l = *(int*)(a);
int r = *(int*)(b);
if (r > l) {
return -1;
}
else if (r < l) {
return 1;
}
else {
return 0;
}
}
int main() {
int n, m, k;
scanf("%d %d %d", &n, &m... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 7691f42e8c9579e5f1448f85bcbda0bc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int height[200001],width[200001],prefix[200001],postfix[200001];
int i,width_total=0;
for(i=0;i<n;i++)
{
scanf("%d%d",&width[i],&height[i]);
width_total+=width[i];
}
int max=height[0];
prefix[0]=max;
for(i=1;i<n;i++)
{
if(height[i]>max)
{
... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | a72101dcfd5d68049339445f455d40e6 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include<stdio.h>
#include<stdlib.h>
typedef struct node
{
long long int width;
long long int height;
long long int index;
}node;
node *a;
long long int count=0;
void insert(long long int w,long long int h,long long int in)
{
count++;
a[count].width=w;
a[count].height=h;
a[count].index=in;
long long int i=count... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | a964001dc3edf075460806c27fcac563 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include <stdio.h>
int main() {
int n,i,wSum=0,w[200000],hMax=0,hSec=0,iMax=0,h,pixels;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d",&w[i],&h);
if(h>=hMax){
hSec=hMax;
iMax=i;
hMax=h;
} else if(h>=hSec) {
hSec=h;
}
wSum+=w[i];
}
for(i=0;i<n;i++) {
pixels = (wSum-w[i])*((i==iMax)?... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 00041fbc37ace5553c3d7583a6a758cb | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include<stdio.h>
int m1=0,m2=0,xm1=0,xm2=0,n,w[200005]={0},sw=0,h[200005]={0},i;
int main()
{
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d",&w[i],&h[i]);
sw+=w[i];
if(h[i]>m1)
{
m2=m1;
xm2=xm1;
m1=h[i];
xm1=i;
}
else if(h[i]>m2)
{
m2=h[i];
xm2=i... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | e6a8b1a2cba73344a607b48d229f3aa6 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include<stdio.h>
#include<string.h>
int main ()
{
int i, n, Wsum = 0, W, H, maxh = 0, predmaxh = 0, c;
scanf("%d", &n);
int w[n], h[n];
for(i = 0; i < n; i++){
scanf("%d%d", &w[i], &h[i]);
Wsum += w[i];
if(predmaxh < h[i]){
predmaxh = h[i];
}
if(maxh ... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | cce5e03bd86c6c9fddf6c7a4ebcfd2da | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include "stdio.h"
struct Node {
unsigned int w;
unsigned int h;
};
unsigned int max(unsigned int x, unsigned int y) {
if (x > y) {
return x;
}
return y;
}
int main(){
int n,i;
scanf("%d ", &n);
struct Node *arr = malloc(sizeof(struct Node)*n);
struct Node *left = malloc(... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 71affb2db6e43beddddde1ec89c7f740 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include<stdio.h>
int main(){
long long int i,j,k,l,n,m,a[200000],c[200000],max1=0,max2=0;
long long int sum=0;
scanf("%lld",&n);
for(i=0;i<n;i++){
scanf("%lld%lld",&c[i],&a[i]);
if(a[i]>=max2){
max2=a[i];
if(a[i]>=max1){
max2=max1;
max1=a[i];
}
}
sum=sum+c[i];
}
for(i=0;i<n;i++){
if(a[... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | db568cac3b22a96932bbbb6a429c8c08 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include <stdio.h>
int main(void) {
long long a[200001],min1=-1,min2=-1,n,sum,b[200001],c[200001],i;
scanf("%lld",&n);
for(i=0;i<n;i++){
scanf("%lld %lld",&b[i],&c[i]);
sum+=b[i];
if(c[i]==min1){
min2 = min1;
}
if(c[i]>min1){
min2 = min1;
min1 = c[i];
} else ... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 0656cb6fce63f7ae43380ce6e4d5524c | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include <stdio.h>
/* NIIICE ONE */
int main(int argc, char *argv[]) {
int i, j;
long int n;
struct q{
int w;
int h;
};
long long int result;
int max = 0, max2 =0, maxPr=0;
long int sum = 0;
scanf("%li", &n);
struct q arr[n];
for (i = 0; i<n;i++) {
... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 81da829b9a1df2f6594042cb91a5f294 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include <stdio.h>
int main()
{
int ara1[200000];
int ara2[200000];
int n,a=0,b=0,c=0,h,w;
int i,j;
scanf("%d",&n);
for(i=0;i<n;i++) {
scanf("%d %d",&w,&h);
ara1[i]=w;
ara2[i]=h;
a+=w;
if(h>b) {
c=b;
b=h;
}
els... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 6bd258cb9d983997fd7b2ca84546b58f | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include <stdio.h>
int main()
{
int ara1[200000];
int ara2[200000];
int n,a=0,b=0,c=0,h,w;
int i,j;
scanf("%d",&n);
for(i=0;i<n;i++) {
scanf("%d %d",&w,&h);
ara1[i]=w;
ara2[i]=h;
a+=w;
if(h>b) {
c=b;
b=h;
}
els... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | dd2c74f3bf95a61f25ed87a25e3c0ddb | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include <stdio.h>
int main()
{
int N, i, SumW, H;
int W[200000];
int MaxH[2], MaxIdx;
scanf("%d", &N);
SumW = MaxH[0] = MaxH[1] = 0;
for(i = 0; i < N; ++i) {
scanf("%d %d", &W[i], &H);
SumW += W[i];
if(H > MaxH[0]) {
MaxH[1] = MaxH[0];
MaxH[0] = ... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 04cf8b28bd7ec71a2cf6e3b84c84e444 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include<stdio.h>
#define N 200000
int main() {
int n;
scanf("%d",&n);
int i;
int w[N];
int h[N];
int sum_w=0;
int max_h=0;
int max_times=0;
int second_max_h=0;
for(i=0;i<n;i++){
scanf("%d%d",&w[i],&h[i]);
sum_w+=w[i];
if(h[i]>max_h){
second_max_h=max_h;
max_h=h[i];
max_times=1;
}else if(h[i]... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 102d7e0c25b506c05d631c52c67fe590 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include <stdio.h>
int main(int argc, const char * argv[]) {
int n, i, all_w = 0, max_h = 0, max_h_index = 0, sec_max_h = 0;
scanf("%d", &n);
int w[n];
int h[n];
for(i = 0; i<n; i++){
scanf("%d", &w[i]);
scanf("%d", &h[i]);
}
for(i = 0; i<n; i++){
if(max_h<h[i... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 1fd04e3abc857e54fb6b8e5732cef7d4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include<stdio.h>
int main()
{
int n,i,j,x[200000],y[200000],w=0;
int max1=0,max2=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d",&x[i],&y[i]);
w+=x[i];
if(y[i] >= max2)
{
if(y[i] >= max1)
{
max2=max1;
max1=y[i];
}
else
max2=y[i];
}
}
for(i=1;i<=n;i++)
{
if(y[i]==max1)
... | |
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together. Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupies a rectangle of pixels: the i-th of them occupies the rectangle of w... | Print n space-separated numbers b1, b2, ..., bn, where bi — the total number of pixels on the minimum photo containing all friends expect for the i-th one. | C | e1abc81cea4395ba675cf6ca93261ae8 | 6960c908f444761401a999338283a109 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"implementation",
"*special",
"data structures"
] | 1425740400 | ["3\n1 10\n5 5\n10 1", "3\n2 1\n1 2\n2 1"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains integer n (2 ≤ n ≤ 200 000) — the number of friends. Then n lines follow: the i-th line contains information about the i-th friend. The line contains a pair of integers wi, hi (1 ≤ wi ≤ 10, 1 ≤ hi ≤ 1000) — the width and height in pixels of the corresponding rectangle. | ["75 110 60", "6 4 6"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n,i,j;
scanf("%d",&n);
long long int w[n],h[n],totW=0,max[]={-1,-1},max_index[2],temp,tempW;
for(i=0;i<n;i++){
scanf("%lld %lld",&w[i],&h[i]);
totW+=w[i];
if(h[i]>max[0]){max[1]=max[0];max_index[1]=max_index[0];max[0]=h[i];max_index[0]=i;... | |
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads.The President of Berland decided to make changes to the road syst... | Print a single integer — the minimum number of separated cities after the reform. | C | 1817fbdc61541c09fb8f48df31f5049a | 2fb03dee20b32a1936bdc41f0a1d4af1 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"graphs",
"dsu",
"data structures",
"dfs and similar"
] | 1459353900 | ["4 3\n2 1\n1 3\n4 3", "5 5\n2 1\n1 3\n2 3\n2 5\n4 3", "6 5\n1 2\n2 3\n4 5\n4 6\n5 6"] | NoteIn the first sample the following road orientation is allowed: , , .The second sample: , , , , .The third sample: , , , , . | PASSED | 1,600 | standard input | 1 second | The first line of the input contains two positive integers, n and m — the number of the cities and the number of roads in Berland (2 ≤ n ≤ 100 000, 1 ≤ m ≤ 100 000). Next m lines contain the descriptions of the roads: the i-th road is determined by two distinct integers xi, yi (1 ≤ xi, yi ≤ n, xi ≠ yi), where xi and y... | ["1", "0", "1"] | #include <stdio.h>
#include <stdlib.h>
//并查集是一种树型的数据结构,用于处理一些不相交集合(Disjoint Sets)
//的合并及查询问题.常常在使用中以森林来表示
int visit[100000];
int filiation[100000];//filiation意为父子关系,此数组用于存储两结点的上下级关系
int search_root_node(int random_node)//查找根结点;random_node任意结点
{
int root_node;//root_node用于储存最后找到的根结点
int intermediary=random_no... | |
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads.The President of Berland decided to make changes to the road syst... | Print a single integer — the minimum number of separated cities after the reform. | C | 1817fbdc61541c09fb8f48df31f5049a | 2c896b0c3b61851ecb46fb08f9c8f0fe | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"graphs",
"dsu",
"data structures",
"dfs and similar"
] | 1459353900 | ["4 3\n2 1\n1 3\n4 3", "5 5\n2 1\n1 3\n2 3\n2 5\n4 3", "6 5\n1 2\n2 3\n4 5\n4 6\n5 6"] | NoteIn the first sample the following road orientation is allowed: , , .The second sample: , , , , .The third sample: , , , , . | PASSED | 1,600 | standard input | 1 second | The first line of the input contains two positive integers, n and m — the number of the cities and the number of roads in Berland (2 ≤ n ≤ 100 000, 1 ≤ m ≤ 100 000). Next m lines contain the descriptions of the roads: the i-th road is determined by two distinct integers xi, yi (1 ≤ xi, yi ≤ n, xi ≠ yi), where xi and y... | ["1", "0", "1"] | /* practice with Dukkha */
#include <stdio.h>
#define N 100000
#define M 100000
int next[M * 2 + 1], jj[M * 2 + 1];
int link(int q, int j) {
static int _ = 1;
next[_] = q, jj[_] = j;
return _++;
}
int ao[N];
char visited[N];
int dfs(int p, int i) {
int l, j;
if (visited[i])
return 1;
visited[i] = 1;
for... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | f050cb217ac2128490f63d27da260e7b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
#define mod 1000000007
int main()
{
int h,w;
scanf("%d %d",&h,&w);
int r[1005],a[1005][1005]={0};
for(int i=0;i<1005;i++)
{
for(int j=0;j<1005;j++)
{
a[i][j]=0;
}
}
for(int i=0;i<h;i++)
{
scanf("%d",&r[i]);
}
int c[1005];
for(int i=0;i<w;i++)
{
scanf("%d",&c[i]);
}
int j,fl... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | d53f5e6309854c9796204c78f91c3641 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
#include<string.h>
int iMap[1005][1005];
//assume 0 for empty 1 for nonempty 2 for both
int iErr;
const int MOD=1e9+7;
long long mpow(long long b,int p){
long long res=1;
while(p){
if(p&1) res=(res*(long long)b)%MOD;
b=(b*b)%MOD;
p>>=1;
}
return res;
}
int main(int argc,char **argv)
{
in... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 10639f6118292f774ec8e4f1e3b848a2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
int T[2000][2000];
int main()
{
int m, n, t, l, i, j;
scanf("%d %d", &m, &n);
for(i = 1; i <= m; i++)
for(j = 1; j <= n; j++)
T[i][j] = 2;
for(i = 1; i <=m; i++)
{
scanf("%d", &t);
for(j = 1; j ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.