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 a small restaurant there are a tables for one person and b tables for two persons. It it known that n groups of people come today, each consisting of one or two people. If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person. If there are still none of them, the restaurant denies service to this group.If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to. | Print the total number of people the restaurant denies service to. | C | e21e768dbb2e5f72873dc1c7de4879fd | d83f0f4ca96f96da04883818e8c48c64 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1499791500 | ["4 1 2\n1 2 1 1", "4 1 1\n1 1 2 1"] | NoteIn the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table. The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, all clients are served.In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person, it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients. | PASSED | 1,200 | standard input | 1 second | The first line contains three integers n, a and b (1ββ€βnββ€β2Β·105, 1ββ€βa,βbββ€β2Β·105) β the number of groups coming to the restaurant, the number of one-seater and the number of two-seater tables. The second line contains a sequence of integers t1,βt2,β...,βtn (1ββ€βtiββ€β2) β the description of clients in chronological order. If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people. | ["0", "2"] | #include<stdio.h>
int main()
{
int i,j,n,rem=0,c=0,one_seat=0,two_seat=0,x=0;
scanf("%d%d%d",&n,&one_seat,&two_seat);
int ar[n];
for(i=0;i<n;i++)
{scanf("%d",&ar[i]);
}
for(i=0;i<n;i++)
{
if(ar[i]==1)
{
if(one_seat>0){
one_seat--;
}
else if(two_seat>0)
{
rem++;
two_seat--;
}
else if(rem>0)
rem--;
else
x++;
}
else
{
if(two_seat>0)
two_seat--;
else
x+=2;
}
}
printf("%d",x);
}
| |
In a small restaurant there are a tables for one person and b tables for two persons. It it known that n groups of people come today, each consisting of one or two people. If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person. If there are still none of them, the restaurant denies service to this group.If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to. | Print the total number of people the restaurant denies service to. | C | e21e768dbb2e5f72873dc1c7de4879fd | 5d7ecc944bddcfc264b5b666cfb204d9 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1499791500 | ["4 1 2\n1 2 1 1", "4 1 1\n1 1 2 1"] | NoteIn the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table. The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, all clients are served.In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person, it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients. | PASSED | 1,200 | standard input | 1 second | The first line contains three integers n, a and b (1ββ€βnββ€β2Β·105, 1ββ€βa,βbββ€β2Β·105) β the number of groups coming to the restaurant, the number of one-seater and the number of two-seater tables. The second line contains a sequence of integers t1,βt2,β...,βtn (1ββ€βtiββ€β2) β the description of clients in chronological order. If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people. | ["0", "2"] | #include <stdio.h>
int main()
{
int n, a, b;
scanf("%d%d%d", &n, &a, &b);
int one = a, two = b, half = 0;
int deny = 0;
for (int i = 0; i < n; i++) {
int t;
scanf("%d", &t);
if (t == 1) {
if (one > 0)
one--;
else if (two > 0)
two--, half++;
else if (half > 0)
half--;
else
deny++;
} else {
if (two == 0)
deny += 2;
else
two--;
}
}
printf("%d\n", deny);
return 0;
}
| |
In a small restaurant there are a tables for one person and b tables for two persons. It it known that n groups of people come today, each consisting of one or two people. If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person. If there are still none of them, the restaurant denies service to this group.If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to. | Print the total number of people the restaurant denies service to. | C | e21e768dbb2e5f72873dc1c7de4879fd | 988fb7f34bef17d87172b751ff170d99 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1499791500 | ["4 1 2\n1 2 1 1", "4 1 1\n1 1 2 1"] | NoteIn the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table. The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, all clients are served.In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person, it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients. | PASSED | 1,200 | standard input | 1 second | The first line contains three integers n, a and b (1ββ€βnββ€β2Β·105, 1ββ€βa,βbββ€β2Β·105) β the number of groups coming to the restaurant, the number of one-seater and the number of two-seater tables. The second line contains a sequence of integers t1,βt2,β...,βtn (1ββ€βtiββ€β2) β the description of clients in chronological order. If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people. | ["0", "2"] | #include <stdio.h>
int main(){
unsigned long int n, a, b, b2, i, denyMan=0;
scanf("%d%d%d", &n, &a, &b);
int sComer[200000];
b2=2*b;
for(i=0;i<n;i++){
scanf("%d", &sComer[i]);
if(sComer[i]==1){
if(a>0)a--;
else if(b!=0){
b2--;
b--;
}
else if(b2>0)b2--;
else denyMan++;
}
else if(sComer[i]==2){
if(b>0){
b--;
b2-=2;
}
else denyMan+=2;
}
}
printf("%d", denyMan);
} | |
In a small restaurant there are a tables for one person and b tables for two persons. It it known that n groups of people come today, each consisting of one or two people. If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person. If there are still none of them, the restaurant denies service to this group.If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to. | Print the total number of people the restaurant denies service to. | C | e21e768dbb2e5f72873dc1c7de4879fd | e9905fcf416561226603a31d828ce84d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1499791500 | ["4 1 2\n1 2 1 1", "4 1 1\n1 1 2 1"] | NoteIn the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table. The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, all clients are served.In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person, it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients. | PASSED | 1,200 | standard input | 1 second | The first line contains three integers n, a and b (1ββ€βnββ€β2Β·105, 1ββ€βa,βbββ€β2Β·105) β the number of groups coming to the restaurant, the number of one-seater and the number of two-seater tables. The second line contains a sequence of integers t1,βt2,β...,βtn (1ββ€βtiββ€β2) β the description of clients in chronological order. If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people. | ["0", "2"] | #include<stdio.h>
int main()
{
int n,t1,t2,people[200000],t=0,i,sum=0;
scanf("%d%d%d",&n,&t1,&t2);
t2*=2;
for(i=0;i<n;i++)
{
scanf("%d",&people[i]);
if(people[i]==1)
{
if(t1)
t1-=1;
else if(t2)
{
t2-=2;
t+=1;
}
else if(t)
{
t-=1;
}
else
sum+=1;
}
else
{
if(t2)
t2-=2;
else
sum+=2;
}
}
printf("%d\n",sum);
}
| |
In a small restaurant there are a tables for one person and b tables for two persons. It it known that n groups of people come today, each consisting of one or two people. If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person. If there are still none of them, the restaurant denies service to this group.If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to. | Print the total number of people the restaurant denies service to. | C | e21e768dbb2e5f72873dc1c7de4879fd | 08c6bb04e9cedf26f087b0416bce560d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1499791500 | ["4 1 2\n1 2 1 1", "4 1 1\n1 1 2 1"] | NoteIn the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table. The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, all clients are served.In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person, it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them. The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients. | PASSED | 1,200 | standard input | 1 second | The first line contains three integers n, a and b (1ββ€βnββ€β2Β·105, 1ββ€βa,βbββ€β2Β·105) β the number of groups coming to the restaurant, the number of one-seater and the number of two-seater tables. The second line contains a sequence of integers t1,βt2,β...,βtn (1ββ€βtiββ€β2) β the description of clients in chronological order. If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people. | ["0", "2"] | #include<stdio.h>
int main()
{
int n, a, b, occupy = 0, cut = 0;
scanf("%d %d %d", &n, &a, &b);
for (int i = 0; i < n; i++)
{
int m;
scanf("%d", &m);
if (m == 2)
{
if (b > 0)
b--;
else
cut += 2;
}
else
{
if (a > 0)
a--;
else if (b > 0)
{
b--;
occupy++;
}
else if (occupy > 0)
{
occupy--;
}
else
cut++;
}
}
printf("%d\n", cut);
return 0;
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | eac72367be4b2c270300ee28c6773579 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include <stdio.h>
int main()
{
int tc;
scanf("%d",&tc);
while(tc--){
long long n;
scanf("%lld",&n);
printf ("%lld\n",n);
}
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | a55b54ce6bd2e04dc27a0b27b5f4218f | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include<stdio.h>
int main()
{
int n,t,i;
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d",&n);
printf("%d\n",n);
}
return 0;
}
| |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | b4c16321f5517e1e38e93b83c7b4b441 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include<stdio.h>
int main()
{
int n,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",n);
}
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | 27ea19648ff1962fd5d99ad93e6e3ad8 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include<stdio.h>
int main()
{
int t,n,i,a;
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d",&n);
switch(n){
case 1:printf("1\n");
break;
default:printf("%d\n",n);
}
}
}
| |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | b0c130ed9a4ee532bfb882a67424ac28 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
printf("%d\n",n);
}
return 0;
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | 8227d523e748f3124fd5f6913a4feb58 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i, j;
scanf("%d",&i);
int arr[i];
for(j=0;j<i;j++)
{
scanf("%d",&arr[j]);
}
for(;j>=0;j--)
{
arr[j]=(arr[j]);
}
for(j=0;j<i;j++)
{
printf("%d \n",arr[j]);
}
return 0;
}
| |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | dab92515d7cf469b7eac98f0e69b58d6 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i, j;
scanf("%d",&i);
int arr[i];
for(j=0;j<i;j++)
{
scanf("%d",&arr[j]);
}
for(j=0;j<i;j++)
{
printf("%d \n",arr[j]);
}
return 0;
}
| |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | 2645c16b2fd431e3e6b547f3f89562ba | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include<stdio.h>
int main(void)
{
long long t;
long long n;
scanf("%lld", &t);
while (t--)
{
scanf("%lld", &n);
printf("%lld\n", n);
}
return 0;
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | cf41150a3b812b7c76fcfa3b3891aee4 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include <stdio.h>
int main()
{
long long int t, n;
scanf("%lld\n", &t);
for (long long i = 0; i < t; i++)
{
scanf("%lld\n", &n);
printf("%lld\n", n);
}
return 0;
}
| |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | 54c0370593eccb28337e8c0d3cdee479 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
long long int t;
scanf("%lld", &t);
do
{
long long int n;
scanf("%lld", &n);
printf("%lld\n", n);
--t;
} while ( t != 0 );
//system("pause");
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | 392ae6ae50b2d4d6020effd978cc682d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include <stdio.h>
#include <stdlib.h>
int main (void) {
int t;
scanf("%d",&t);
int n[t];
for(int i=0;i<t;i++)
scanf("%d",&n[i]);
for(int i=0;i<t;i++)
printf("%d\n",n[i]);
return 0;
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | cee2d4795c9289029381c94df8ad410e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
long long int i,j,k,n,m,x,y,z,t;
scanf("%lld",&t);
for(long long int z1=0;z1<t;z1++)
{
scanf("%lld",&n);
printf("%lld\n",n);
}
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | 9d0545edd3df48949aa8868921ac4431 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include<stdio.h>
long long int t, n[10000];
int main()
{
scanf("%d",&t);
int i;
for (i = 0; i < t; i++)
{
scanf("%d", &n[i]);
}
for (i = 0; i < t; i++)
{
printf("%d\n", n[i]);
}
return 0;
} | |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | f91f8684cbfeec6952c00ca4e607d36b | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include<stdio.h>
int main()
{
int a,b, n;
scanf("%d",&n);
for (int i=1;i<=n;i++)
{
scanf("%d",&a);
//scanf("%d",&b);
printf("%d\n",a);
//printf("%d\n",b);
}
}
| |
You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding. On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases. | For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$. | C | 740c05c036b646d8fb6b391af115d7f0 | 89823aa620d6492c3667e775963f323e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"implementation",
"brute force",
"math"
] | 1586700300 | ["2\n2\n1"] | NoteIn the first test case, there are the following $$$2$$$ ways to fill the area: In the second test case, there is a unique way to fill the area: | PASSED | 900 | standard input | 1 second | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$)Β β the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$). | ["2\n1"] | #include<stdio.h>
int main() {
int t,n;
scanf("%d",&t);
while(t--) {
scanf("%d",&n);
printf("%d\n",n);
}
return 0;
}
| |
A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | C | 0ecf60ea733eba71ef1cc1e736296d96 | 5d4103eff3ce43dbe45b83500305b521 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"greedy",
"brute force"
] | 1346081400 | ["6 3\nABBACC", "3 2\nBBB"] | null | PASSED | 1,600 | standard input | 2 seconds | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding cell of the stripe. | ["2\nABCACA", "1\nBAB"] | #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define MAXLEN 1000000
#define min(a, b) (((a) < (b)) ? (a) : (b))
int k, n, bad, d[MAXLEN][2] ;
char s[MAXLEN], ans[MAXLEN];
char
another(char z, char z1)
{
char res = ((z == 'A' + k - 1) ? 'A' : z + 1);
if (res == z1){
res = ((res == 'A' + k - 1) ? 'A' : res + 1);
}
return res;
}
void
solve1(void)
{
int i, j, prev = '@';
for(j = 0; j < n; ++j){
if(s[j] == prev){
++i;
} else {
i = 1;
}
if(i % 2 == 0){
ans[j] = another(s[j], (j == n - 1) ? s[j] : s[j + 1]);
++bad;
} else {
ans[j] = s[j];
}
prev = s[j];
}
}
void
solve2(void)
{
int i, start;
d[0][0] = 0;
d[0][1] = 1;
for(i = 1; i < n; ++i){
if(s[i] == s[i - 1]){
d[i][0] = d[i - 1][1];
d[i][1] = d[i - 1][0] + 1;
} else {
d[i][0] = d[i - 1][0];
d[i][1] = d[i - 1][1] + 1;
}
}
if(d[n - 1][0] < d[n - 1][1]){
start = 0;
} else {
start = 1;
}
for(i = n - 1; i >= 0; --i){
if (start == 1){
ans[i] = another(s[i], s[i]);
++bad;
} else {
ans[i] = s[i];
}
if(ans[i] == s[i - 1]){
start = 1;
} else {
start = 0;
}
}
}
int
main(void)
{
int j;
scanf("%d%d\n", &n, &k);
for(j = 0; j < n; ++j){
scanf("%c", &s[j]);
}
if(k > 2){
solve1();
}else {
solve2();
}
printf("%d\n%s", bad, ans);
return 0;
}
| |
A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | C | 0ecf60ea733eba71ef1cc1e736296d96 | ca03f6c2ff0cd23e6443add583ffca2b | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"greedy",
"brute force"
] | 1346081400 | ["6 3\nABBACC", "3 2\nBBB"] | null | PASSED | 1,600 | standard input | 2 seconds | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding cell of the stripe. | ["2\nABCACA", "1\nBAB"] | #include<stdio.h>
#include<string.h>
char q[500000];
int main(void)
{
int i=0,j,n,k,len,tmp1,tmp2,ans;
scanf("%d %d",&n,&k);
getchar();
scanf("%s",q);
len=strlen(q);
if(k==2)
{
tmp1=0;tmp2=0;
for(i=0;i<len;i+=2)
{
if(q[i]=='B') tmp1++;
if(q[i+1]=='A') tmp1++;
}
for(i=0;i<len;i+=2)
{
if(q[i]=='A') tmp2++;
if(q[i+1]=='B') tmp2++;
}
if(tmp1<tmp2)
{
printf("%d\n",tmp1);
for(i=0;i<len;i++)
{
if(i%2==0) printf("A");
else printf("B");
}
}
else
{
printf("%d\n",tmp2);
for(i=0;i<len;i++)
{
if(i%2==0) printf("B");
else printf("A");
}
}
printf("\n");
return 0;
}
ans=0;
while(i<len-2)
{
if(q[i]==q[i+1])
for(j=0;j<k;j++)
if('A'+j!=q[i] && 'A'+j!=q[i+2])
{
q[i+1]='A'+j;
i++;
ans++;
break;
}
i++;
}
if(q[len-1]==q[len-2])
{
if(q[len-1]<'A'+k-1) q[len-1]++;
else q[len-1]--;
ans++;
}
printf("%d\n%s\n",ans,q);
return 0;
} | |
A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | C | 0ecf60ea733eba71ef1cc1e736296d96 | b745e21fecd0a42f4874867a46aa7415 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"greedy",
"brute force"
] | 1346081400 | ["6 3\nABBACC", "3 2\nBBB"] | null | PASSED | 1,600 | standard input | 2 seconds | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding cell of the stripe. | ["2\nABCACA", "1\nBAB"] | #include <stdio.h>
#define LIMIT 500005
#define EMPTY -1
char ch[LIMIT][26],a[LIMIT];
int f[LIMIT][26];
int main()
{
int i,j,k,n,p,t,tmp;
while (scanf("%d%d%s",&n,&k,a)!=EOF) {
for (i=0; i<k; ++i)
f[0][i]=1;
f[0][a[0]-'A']=0;
for (i=1; i<n; ++i)
for (j=0; j<k; ++j) {
tmp=LIMIT;
p=EMPTY;
for (t=0; t<k; ++t)
if (t!=j && f[i-1][t]<tmp) {
tmp=f[i-1][t];
p=t;
}
f[i][j]=tmp+(a[i]!=j+'A');
ch[i][j]=p+'A';
}
tmp=LIMIT;
p=EMPTY;
for (i=0; i<k; ++i)
if (f[n-1][i]<tmp) {
tmp=f[n-1][i];
p=i;
}
printf("%d\n",tmp);
a[n-1]=p+='A';
for (i=1; i<n; ++i)
a[n-1-i]=p=ch[n-i][p-'A'];
a[n]='\0';
puts(a);
}
return 0;
} | |
A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | C | 0ecf60ea733eba71ef1cc1e736296d96 | 7cd92a4a9cdf4b0593118642444ae938 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"greedy",
"brute force"
] | 1346081400 | ["6 3\nABBACC", "3 2\nBBB"] | null | PASSED | 1,600 | standard input | 2 seconds | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding cell of the stripe. | ["2\nABCACA", "1\nBAB"] | #include <stdio.h>
int main()
{
int n,k,i,j,t,sum0,x,sum1,sum;
char ch[500005],c;
while(scanf("%d%d",&n,&k)!=EOF)
{
sum=0;
sum1=0;
sum0=0;
getchar();
for(i=0;i<n;i++)
scanf("%c",&ch[i]);
if(k==2)
{
for(i=0;i<n;i++)
{
if(i%2==0)
{
if(ch[i]!='A')
sum0++;
}
else
{
if(ch[i]!='B')
sum0++;
}
}
for(i=0;i<n;i++)
{
if(i%2==0)
{
if(ch[i]!='B')
sum1++;
}
else
{
if(ch[i]!='A')
sum1++;
}
}
if(sum0>sum1)
{
printf("%d\n",sum1);
for(i=0;i<n;i++)
if(i%2==0)
printf("%c",'B');
else
printf("%c",'A');
printf("\n");
}
else
{
printf("%d\n",sum0);
for(i=0;i<n;i++)
if(i%2==0)
printf("%c",'A');
else
printf("%c",'B');
printf("\n");
}
}
else {
for(i=1;i<n;i++)
{
if(ch[i]==ch[i-1])
{
j=i+1;
while(ch[j]==ch[i])
{
j++;
}
x=j-i+1;
if(x%2==1)
{
if(ch[i]=='A')
{
ch[i]='B';
t=i+2;
while(t<j)
{
ch[t]='B';
t=t+2;
}
}
else
{
c=ch[i]-1;
t=i;
while(t<j)
{
ch[t]=c;
t=t+2;
}
}
}
else
{
if(j==n)
{
if(i-2>=0)
c=ch[i-2];
else if(ch[i]=='A')
c='B';
else
c=ch[i]-1;
t=i;
while(t<j)
{
ch[t]=c;
t=t+2;
}
}
else
{
if(i-2>=0)
{
c=ch[i-2];
t=i;
while(t<j)
{
ch[t]=c;
t=t+2;
}
if(ch[j-1]==ch[j])
{
for(c='A';c<'A'+k;c++)
{
if(c!=ch[j-2]&&c!=ch[j])
{
ch[j-1]=c;
break;
}
}
}
}
else
{
c=ch[j];
t=i-1;
while(t<j)
{
ch[t]=c;
t=t+2;
}
}
}
}
i=j-1;
sum=sum+x/2;
}
}
printf("%d\n",sum);
for(i=0;i<n;i++)
printf("%c",ch[i]);
printf("\n");
}
}
return 0;
}
| |
A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | C | 0ecf60ea733eba71ef1cc1e736296d96 | 9d9484c4598150a207fa4e28bb7101ec | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"greedy",
"brute force"
] | 1346081400 | ["6 3\nABBACC", "3 2\nBBB"] | null | PASSED | 1,600 | standard input | 2 seconds | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding cell of the stripe. | ["2\nABCACA", "1\nBAB"] | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int n,k;
char str[555555];
int letter[50][50];
void init(){
int i,j,t;
for(i=1;i<=k;i++){
for(j=i;j<=k;j++){
if(i==j){
if(i==k) t = i-1;
else t = i+1;
} else {
if(j>i+1) t=i+1;
else if(j==i+1){
if(j==k) t=i-1;
else if(i==1) t=j+1;
else t=i-1;
}
else t=i+1;
}
letter[i][j] = letter[j][i] = t|64;
}
}
}
int main(){
int i;
scanf("%d%d%s",&n,&k,str);
if(k==2){
char str1[555555];
char str2[555555];
for(i=0;str[i];i++){
str1[i] = 'A' + (i&1);
str2[i] = 'A' + (i+1&1);
}
int d1,d2;
d1=d2=0;
for(i=0;str[i];i++){
d1+=(str[i]!=str1[i])?1:0;
d2+=(str[i]!=str2[i])?1:0;
}
if(d1<d2){
printf("%d\n",d1);
puts(str1);
return 0;
}
printf("%d\n",d2);
puts(str2);
return 0;
}
int ans = 0;
init();
for(i=0;str[i];i++){
if(str[i]==str[i+1]){
if(str[i+2])str[i+1] = letter[str[i]&31][str[i+2]&31];
else str[i+1] = letter[str[i]&31][str[i]&31];
ans++;
}
}
printf("%d\n%s\n",ans,str);
return 0;
}
| |
A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | C | 0ecf60ea733eba71ef1cc1e736296d96 | 946f3db53024b395a8d93a07a1d630fb | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"greedy",
"brute force"
] | 1346081400 | ["6 3\nABBACC", "3 2\nBBB"] | null | PASSED | 1,600 | standard input | 2 seconds | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding cell of the stripe. | ["2\nABCACA", "1\nBAB"] | #include<stdio.h>
int a[500000] = {};
char s[500001];
int main(){
int n, k, c = 0, i, j;
scanf("%d%d%s", &n, &k, s);
if (k > 2){
for (i = 0 ; i < n ; ++i){
if (s[i] == s[i + 1]){
for (j = 0 ; j < k - 1 ; ++j){
if ('A' + j != s[i] && 'A' + j != s[i + 2])
break;
}
s[i + 1] = 'A' + j;
++c;
}
}
printf("%d\n%s\n", c, s);
}
else {
int a0 = 0, a1 = 0, b0 = 0, b1 = 0;
for (i = 0 ; i < n ; i += 2){
if (s[i] == 'A')++a0;
else ++b0;
}
for (i = 1 ; i < n ; i += 2){
if (s[i] == 'A')++a1;
else ++b1;
}
if (a0 + b1 >= a1 + b0){
printf("%d\n", a1 + b0);
for (i = 0 ; i + i < n - 1; ++i)
printf("AB");
if (n % 2)putchar('A');
}
else {
printf("%d\n", a0 + b1);
for (i = 0 ; i + i < n - 1; ++i)
printf("BA");
if (n % 2)putchar('B');
}
}
return 0;
}
| |
A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | C | 0ecf60ea733eba71ef1cc1e736296d96 | 0149d0477e61b5566ec47a0b0404341c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"greedy",
"brute force"
] | 1346081400 | ["6 3\nABBACC", "3 2\nBBB"] | null | PASSED | 1,600 | standard input | 2 seconds | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding cell of the stripe. | ["2\nABCACA", "1\nBAB"] | #include<stdio.h>
main()
{
char a[26],s[500002];
int n,k,t=0,x,y;
scanf("%d%d%s",&n,&k,s);
s[n]='a';s[n+1]='\0';
for(x=0;x<k;a[x]=65+x,x++);
if(k!=2)
{
for(x=1;x<n;x++)
{
if(s[x]==s[x-1])
{t++;
for(y=0;y<k;y++)
{
if(a[y]!=s[x] && a[y]!=s[x+1])
{
s[x]=a[y];
break;
}
}
}
}
s[n]='\0';
printf("%d\n%s",t,s);
}
else
{
for(x=0;x<n;x++)
{
if(s[x]!=a[x%2])
t++;
}
if(t<=n/2)
{
printf("%d\n",t);
for(x=0;x<n;x++)
printf("%c",a[x%2]);
}
else
{
printf("%d\n",n-t);
for(x=1;x<=n;x++)
printf("%c",a[x%2]);
}
}
return(0);
} | |
Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$.Find this number of pairs for Rash. | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | C | 71bace75df1279ae55a6e755159d4191 | 1e9421d4400257c354c1894fd0428166 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force"
] | 1558884900 | ["010101", "11001100"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | PASSED | 1,900 | standard input | 4 seconds | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | ["3", "0"] | /* https://codeforces.com/blog/entry/67189?#comment-513690 */
/* upsolve with Dukkha */
#include <stdio.h>
#include <string.h>
#define N 300000
int main() {
static char cc[N + 1];
static char dp[N][9];
int n, i, k, good;
long long cnt;
scanf("%s", cc);
n = strlen(cc);
cnt = 0;
for (k = 3; k < 9; k++)
for (i = 0; i + k <= n; i++) {
if (k % 2 == 1 && cc[i] == cc[i + k / 2] && cc[i] == cc[i + k - 1]) {
good = 1;
} else
good = dp[i][k - 1] || dp[i + 1][k - 1];
if ((dp[i][k] = good))
cnt++;
}
if (n >= 9)
cnt += (long long) (n - 8) * (n - 7) / 2;
printf("%lld\n", cnt);
return 0;
}
| |
Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$.Find this number of pairs for Rash. | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | C | 71bace75df1279ae55a6e755159d4191 | 1ac4133dca7f4cecb8d4aa42bbccdbda | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force"
] | 1558884900 | ["010101", "11001100"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | PASSED | 1,900 | standard input | 4 seconds | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | ["3", "0"] | #include <stdio.h>
#include <string.h>
char s[300003];
int dp[300003], i, n, k;
long long res;
int main()
{
scanf("%s", &s);
n = strlen(s);
dp[n] = n;
for(i = n-1; i >= 0; i --){
dp[i] = dp[i+1];
for(k = 1; i + (k<<1) < dp[i]; k ++)
if(s[i] == s[i+k] && s[i] == s[i+(k<<1)])
dp[i] = i + (k<<1);
res += dp[i];
}
printf("%I64d", 1LL*n*n-res);
return 0;
} | |
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two intersections. Initially anyone can pass any road for free. But since SlapsGiving is ahead of us, there will q consecutive events happen soon. There are two types of events:1. Government makes a new rule. A rule can be denoted by integers v, u and w. As the result of this action, the passing fee of all roads on the shortest path from u to v increases by w dollars. 2. Barney starts moving from some intersection v and goes to intersection u where there's a girl he wants to cuddle (using his fake name Lorenzo Von Matterhorn). He always uses the shortest path (visiting minimum number of intersections or roads) between two intersections.Government needs your calculations. For each time Barney goes to cuddle a girl, you need to tell the government how much money he should pay (sum of passing fee of all roads he passes). | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | C | 12814033bec4956e7561767a6778d77e | 6ec6fd9f17bd88119e65656c61f96706 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"data structures",
"implementation",
"trees",
"brute force"
] | 1468514100 | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals to 32β+β32β+β30β=β94. Intersections on the path are 6, 3 and 1. Intersections on the path are 3 and 7. Passing fee of the road between them is 0. Intersections on the path are 2 and 4. Passing fee of the road between them is 32 (increased by 30 in the first event and by 2 in the second). | PASSED | 1,500 | standard input | 1 second | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v by w dollars, or in form 2 v u if it's an event when Barnie goes to cuddle from the intersection v to the intersection u. 1ββ€βv,βuββ€β1018,βvββ βu,β1ββ€βwββ€β109 states for every description line. | ["94\n0\n32"] | #include<stdio.h>
#include<string.h>
#define N 165003
long long key[N];
long long val[N];
long long calc(long long x){
long long val = x%N;
while(key[val] && key[val]!=x){
val++;
if(val>N)
val=1;
}
key[val]=x;
return val;
}
long long swap(long long *a,long long *b){
long long temp = *a;
*a=*b;
*b=temp;
}
long long lca(long long v, long long u, long long int w){
if(u==v)
return 0;
if(u<v)
swap(&u,&v);
val[calc(u)]+=w;
return lca(v,u/2,w) + val[calc(u)];
}
int main(){
long long a,b,c,d,e;
scanf("%lld",&a);
long long i;
for(i=0;i<a;i++){
long long in,in1,in2,in3;
scanf("%lld%lld%lld",&in,&in1,&in2);
if(in==1){
scanf("%lld",&in3);
lca(in1,in2,in3);
}
else{
printf("%lld\n",lca(in1,in2,0));
}
}
} | |
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two intersections. Initially anyone can pass any road for free. But since SlapsGiving is ahead of us, there will q consecutive events happen soon. There are two types of events:1. Government makes a new rule. A rule can be denoted by integers v, u and w. As the result of this action, the passing fee of all roads on the shortest path from u to v increases by w dollars. 2. Barney starts moving from some intersection v and goes to intersection u where there's a girl he wants to cuddle (using his fake name Lorenzo Von Matterhorn). He always uses the shortest path (visiting minimum number of intersections or roads) between two intersections.Government needs your calculations. For each time Barney goes to cuddle a girl, you need to tell the government how much money he should pay (sum of passing fee of all roads he passes). | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | C | 12814033bec4956e7561767a6778d77e | b9523faa40d44c93902ea2c6362edcbe | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"data structures",
"implementation",
"trees",
"brute force"
] | 1468514100 | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals to 32β+β32β+β30β=β94. Intersections on the path are 6, 3 and 1. Intersections on the path are 3 and 7. Passing fee of the road between them is 0. Intersections on the path are 2 and 4. Passing fee of the road between them is 32 (increased by 30 in the first event and by 2 in the second). | PASSED | 1,500 | standard input | 1 second | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v by w dollars, or in form 2 v u if it's an event when Barnie goes to cuddle from the intersection v to the intersection u. 1ββ€βv,βuββ€β1018,βvββ βu,β1ββ€βwββ€β109 states for every description line. | ["94\n0\n32"] | #include<stdio.h>
#include<string.h>
#define N 165003
long long key[N];
long long val[N];
long long calc(long long x){
long long val = x%N;
while(key[val] && key[val]!=x){
val++;
if(val>N)
val=1;
}
key[val]=x;
return val;
}
long long swap(long long *a,long long *b){
long long temp = *a;
*a=*b;
*b=temp;
}
long long lca(long long u, long long v){
while(u!=v){
if(u>v){
u/=2;
}
else{
v/=2;
}
}
return u;
}
long long upd(long long u,long long v,long long w,long long lc){
while(u!=lc || v!=lc){
if(u!=lc){
val[calc(u)]+=w;
u/=2;
}
if(v!=lc){
val[calc(v)]+=w;
v/=2;
}
}
}
long long solve(long long u,long long v,long long lc){
long long s =0 ;
while(u!=lc || v!=lc){
if(u!=lc){
s+=val[calc(u)];
u/=2;
}
if(v!=lc){
s+=val[calc(v)];
v/=2;
}
}
return s;
}
int main(){
long long a,b,c,d,e;
scanf("%lld",&a);
long long i;
for(i=0;i<a;i++){
long long in,in1,in2,in3;
scanf("%lld%lld%lld",&in,&in1,&in2);
long long int res = lca(in1,in2);
if(in==1){
scanf("%lld",&in3);
upd(in1,in2,in3,res);
}
else{
printf("%lld\n",solve(in1,in2,res));
}
}
} | |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 04261a146bb878788bb78b8f0531062c | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int n,d,m,x,y;
scanf("%d %d",&n,&d);
if(1<=d && d<n && n<=100)
scanf("%d",&m);
if(m>=1 && m<=100)
for(int i=0;i<m;i++)
{
scanf("%d %d",&x,&y);
if((x+y)>=d && (x+y)<=(2*n-d)&& (x-y)<=d && (x-y)>=(-d))
{
printf("YES\n");
}
else
printf("NO\n");
}
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 656648af4a870626c7d88b639c97b955 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | /* Codeforces 1030B - Vasya and Cornfield*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a, b) ((a > b) ? a : b)
double distance(double, double, int, int, int); // Calculate the distance from (x, y) to a line
int main()
{
int n, d, m;
scanf("%d %d %d", &n, &d, &m);
double x, y; // Position of each grasshopper
for (unsigned i = 0; i < m; i++)
{
scanf("%lf %lf", &x, &y);
if (MAX(distance(x, y, -1, 1, d), distance(x, y, -1, 1, -d)) <= sqrt(2) * d &&
MAX(distance(x, y, 1, 1, -d), distance(x, y, 1, 1, d - 2*n)) <= sqrt(2) * (n - d))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
double distance(double x, double y, int a, int b, int c)
{
return abs(a * x + b * y + c) / sqrt(pow(a, 2) + pow(b, 2));
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 51eb5b3d9794e4b61fc02721d87fab25 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main()
{
int i=0, n,m, x, y, d;
scanf("%d %d", &n,&d);
scanf("%d", &m);
for(i=0;i<m;i++)
{
scanf("%d %d", &x, &y);
if(y<=x+d&&y>=x-d)
{
if(y>=d-x&&y<=2*n-d-x)
printf("YES\n");
else
printf("NO\n");
}
else
{
printf("NO\n");
}
}
} | |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | f5f9ad8cf4dd5dd41ba1d74702897eac | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
#include<math.h>
int main()
{
float A,A1,A2,A3,A4,a1,a2,a3,a4,b1,b2,b3,b4,u1,u2,u3,u4,s;
int n,d,x,y,m,i,s1,s2,l;
scanf("%d%d",&n,&d);
scanf("%d",&m);
for(i=0;i<m;i++){
A=0,A1=0,A2=0,A3=0,A4=0,a1=0,a2=0,a3=0,a4=0,b1=0,b2=0,b3=0,b4=0,u1=0,u2=0,u3=0,u4=0,s=0,s1=0,s2=0;
scanf("%d%d",&x,&y);
a1=sqrt(2)*d;
a2=sqrt(2)*(n-d);
a3=sqrt(2)*d;
a4=sqrt(2)*(n-d);
b1=sqrt((x*x)+((d-y)*(d-y)));
b2=sqrt(((x-d)*(x-d))+(y*y));
b3=sqrt(((x-n)*(x-n))+((y-n+d)*(y-n+d)));
b4=sqrt(((x-n+d)*(x-n+d))+((y-n)*(y-n)));
u1=(a1+b1+b2)/2;
u2=(a2+b2+b3)/2;
u3=(a3+b3+b4)/2;
u4=(a4+b4+b1)/2;
A=a1*a2;
A1=sqrt(u1*(u1-a1)*(u1-b1)*(u1-b2));
A2=sqrt(u2*(u2-a2)*(u2-b2)*(u2-b3));
A3=sqrt(u3*(u3-a3)*(u3-b3)*(u3-b4));
A4=sqrt(u4*(u4-a4)*(u4-b4)*(u4-b1));
s=A1+A2+A3+A4;
if(A>=s||s-A<=.1){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return 0;
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 12dece99627bd308b8c1442133174b27 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main()
{
int n,d;
scanf("%d %d",&n,&d);
int m;
scanf("%d",&m);
int ara[m][2];
for(int j=0;j<m;j++)
{
scanf("%d %d",&ara[j][0],&ara[j][1]);
}
for(int i=0;i<m;i++)
{
if( ((ara[i][0]-ara[i][1]+d) >=0) && ((ara[i][0]-ara[i][1]-d) <=0) && ((ara[i][0]+ara[i][1]-d) >=0) && ((ara[i][0]+ara[i][1]+d-2*n) <=0) )
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
return 0;
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 2d0b0424aa3d800743fa1a6e0f91aac2 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main(){
int n , d;
int m;
int P[100][2];
scanf("%d %d",&n,&d);
scanf("%d",&m);
int i;
for(i = 0 ; i < m ; i++)
{
scanf("%d %d",&P[i][0], &P[i][1]);
}
for(i = 0 ; i < m ; i++)
{
if(P[i][0]+ P[i][1] >= d && P[i][1] - P[i][0] <= d &&P[i][0]+ P[i][1] <= 2*n-d && P[i][0] - P[i][1] <= d)
{
if(i!=m-1)
printf("YES\n");
else printf("YES");
}
else
{
if(i!=m-1)
printf("NO\n");
else printf("NO");
}
}
return 0;
} | |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | fea117b6d08ef0848fc7a4f5830c0fa3 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int d,n;
int Y_1(int x,int y)
{
return d-x;
}
int Y_2(int x,int y)
{
return x+d;
}
int Y_3(int x,int y)
{
return 2*n-x-d;
}
int Y_4(int x,int y)
{
return x-d;
}
int main()
{
int i,m,x,y;
scanf("%d %d",&n,&d);
scanf("%d",&m);
if(n-d>d){
for(i=1;i<=m;i++)
{
scanf("%d %d",&x,&y);
if(x>=0&&x<=d)
{
if(y>=Y_1(x,y)&&y<=Y_2(x,y))
printf("YES\n");
else
printf("NO\n");
}
else if(x>=d&&x<=n-d)
{
if(y>=Y_4(x,y)&&y<=Y_2(x,y))
printf("YES\n");
else
printf("NO\n");
}
else if(x>=n-d&&x<=n)
{
if(y>=Y_4(x,y)&&y<=Y_3(x,y))
printf("YES\n");
else
printf("NO\n");
}
else if(x>n)
{
printf("NO\n");
}
}
}
else{
for(i=1;i<=m;i++)
{
scanf("%d %d",&x,&y);
if(x>=0&&x<=n-d)
{
if(y>=Y_1(x,y)&&y<=Y_2(x,y))
printf("YES\n");
else
printf("NO\n");
}
else if(x>=n-d&&x<=d)
{
if(y>=Y_1(x,y)&&y<=Y_3(x,y))
printf("YES\n");
else
printf("NO\n");
}
else if(x>=d&&x<=n)
{
if(y>=Y_4(x,y)&&y<=Y_3(x,y))
printf("YES\n");
else
printf("NO\n");
}
else if(x>n)
{
printf("NO\n");
}
}
}
return 0;
};
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 2174f1b74bb080d9c708fa5964895f67 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include <stdio.h>
#include <stdlib.h>
int d,n;
void inside(int x, int y)
{
if (y-x<=d&&y+x>=d&&y-x>=-d&&y+x<=2*n-d) printf("YES\n");
else printf("NO\n");
}
int main()
{
scanf("%d%d",&n,&d);
int q,i,x,y;
scanf("%d",&q);
for (i=0;i<q;i++)
{
scanf("%d%d",&x,&y);
inside(x,y);
}
return 0;
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 36135efa58efb0b92d45cfe9d0fc3877 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include <stdio.h>
int main() {
int temp, d, n, m, i, x, y;
scanf("%d %d", &d, &n);
if (d > n) {
temp = d;
d = n;
n = temp;
}
scanf("%d", &m);
for(i=0; i<m; i++) {
scanf("%d %d", &x, &y);
if (y >= d-x && y >= x-d && y <= 2*n-x-d && y <= x+d)
printf("YES\n");
else
printf("NO\n");
}
return 0;
} | |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | db1cb478086af1a553d30f850e5180dc | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main()
{
int d, n, m, p, q, r, x,y, i;
scanf("%d%d%d", &n, &d, &m);
for(i=1;i<=m;i++)
{
scanf("%d%d", &x, &y);
q=abs(d-x);
r=n-d;
r=abs(r-x);
p=n-r;
if(y>=q && p>=y)
printf("YES\n");
else
printf("NO\n");
}
return 0;
} | |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 2420ab8f643d3fb3159359814c55dac9 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
/*int cmp(const void *a, const void *b)
{
return(*(int *)a-*(int *)b);
}*/
// qsort(a,n,sizeof(a[0]),cmp);
int main()
{
int n,d,m,i,x,y;
scanf("%d %d",&n,&d);
scanf("%d",&m);
for(i = 0; i < m; i++)
{
scanf("%d %d",&x,&y);
if(x + y - d < 0 || x + y - 2*n + d > 0 || x - y - d > 0 || x - y + d < 0)
{
printf("no\n");
}
else
{
printf("yes\n");
}
}
return 0;
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | d7fbf1aa7f4493cd91fa8ae542b274c7 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main()
{
int n,m,d;
scanf("%d %d",&n,&d);
scanf("%d",&m);
int x,y,count=0;
for(int i=0;i<m;i++)
{
scanf("%d",&x);
scanf("%d",&y);
if((x+y-d>=0)&&(x+y+d-2*n<=0)&&(y-x+d>=0)&&(y-x-d<=0))
printf("YES\n");
else
printf("NO\n");
}
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 61e0003d3ca8090390a8d33cf6c2cc4c | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main()
{
int n,d,m,i,x,y;
scanf("%d %d",&n,&d);
scanf("%d",&m);
for(i=0;i<m;i++){
scanf("%d %d",&x,&y);
if(x-y>d || y-x>d || x+y<d || x+y>2*n-d)
printf("NO\n");
else{
printf("YES\n");
}
}
return 0;
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | d24b60392e45909be089f1101ef2375a | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main()
{
int n,d,m,t;
scanf("%d%d%d",&n,&d,&m);
t=m-1;;
int arr[m];
while(m--)
{
int a,b;
scanf("%d%d",&a,&b);
if((a+b>=d)&&(a+b<=(2*n)-d)&&(a-b<=d)&&(a-b>=-d))
arr[m]=1;
else
arr[m]=0;
}
for(int i=t;i>=0;i--)
{
if(arr[i]==1)
printf("%s\n","YES");
else
printf("%s\n","NO");
}
return 0;
} | |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 758d68741e66e6a1f3ee5c205e715bac | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main()
{
int k,n,d,x[200],y[200],m,i=0,j=0;
scanf("%d %d %d",&n,&d,&m);
k=m;
while(m--){
scanf("%d %d",&x[i],&y[i]);
i++;
}
while(k--){
if(x[j]+y[j]-d<0||x[j]+y[j]-2*n+d>0||x[j]-y[j]-d>0||x[j]-y[j]+d<0) {printf("NO\n");j++;}
else {printf("YES\n");j++;}
}
return 0;
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 170939669bbc8edc95d4c7fe7e426d46 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main()
{
int n,d,x,y,m;
scanf("%d %d",&n,&d);
scanf("%d",&m);
while(m--)
{
scanf("%d%d",&x,&y);
if(x+y-d<0||x+y-2*n+d>0||x-y-d>0||x-y+d<0)
{
printf("NO\n");
}
else printf("YES\n");
}
return 0;
} | |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | 0551c77c979c519cb30794deb491a84e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include<stdio.h>
int main(){
int n,d;
scanf("%d%d",&n,&d);
int m,i;
scanf("%d",&m);
for(i=0;i<m;i++){
int x,y;
scanf("%d%d",&x,&y);
int l=x-(y+d);
int h=y-(x+d);
int f=x+y+d-(2*n);
int g=x+y-d;
if(l<0 && h<0 && f<0 && g>0){
printf("YES\n");
continue;
}
if(l==0 || h==0 || f==0 || g==0){
printf("YES\n");
continue;
}
printf("NO\n");
}
return 0;
}
| |
Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border). | Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower). | C | 9c84eb518c273942650c7262e5d8b45f | f2b0143d713f5f61172b9be6dde526c8 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"geometry"
] | 1537707900 | ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"] | NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. | PASSED | 1,100 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) β the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) β position of the $$$i$$$-th grasshopper. | ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
double area(int x1,int y1,int x2,int y2,int x3,int y3){
double a;
a = (x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))/2.0;
a = fabs(a);
return a;
}
int main()
{
int n,d,m,i,j;
int** ptr;
double a,a1,a2,a3,a4,sum;
scanf("%d%d",&n,&d);
scanf("%d",&m);
ptr = (int**)malloc(m*sizeof(int*));
for(i=0;i<m;i++){
ptr[i]=(int*)malloc(2*sizeof(int));
}
for(i=0;i<m;i++){
for(j=0;j<2;j++){
scanf("%d",&ptr[i][j]);
}
}
a = area(0,d,d,0,n,n-d) + area(0,d,n,n-d,n-d,n);
for(i=0;i<m;i++){
a1 = area(ptr[i][0],ptr[i][1],0,d,d,0);
a2 = area(ptr[i][0],ptr[i][1],d,0,n,n-d);
a3 = area(ptr[i][0],ptr[i][1],n,n-d,n-d,n);
a4 = area(ptr[i][0],ptr[i][1],n-d,n,0,d);
sum = a1+a2+a3+a4;
if(sum==a)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
| |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | 5482143e2108d97aa7fd1697ef713e1c | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include<stdio.h>
int main(void)
{
int Number,Count;
char E[5];
scanf("%d",&Number);
gets(E);
char String[Number+1],String_Decoded[Number+1];
gets(String);
if(Number%2)
for(Count=0;Count<Number;Count++)
{
if(Count==0)
String_Decoded[Number/2]=String[Count];
else
{
if(Count%2)
String_Decoded[Number/2-(Count/2+1)]=String[Count];
else
String_Decoded[Number/2+Count/2]=String[Count];
}
}
else
for(Count=0;Count<Number;Count++)
{
if(Count==0)
String_Decoded[Number/2-1]=String[Count];
else
{
if(Count%2)
String_Decoded[(Number/2-1)+(Count/2+1)]=String[Count];
else
String_Decoded[(Number/2-1)-Count/2]=String[Count];
}
}
String_Decoded[Number]='\0';
puts(String_Decoded);
return 0;
} | |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | 28f68764e144985827f4b8d7f86c498e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include <stdio.h>
int main(void) {
unsigned int n;
scanf("%u\n", &n);
char result_str[n + 1];
int med = n % 2 == 0 ? n / 2 : (n + 1) / 2;
result_str[med] = getchar();
if(n % 2 == 1) {
int sign = -1;
for(int i = 1; i < n; i++) {
int c = getchar();
med += sign * i;
result_str[med] = c;
sign = -sign;
}
} else {
int sign = 1;
for(int i = 1; i < n; i++) {
int c = getchar();
med += sign * i;
result_str[med] = c;
sign = -sign;
}
}
for(int i = 1; i <= n; i++) {
putchar(result_str[i]);
}
return 0;
} | |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | 94af6a21057fb60a552c074eef52b8ca | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include<stdio.h>
#include<string.h>
#include<math.h>
void append(char str[], char ch, int pos)
{
char buf[3000];
strncpy(buf, str, pos);
buf[pos] = ch;
strcpy(buf + pos + 1, str+pos);
strcpy(str, buf);
free(buf);
//puts(str);
}
int main()
{
char str1[3000], str2[3000], ch;
int n, len, pos, index;
scanf("%d", &n);
getchar();
gets(str1);
index = strlen(str1) - 2;
strcpy(str2, str1 + index);
while(strlen(str2) != n){
len = n - strlen(str2) - 1;
ch = str1[len];
pos = (int)(strlen(str2))/2.0;
append(str2, ch, pos);
}
puts(str2);
return 0;
}
| |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | cd429ae44fe7ab3c48ab7e0bef686ee2 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include <stdio.h>
#include <string.h>
int main(void)
{
int n;
scanf("%d%*c",&n);
char s[2001];
gets(s);
int direction[2] = {0,n-1};
char decode[2001];
int count = n-1;
char dir = 1; // 1 is right and 0 is left
for (count; count >= 0; count--)
{
decode[direction[dir]] = s[count];
(dir)?direction[dir]--:direction[dir]++;
dir = !dir;
}
decode[n]='\0';
printf("%s",decode);
} | |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | 1159702cd8f005cdc0e137da05e05b6a | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include<stdio.h>
#include<string.h>
int main()
{
char a[4000], b[4000];
memset(b, 0, sizeof(b));
int n, i, j, len;
scanf("%d\n", &n);
fgets(a, 4000, stdin);
len=n;
if(n>2){
if(n%2!=0)
for(i=0; i<len; i++)
{
if(i==0){
/*if(n%2==0)
{
j=n/2 -1;
b[j]=a[i];
}*/
//else
//{
j=n/2;
b[j]=a[i];
//}
}
if(i%2!=0)
{
j=j-i;
b[j]=a[i];
}
else
{
j=j+i;
b[j]=a[i];
}
}
else
for(i=0; i<len; i++)
{
if(i==0)
{
j=n/2 -1;
b[j]=a[i];
}
else if(i%2==0)
{
j=j-i;
b[j]=a[i];
}
else
{
j=j+i;
b[j]=a[i];
}
}
printf("%s\n", b);
}
else printf("%s", a);
return 0;
}
| |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | 7339d573ac4c37f9ced62af012f2cf56 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
int n,i,k,j;
scanf("%d",&n);
char S[n];
scanf("%s",&S);
for(k=2;k<=n;k+=2)
{
printf("%c",S[n-k]);
}
if(n%2==1)
{
i=0;
}
else
{
i=1;
}
for(;i<n;i+=2)
{
printf("%c",S[i]);
}
printf("\n");
return 0;
}
| |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | 63dca0807a86c390258baf398eb0a08c | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main()
{
int n,i,m,j,f,k=0;
scanf("%d",&n);
char s2[n+1];
char s[n+1];
gets(s);
gets(s);
m=n/2;
j=n/2;
f=n;
if(n%2==1){
s2[m]=s[0];
for(i=1;i<n;i++){
if(i%2==1){
s2[m-1]=s[i];
m--;
}
else{
s2[j+1]=s[i];
j++;
}
}
}
else{
s2[m-1]=s[0];
for(i=1;i<n;i++){
if(i%2==1){
s2[m]=s[i];
m++;
}
else{
s2[j-2]=s[i];
j--;
}
}
}
for(i=0;i<f;i++)
printf("%c",s2[i]);
return 0;
} | |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | 1138d4c469964e484eda336dada75bc7 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include<stdio.h>
int main()
{
int n, i;
char a[2001];
scanf("%d", &n);
scanf("%s", a);
n-=1;
for(i=n-1; i>=0; i-=2)
{
printf("%c", a[i]);
}
if(n%2==0) i=0;
else i = 1;
for(i; i<=n; i+=2) printf("%c", a[i]);
return 0;
} | |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | 9ebc81bf08678e46bed92ec7015687b4 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include<stdio.h>
int main(void)
{
int i,r,l,n;
scanf("%d",&n);
char string[n+2],answer[n+2];
scanf("%s",string);
if(!(n&1))
{
for(r=n/2-1,i=0;i<n&&r>=0;i+=2,r--)
answer[r]=string[i];
for(l=n/2,i=1;l<n&&i<n;l++,i+=2)
answer[l]=string[i];
answer[n]='\0';
}
else
{
for(r=n/2,i=0;i<n&&r<n;i+=2,r++)
answer[r]=string[i];
for(l=n/2-1,i=1;i<n&&l>=0;i+=2,l--)
answer[l]=string[i];
answer[n]='\0';
}
printf("%s\n",answer);
return 0;
}
| |
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. | Print the word that Polycarp encoded. | C | 2a414730d1bc7eef50bdb631ea966366 | aab3ef273afc887fd3efc6523a4f6edc | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"strings"
] | 1482057300 | ["5\nlogva", "2\nno", "4\nabba"] | NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba. | PASSED | 900 | standard input | 1 second | The first line contains a positive integer n (1ββ€βnββ€β2000)Β β the length of the encoded word. The second line contains the string s of length n consisting of lowercase English lettersΒ β the encoding. | ["volga", "no", "baba"] | #include <stdio.h>
int main() {
int i,n,j=1;
scanf("%d",&n);
char coded[n];
scanf("%s",coded);
char decoded[n];
for(i=0;i<n;i++)
{
if(n-j-1 <0)
{
if (n-j == 0)
{
decoded[n-i-1] = coded[n-j];
}
decoded[n] = '\0';
decoded[n+1] = '\0';
printf("%s",decoded);
return 0;
}
decoded[n-i-1] = coded[n-j];
decoded[i] = coded[n-j-1];
j+=2;
}
} | |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | f82578ddc92ef50fb625cc07617e830c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
//#include<conio.h>
#include<stdlib.h>
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main()
{
int n,m,i,j;
int a[101],b[101];
int max=0;
scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
qsort (a, n, sizeof(long int), compare);
for(j=0;j<m;j++)
{
scanf("%d",&b[j]);
}
qsort (b, m, sizeof(long int), compare);
/*for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
for(j=0;j<m;j++)
{
printf("%d ",b[j]);
}*/
if((2*a[0])>a[n-1])
{
max=2*a[0];
}
else
{
max=a[n-1];
}
if(max<b[0])
{
printf("%d",max);
}
else
{
printf("-1");
}
//getch();
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 465136d84928a885f5b6cb58f169d1dd | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include <stdio.h>
int main()
{
int a, b, n[101], m[101], i, k=101, l=0 ,s=101, p;
scanf("%d %d", &a, &b);
for(i=0; i<a; i++)
{
scanf("%d", &n[i]);
}
for(i=0; i<b; i++)
{
scanf("%d", &m[i]);
}
for(i=0; i<a; i++)
{
if(k>n[i])
{
k=n[i];
}
}
for(i=0; i<a; i++)
{
if(l<n[i])
{
l=n[i];
}
}
for(i=0; i<b; i++)
{
if(s>m[i])
{
s=m[i];
}
}
p=2*k;
if(p<l || p==l)
{
// printf("%d %d %d", k, l, s);
if(l<s)
{
printf("%d\n", l);
}
else
{
printf("-1\n");
}
}
else if(p>l && p<s)
{
printf("%d\n", p);
}
else
{
printf("-1\n");
}
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 7e12a3e7c5219818bfb0f926953d0487 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
typedef unsigned u;
int main()
{
u mw,mr,Mr=0,w,r,n,T;
scanf("%u%u",&r,&w);
for(mw=mr=0xffffffffu;r--;mr>n?mr=n:0,Mr<n?Mr=n:0)scanf("%u",&n);
while(w--)scanf("%u",&n),mw>n?mw=n:0;T=(mr<<=1)<Mr?Mr:mr;
printf(T<mw?"%u\n":"-1\n",T);
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 27b04e5116b33ce8d9df7cba42cff484 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int main(){
int n,m,i,q,p,t;
int a[110],b[110];
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)scanf("%d",a+i);
for(i=0;i<m;i++)scanf("%d",b+i);
p=q=a[0];
t=b[0];
for(i=1;i<n;i++){
if(p>a[i])p=a[i];
if(q<a[i])q=a[i];
}
for(i=1;i<m;i++)
if(t>b[i])t=b[i];
if(2*p>=t || t<=q)printf("-1\n");
else
printf("%d\n",q>2*p ? q:2*p);
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | ccc7b1dd2892b9b53899c6aca05aea86 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int main(){
int n,m,k,l,q,i;
scanf("%d %d ",&n,&m);
int arr[n],are[m];
k = 0;
l = 101;
for(i=0;i<n;i++){
scanf("%d", &arr[i]);
if(arr[i] > k)
k = arr[i];
if(arr[i] < l)
l = arr[i];
}
l = 2*l;
if(l>k)
k=l;
q = 101;
for(i=0;i<m;i++){
scanf("%d", &are[i]);
if(are[i] < q)
q = are[i];
}
if(q>k)
printf("%d", k);
else
printf("-1");
return 0;
} | |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 13258cbb0fa8cbb4f07a1217419ad904 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int A[101];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
int i,j,max=-1,min1=101;
for(i=0;i<n;i++)
{
scanf("%d",&A[i]);
if(A[i]>max)
max=A[i];
if(A[i]<min1)
min1=A[i];
}
int min=101,a;
for(i=0;i<m;i++)
{
scanf("%d",&a);
if(a<min)
min=a;
}
min--;
if(max<2*min1)
max=2*min1;
if(min>=max)
printf("%d\n",max);
else
printf("-1\n");
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | f10b589df783ae9408e590203dbb8aca | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int main()
{
int n,m,a[500]={0},b[500]={0},i,j,min=0,max=0,ans=0;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<m;i++)
{
scanf("%d",&b[i]);
}
if(n==1)
{
min=b[0];
for(i=0;i<m;i++)
{
if(b[i]<min)
{
min=b[i];
}
}
if(min<=2*a[0])
printf("-1\n");
else
printf("%d",2*a[0]);
return 0;
}else{
min=a[0];
max=0;
for(i=0;i<n;i++)
{
if(a[i]<min)
{
min=a[i];
}
if(a[i]>max)
{
max=a[i];
}
}
ans=max;
if(min*2>max)
{
max=min*2;
}
else
max=ans;
for(i=0;i<m;i++)
{
if(b[i]<=max)
{
printf("-1\n");
return 0;
}
}
printf("%d\n",max);
return 0;
}
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 4136fd55b245adc26b9ddf4dc13ffd12 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include <stdio.h>
int pas[101];
int fail[101];
int main()
{
int minp=1000,maxp=0;
int minf=1000,maxf=0;
int n,m,i,j,k,l,b;
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++)
{
scanf("%d",&pas[i]);
if(pas[i]<minp)
minp=pas[i];
if(pas[i]>maxp)
maxp=pas[i];
}
for(i=1;i<=m;i++)
{
scanf("%d",&fail[i]);
if(fail[i]<minf)
minf=fail[i];
if(fail[i]>maxf)
maxf=fail[i];
}
if(((2*minp)<minf)&&(maxp<minf))
{
if(2*minp>maxp)
printf("%d",2*minp);
else
printf("%d",maxp);
}
else
printf("%d",-1);
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 0a458664d939a70b5ecda222f714e408 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int main()
{
int start,end,i,n,m,a[1005],b[1005],a_max=0,a_min=1000,b_min=1000;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]<a_min)
a_min=a[i];
if(a[i]>a_max)
a_max=a[i];
}
for(i=0;i<m;i++)
{
scanf("%d",&b[i]);
if(b[i]<b_min)
b_min=b[i];
}
if(a_max>2*a_min)
start=a_max;
else
start=2*a_min;
end=b_min-1;
if(start>end)
printf("-1\n");
else
printf("%d\n",start);
return 0;
} | |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 6389d72806f4713966c9a93b5b6e7d17 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | /* CodeForces 350A GNU/C */
#include <stdio.h>
#define MAX 100
int main()
{
unsigned n = 0, //Number of correct solutions
m = 0; //Number of wrong solutions
unsigned correctSolutions[MAX],
wrongSolutions[MAX];
unsigned minCorrect = MAX,
maxCorrect = 0,
minWrong = MAX;
scanf("%d%d", &n, &m);
for (unsigned i=0; i<n; i++) {
scanf("%d", &correctSolutions[i]);
if (correctSolutions[i] < minCorrect) {
minCorrect = correctSolutions[i];
}
if (correctSolutions[i] > maxCorrect) {
maxCorrect = correctSolutions[i];
}
}
for (unsigned i=0; i<m; i++) {
scanf("%d", &wrongSolutions[i]);
if (wrongSolutions[i] < minWrong) {
minWrong = wrongSolutions[i];
}
}
if ((2*minCorrect >= minWrong) || (minWrong <= maxCorrect)) {
printf("-1\n");
}
else if (2*minCorrect > maxCorrect) {
printf("%d\n", 2*minCorrect);
}
else {
printf("%d\n", maxCorrect );
}
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | c804aef4b05307770e90f682d616fa3e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include <stdio.h>
#define MAX 107
int main()
{
int n, m, max = 0, min = MAX, i, x, ans;
scanf("%d %d", &n, &m);
for(i=0;i<n;++i)
{
scanf("%d", &x);
if(x > max)
{
max = x;
}
if(x < min)
{
min = x;
}
}
ans = (max >= 2 * min) ? max : 2 * min;
for(i=0;i<m;++i)
{
scanf("%d", &x);
if(x <= ans)
{
break;
}
}
if(i == m)
{
printf("%d\n", ans);
}
else
{
printf("-1\n");
}
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 7be94b139b2b57d1f9c82e8898715103 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int a[105],b[105];
int main()
{
int n,m;
int i,max,min,j;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<m;i++)
scanf("%d",&b[i]);
max=a[0];
min=b[0];
for(i=1;i<m;i++)
{
if(min>b[i])
min=b[i];
}
for(i=1;i<n;i++)
{
if(max<a[i])
max=a[i];
}
// printf("%d %d ",max,min);
// printf("%d %d",max,min);
int flag=1;
if(max<=0)
flag=0;
if(max>=min)
flag=0;
if(flag==1)
{
// printf("$");
for(i=max;i<min;i++)
{
for(j=0;j<n;j++)
{
if(2*a[j]<=i)
{
max=i;
flag=2;
// printf("-");
break;
}
}
if(flag==2)
break;
}
}
else
{
// printf(" >< ");
printf("-1\n");
}
if(flag==2)
printf("%d\n",max);
else if(flag==1)
printf("-1\n");
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | da4e8a96b946bd36929f628e851fc54e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include <stdio.h>
int cmpfunc(const void *a, const void *b)
{
return (*(int*)a-*(int*)b);
}
int main()
{
int ans, n, m, a[101], b[101], i, j;
scanf("%d %d", &n, &m);
for(i=0; i<n; i++)
scanf("%d", &a[i]);
for(i=0; i<m; i++)
scanf("%d", &b[i]);
qsort(a, n, sizeof(int), cmpfunc);
qsort(b, m, sizeof(int), cmpfunc);
//for(i=0; i<n; i++)
// printf("%d ", a[i]);
//printf("\n");
//for(i=0; i<m; i++)
// printf("%d ", b[i]);
ans=a[n-1];
if(n==1)
ans*=2;
if(ans<2*a[0])
ans+=(2*a[0]-ans);
if(ans>=b[0])
printf("-1\n");
else
printf("%d\n", ans);
return 0;
} | |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 72109cb843e70eaf04750c35696c9ed6 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int main()
{
int i,j,k=0,t,n,m,a[100],b[100],ex=0;
scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<m;i++){
scanf("%d",&b[i]);
if(i==0)
k=b[0];
else if(k>b[i])
k=b[i];}
for(i=0;i<n;i++)
for(j=i;j<n;j++)
{if(a[i]>a[j])
{t=a[i];
a[i]=a[j];
a[j]=t;}t=0;
}for(i=0;i<n;i++)
{
if(2*a[i]<=a[n-1]&&a[n-1]<k)
{printf("%d",a[n-1]);t=1;break;}
else if(2*a[i]>a[n-1]&&2*a[i]<k)
{printf("%d",2*a[i]);t=1;break;}
}
if(t!=1)
printf("-1");
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | aca82ac4a5c05b83df5e16223c710583 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include <stdio.h>
#include <stdlib.h>
int part(int *a, int p, int r)
{
int x = a[r];
int i, j, t;
i = p - 1;
for (j = p; j < r; j++) {
if (a[j] < x) {
i++;
t = a[j];
a[j] = a[i];
a[i] = t;
}
}
t = a[i + 1];
a[i + 1] = a[r];
a[r] = t;
return i + 1;
}
void qs(int *a, int p, int r) {
if (p < r) {
int q;
q = part(a, p, r);
qs(a, p, q - 1);
qs(a, q + 1, r);
}
}
int main()
{
int a[102];
int i;
int b[102];
int size1, size2;
scanf("%d%d", &size1, &size2);
for (i = 0; i < size1; i++) {
scanf("%d", &a[i]);
}
for (i = 0; i < size2; i++) {
scanf("%d", &b[i]);
}
qs(a, 0, size1 - 1);
qs(b, 0, size2 - 1);
/* for (i = 0; i < size1; i++) {
printf("%d", a[i]);
}
for (i = 0; i < size2; i++) {
printf("%d", b[i]);
}*/
int t = a[size1 - 1];
if (t >= b[0]) {
printf("-1\n");
return 0;
}
for (i = t; i < b[0]; i++) {
if (i >= 2*a[0]) {
break;
}
}
printf("\n");
if (i == b[0]) {
printf("-1\n");
} else {
printf("%d\n", i);
}
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 0b20b2c6ccbfcc3ef6030f2c6f97e4f8 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include <stdio.h>
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main(void) {
int i,a,b;
int cr[1010],wr[1010];
// your code goes here
scanf("%d%d",&a,&b);
for(i=0;i<a;i++)
{
scanf("%d",&cr[i]);
}
for(i=0;i<b;i++){
scanf("%d",&wr[i]);
}
qsort (cr, a, sizeof(int), compare);
qsort (wr, b, sizeof(int), compare);
int wr_min=wr[0];
int cr_max = cr[a-1];
int start = cr[0]%3?((cr[0]*2)+2)/3:(cr[0]*2)/3;
int flag=0;
//printf("%d\n",start);
for(i=start;i<wr[0];i++)
{
if((cr_max <= (i)) && (wr_min > i) && (cr[0]*2 <= i))
{
flag=1;
break;
}
}
if(flag==1)
{
printf("%d\n",i);
}
else{
printf("-1\n");
}
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | dc72d29dae727a7cca03b3b68d74596e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
#include<stdlib.h>
int min(int a,int b)
{
if(a<b)
return a;
else
return b;
}
int main()
{
int n,m;
int i,j,cmax=-1,c[101],wr[101],cmin=100000000,wmin=10000000;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&c[i]);
cmin=min(cmin,c[i]);
if(c[i]>cmax)
cmax=c[i];
}
for(i=0;i<m;i++)
{
scanf("%d",&wr[i]);
wmin=min(wmin,wr[i]);
}
int ans=cmax;
if(ans<wmin && ans>=2*cmin)
printf("%d\n",ans);
else if(2*cmin>=cmax && 2*cmin<wmin)
printf("%d\n",2*cmin);
else
printf("-1\n");
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | da6ee7d2ccece6b31b8011f4b66ebced | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int cmpfunc (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main() {
int i,n,m;
int minr,maxr,minw;
int r[100],w[100];
int num;
scanf("%d %d",&n,&m);
for (i=0 ; i<n ; i++) {
scanf("%d",&r[i]);
}
for (i=0 ; i<m ; i++) {
scanf("%d",&w[i]);
}
qsort(r, n, sizeof(int), cmpfunc);
qsort(w, m, sizeof(int), cmpfunc);
minr = r[0];
maxr = r[n-1];
minw = w[0];
int out = 2*minr;;
if (out < minw) {
if (maxr < minw) {
if (maxr > out) {
out = maxr;
}
} else {
out = -1;
}
} else {
out = -1;
}
printf("%d",out);
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 5171ed199230edbb41e04ee027674810 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int a[1000],b[1000],c,d,e,i,j,k,l,max=1,min=100,min1=100,n,m;
scanf("%d",&n);
scanf("%d",&m);
max=1;
min=100;
min1=100;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(j=0;j<m;j++)
{
scanf("%d",&b[j]);
}
for(k=0;k<n;k++)
{
if(a[k]>max)max=a[k];
if(a[k]<min1)min1=a[k];
}
for(l=0;l<m;l++)
{
if(b[l]<min)min=b[l];
}
if(max>=min)
{
printf("-1\n");
}
else if(2*min1>=min)
{
printf("-1\n");
}
else
{
for(c=max;c<min;c++)
{
if(c>=(2*min1))
{
if(c<0)
{
printf("-1\n");
}
else
{
printf("%d\n",c);
}
break;
}
}
}
return 0;
} | |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 0b165345388b3e7e6b396c3ca2d37733 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
#include<limits.h>
int fmax(int a,int b);
int main()
{
int n,m;
scanf("%d%d",&n,&m);
int a[n],b[m],i;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
/*if(a[i]>p)
p=a[i];
if(a[i]<v)
v=a[i];*/
}
for(i=0;i<m;i++)
{
scanf("%d",&b[i]);
/*if(b[i]<min)
min=b[i];*/
}
int j,temp;
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(i=0;i<m;i++)
{
for(j=0;j<m-i-1;j++)
{
if(b[j]>b[j+1])
{
temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
int c,v,p;
v=a[0];
p=a[n-1];
c=b[0];
int z=fmax((2*v),p);
if(z<c)
printf("%d",z);
else
printf("-1");
return 0;
}
int fmax(int a,int b)
{
if(a>b)
return a;
else
return b;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 4b01d408a97fcc46926d461c8beb2a20 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #define r(i,j) for(i=0;i++<j;)
#define s(a) scanf("%d",&a)
main(){int ans,a,b,v,m =101,n=-1,l=101,i;
s(a),s(b);r(i,a)s(v),(v>n)?n=v:0,(v<m)?m=v:0;r(i,b)s(v),(v<l)?l=v:0;
(m*2>n)?n=m*2:0;printf("%d",(n<l)?n:-1);return 0;} | |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 78cc6803b24e7076659dbb77b7a9691e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
#include<stdlib.h>
int max(int a,int b)
{
return (a>b?a:b);
}
int compare (const void * a, const void * b)
{
return ( *(long long int*)a - *(long long int*)b );
}
int main()
{
int n,m,i,d,j;
scanf("%d %d",&n,&m);
int a[n];
int b[m];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<m;i++)
scanf("%d",&b[i]);
qsort(a,n,sizeof(int),compare);
qsort(b,m,sizeof(int),compare);
if(2*a[0]>=b[0])
{
printf("-1\n");
goto exit;
}
else
{
d=max(2*a[0],a[n-1]);
if(d<b[0])
printf("%d\n",d);
else
printf("-1\n");
goto exit;
}
exit:
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | b31a5f96b48f4896b144f82740c6a223 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include <stdio.h>
int main()
{
int n, m, x1 = 0, y1 = 100, x2 = 0, y2 = 100, i;
scanf("%d %d", &n, &m);
for (i = 0; i < n; i++) {
int x;
scanf("%d", &x);
if (x > x1) x1 = x;
if (x < y1) y1 = x;
}
for (i = 0; i < m; i++) {
int x;
scanf("%d", &x);
if (x > x2) x2 = x;
if (x < y2) y2 = x;
}
if (x1 >= y2 || y1 * 2 >= y2) {
puts("-1");
} else if (x1 > y1 * 2) {
printf("%d\n", x1);
} else {
printf("%d\n", y1 * 2);
}
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 30900a122255b599af479ddb4f9936eb | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
#include<stdlib.h>
#define BUF 4096
#define true 1
#define false 0
typedef int bool;
char ibuf[BUF];
int ipt = BUF;
long long readint();
int main()
{
int n,m;
int maxcor=0,mincor=300,tmp;
int maxwrg=0,minwrg=300;
n=readint();
m=readint();
while(n--)
{
tmp=readint();
if(tmp>maxcor)
maxcor=tmp;
if(tmp<mincor)
mincor=tmp;
}
while(m--)
{
tmp=readint();
if(tmp<minwrg)
minwrg=tmp;
if(tmp>maxwrg)
maxwrg=tmp;
}
int twicelt=2*mincor;
if(twicelt<maxcor)
twicelt=maxcor;
if(twicelt>=minwrg)
printf("-1");
else
printf("%d",twicelt);
return 0;
}
long long readint() {
while (ipt < BUF && ibuf[ipt] < '0') ipt++;
if (ipt == BUF)
{
fread(ibuf, 1, BUF, stdin);
ipt = 0;
while (ipt < BUF && ibuf[ipt] < '0') ipt++;
}
long long n = 0;
while (ipt < BUF && ibuf[ipt] >= '0') n = (n*10)+(ibuf[ipt++]-'0');
if (ipt == BUF)
{
fread(ibuf, 1, BUF, stdin);
ipt = 0;
while (ipt < BUF && ibuf[ipt] >= '0') n = (n*10)+(ibuf[ipt++]-'0');
}
return n;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | e374fcc01450341c6187887eb6f26c88 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int main()
{
int max=0;
int min1=1000000;
int min2=1000000;
int n,m,i;
scanf("%d %d",&n,&m);
int c[n],w[m];
for(i=0;i<n;i++)
{
scanf("%d",&c[i]);
if(c[i]>max)
{
max=c[i];
}
if(c[i]<min1)
{
min1=c[i];
}
}
for(i=0;i<m;i++)
{
scanf("%d",&w[i]);
if(w[i]<min2)
{
min2=w[i];
}
}
while(min1>max/2)
{
max=max+1;
}
if(max<min2)
{
printf("%d\n",max);
}
else
{
printf("-1\n");
}
return 0;
}
| |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | 5e2e54161a7e4d21e05d0b78b3f2c4e2 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int main(void)
{
int n,m,i,t,max1=0,min1=101,max2=0,min2=101,v;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&t);
if(t>=max1)
max1=t;
if(t<=min1)
min1=t;
}
for(i=0;i<m;i++)
{
scanf("%d",&t);
if(t>=max2)
max2=t;
if(t<=min2)
min2=t;
}
v=2*min1;
if(v<max1)
v=max1;
if(v<min2)
printf("%d\n",v);
else
printf("-1\n");
return 0;
} | |
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2aββ€βv holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some "extra" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist. | If there is a valid TL value, print it. Otherwise, print -1. | C | 49c47ebfd710a3733ce7ecb3a3c134a7 | ef35d0d4a9c0bde9a382bae3f05aed2c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"brute force"
] | 1380641400 | ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n, m (1ββ€βn,βmββ€β100). The second line contains n space-separated positive integers a1,βa2,β...,βan (1ββ€βaiββ€β100) β the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,βb2,β...,βbm (1ββ€βbiββ€β100) β the running time of each of m wrong solutions in seconds. | ["5", "-1"] | #include<stdio.h>
int main()
{
int n,m,i,nn[100],mm[100],minn,max,minm,temp;
scanf("%d %d",&n,&m);
scanf("\n%d",&nn[0]);
for(i=1;i<n;i++)
scanf(" %d",&nn[i]);
scanf("\n%d",&mm[0]);
for(i=1;i<m;i++)
scanf(" %d",&mm[i]);
minn=nn[0];max=nn[0];
for(i=1;i<n;i++)
{
if(nn[i]>max)
max=nn[i];
if(nn[i]<minn)
minn=nn[i];
}
minm=mm[0];
for(i=1;i<m;i++)
{
if(mm[i]<minm)
minm=mm[i];
}
temp=2*minn<=max?max:2*minn;
if(temp>=minm)
printf("-1");
else
printf("%d",temp);
return 0;
} | |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 7794aaf71a47ed9be813799990f40d39 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
#include <math.h>
int main()
{
double v1,t,s,d,h,v,e,v2;
double pi=2*acos(0.0);
scanf ("%lf%lf%lf%lf",&d,&h,&v,&e);
v1=(pi*(d/2.0)*(d/2.0)*h);
v2=(pi*(d/2.0)*(d/2.0)*e);
if(v>v2)
{
s=v-v2;
s=v1/s;
printf ("YES\n%.12lf\n",s);
}
else
{
printf ("NO\n");
}
return 0;
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 5306354d13745b9afb6ea3aefb9d122d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
int main(){
double d,h,v,e;
double g;
scanf("%lf%lf%lf%lf",&d,&h,&v,&e);
if(e*0.78539816339*d*d >= v) {
printf("NO\n");
}
else {
g = h/((v/(0.78539816339*d*d)) - e);
printf("YES\n");
printf("%lf\n",g);
}
return 0;
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | d328e728c932ad4ba8a4b7ff77771a73 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
#define pi 3.14159265
int main()
{
float d,h,v,e,r;
scanf("%f%f%f%f",&d,&h,&v,&e);
r=d/2;
if((v/(r*r)*pi)-e<=0)
printf("NO");
else
printf("YES\n%f",h/((v/((r*r)*pi)-e)));
return 0;
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 7ded62b63c895990bcf880eaa1c3496e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
#define PI 3.14159265358979323846264338327950
int main(void) {
int d, h, v, e;
double r;
scanf("%d %d %d %d", &d, &h, &v, &e);
r = d / 2.;
if (PI * r * r * e > v)
puts("NO");
else
printf("YES\n%.12f\n", PI * r * r * h / (v - PI * r * r * e));
return 0;
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 6bb4ad294804a47410dac4020ab9fcc4 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include "stdio.h"
#define pi 3.14159265359
int main(int argc, char const *argv[])
{
double d, h, v, e;
while(~scanf("%lf %lf %lf %lf", &d, &h, &v, &e))
{
e=e*pi*(d/2)*(d/2);
if(e>=v)
{
puts("NO");
}
else
{
printf("YES\n%.12f\n", pi*h*(d/2)*(d/2)/(v-e));
}
}
return 0;
} | |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 3eafeed6acb46ff3da6b93e11df8b2a9 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define pi 3.1415926
int main()
{
double d, h, v, e;
double oriV, incV, decV;
double baseSize;
double time;
scanf("%lf %lf %lf %lf", &d, &h, &v, &e);
baseSize = pi*d*d/4;
incV = e*baseSize;
decV = v;
if (incV>=decV)
{
printf("NO"); return 0;
}
printf("YES\n");
oriV = h*baseSize;
time = oriV/(v-incV);
printf("%f",time);
return 0;
} | |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 5112cb232ba184aee5809211e880e9de | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include<stdio.h>
int main ()
{
double a,b,c,d,x,r,p,t;
scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
x=3.14159265*(a/2)*d*(a/2);
if(x>=c)
{
printf("NO");
}
else
{
r=c-x;
p=3.14159265*(a/2)*(a/2)*b;
t=p/r;
printf("YES\n%.12lf",t);
}
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | c3aa3ec18f9cd8772a59334c14b89526 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
double d,h,v,e,V,s,val;
scanf("%lf %lf %lf %lf",&d,&h,&v,&e);
//e=E*2*pi*d*d/4;
double S;
double pi;
pi=3.1415926535897932;
S=(pi*d*d)/4;
V=v/S;
val=S*h;
s=h/(V-e);
if((V-e)<=0)
{
printf("NO");
return 0;
}
int i=1;
if(s>10000 || V<=0)
printf("NO");
else
printf("YES\n%.16lf",s);
return 0;
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | bf693c8c855911c6048a958da4050a0f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | /*******************************************************************************\
|*********S*** ****** ************* ************* ************** * ******|
|*********** ******** ************ ************ *********** ** ******|
|********* ********** *********** *** *********** * ********* *** ******|
|******** *********** *I******** **** ********** *** ***** ***** ******|
|******** *********** ********* ****** ********* ***** ** ****** ******|
|********** ********* ******** ***A**** ******** ******* ******** ******|
|*********** ******** ******* ********** ******* ***************** ******|
|********** ********* ****** ************ ****** ***************** ******|
|******** *********** ***** ************** ***** ********M******** ******|
|***** ************** **** **************** **** ***************** ******|
|*******************************************************************************|
|**************BSMRSTU********************************CSE***********************|
\*******************************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<conio.h>
#include<stdlib.h>
#define ll long long
#define pi 3.1415926
#define B break
#define C continue
#define sf scanf
#define pf printf
#define byebye return 0
int main()
{
float d,h,a,b;
sf("%f%f%f%f",&d,&h,&a,&b);
if(b>a){
pf("NO");
byebye;
}
else{
float v=(4*a)/(pi*d*d);
float t=h/(v-b);
if(t<=0)
pf("NO");
else{
pf("YES\n");
pf("%.12f",t);
}
}
byebye;
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | f2ba37473f341101e480bf2d0f095145 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
#include <math.h>
int main()
{
double d, h, v, e;
scanf("%lf%lf%lf%lf", &d, &h, &v, &e);
double s = M_PI * d * d / 4;
double hspd_pour = e;
double hspd_drink = v / s;
if (hspd_pour < hspd_drink - 1e-6) {
puts("YES");
double time = h / (hspd_drink - hspd_pour);
printf("%.12lf\n", time);
} else {
puts("NO");
}
return 0;
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 0da3413b5f8fe5e70113256afdefc2e6 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include<stdio.h>
double d,h,e,v;
int main()
{
double pi =3.14159265358979323846264338327950288;
scanf("%lf %lf %lf %lf",&d,&h,&v,&e);
if(4*v>d*d*e*pi){
printf("YES\n%.12lf",d*d*pi*h/(4*v-d*d*e*pi));
} else {
printf("NO");
}
return 0;
} | |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 538a735227fff64fe60634e1fbd6c4de | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
#include <math.h>
int main()
{
double pi=acos(-1);
double t,r;
int d,h,v,e;
scanf("%d %d %d %d", &d, &h, &v, &e);
r=v-(0.25*pi*d*d*e);
if(r>0)
{
t=(0.25*pi*d*d*h)/r;
if(t<=10000)
{
printf("YES\n");
printf("%lf", t);
}
else
printf("NO");
}
else
printf("NO");
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 12e15e3f38427b9b1249074fc7d3f5f7 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
int main()
{
int d,h,v,e;
scanf("%d%d%d%d",&d,&h,&v,&e);
double area;
area=h/((v/((3.1415926535*d*d)/(4.0)))-e);
if(area<0)
printf("NO");
else
{
if(area>10000)
printf("NO");
else
printf("YES\n%.12lf",area);
}
return 0;
}
| |
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter. | If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number β time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10β-β4. It is guaranteed that if the answer exists, it doesn't exceed 104. | C | fc37ef81bb36f3ac07ce2c4c3ec10d98 | 02c3613a45ff5480d0543795f68760bd | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"geometry",
"math"
] | 1461947700 | ["1 2 3 100", "1 1 1 1"] | NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in seconds. | PASSED | 1,100 | standard input | 1 second | The only line of the input contains four integer numbers d,βh,βv,βe (1ββ€βd,βh,βv,βeββ€β104), where: d β the diameter of your cylindrical cup, h β the initial level of water in the cup, v β the speed of drinking process from the cup in milliliters per second, e β the growth of water because of rain if you do not drink from the cup. | ["NO", "YES\n3.659792366325"] | #include <stdio.h>
//#define _USE_MATH_DEFINES // for C
//#include <math.h>
int main()
{
// your code goes here
double Pi=3.14159265358979323846;
int d,h,v,e;
scanf("%d %d %d %d",&d,&h,&v,&e);
double Sd=Pi*1.0*(d/2.0)*(d/2.0);
double s=(h*1.0)/((-e)*1.0+(v*1.0)/(Sd*1.0));
//print
if (s<(10*10*10*10*1.0) && (s>0.0) )
{
printf("YES \n");
printf("%4.12lf",s);
}
else
{
printf("NO");
}
return 0;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.