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
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
C
f00eb0452f5933103f1f77ef06473c6a
3e87959b0da98a7e222d2b688c23dbb7
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "number theory", "math" ]
1590327300
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
PASSED
1,300
standard input
2 seconds
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
["2\n8\n1\n999999733\n1"]
/* * Coder: @SumitRaut */ #include <stdio.h> #include <stdbool.h> #include <string.h> #include <limits.h> #include <math.h> int Min(int x,int y) { return y^((x^y)&-(x<y)); } int Max(int x,int y) { return y^((x^y)&-(y<x)); } void smin(int* a, int b) { if(*a>b) *a=b; } int main() { #ifndef ONLINE_JUDGE freopen(...
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
C
f00eb0452f5933103f1f77ef06473c6a
0c1d06b2dc577429c2edb9d449fb5b8b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "number theory", "math" ]
1590327300
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
PASSED
1,300
standard input
2 seconds
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
["2\n8\n1\n999999733\n1"]
#include<stdio.h> #include<stdlib.h> typedef long long int ll; int finddivisor(int n,int k) { int a=0; for(int i=1;i<=n/i;i++) { if(n%i==0) { if(i<=k) a=i>a?i:a; if((n/i)<=k) a=(n/i)>a?(n/i):a; } } return a; } int main() { i...
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
C
f00eb0452f5933103f1f77ef06473c6a
e249455c859a4111ad8db8cca6a350f5
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "number theory", "math" ]
1590327300
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
PASSED
1,300
standard input
2 seconds
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
["2\n8\n1\n999999733\n1"]
#include<stdio.h> #include<math.h> void pd(int n,int k) { int i,q1,q2,max=1; for (int i=sqrt(n); i>=1; i--) { if (n%i == 0) { q1=i; q2=n/i; if(q1>max && q1<=k) max=q1; if(q2>max && q2<=k) max=q2; } }...
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
C
f00eb0452f5933103f1f77ef06473c6a
16daf2e706658c2e8a0a4e61687d5ab5
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "number theory", "math" ]
1590327300
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
PASSED
1,300
standard input
2 seconds
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
["2\n8\n1\n999999733\n1"]
#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<limits.h> #define MOD 1000000007 #define PI 3.14159265 #define seive_len 1000001 int *array; int seive[seive_len]; int prime_prime[seive_len]; int min(int a, int b) { return a<b?a:b; } int max(int a, int b) { return a>b?a:b; } ...
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
C
f00eb0452f5933103f1f77ef06473c6a
fe187c83dffa630f650fc6b9bd7fcfb3
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "number theory", "math" ]
1590327300
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
PASSED
1,300
standard input
2 seconds
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
["2\n8\n1\n999999733\n1"]
#include<stdio.h> int main() { int t,j; scanf("%d",&t); for(j=0;j<t;j++) { int n,k,max=0,f=0; scanf("%d %d",&n,&k); int i; for(i=1;i*i<=n&&i<=k;i++) { if(n%i==0&&n/i<=k) { printf("%d\n",i); f=1; break; } else if(n%i=...
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
C
f00eb0452f5933103f1f77ef06473c6a
7d0a7072a6d821ccbc81b70229313f52
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "number theory", "math" ]
1590327300
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
PASSED
1,300
standard input
2 seconds
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
["2\n8\n1\n999999733\n1"]
#include "stdio.h" int factor(int a, int b) { int f = 1; for(int i = 2; i * i <= a && i <= b; i++) if(a % i == 0) { if(a / i <= b) { f = a / i; break; } else f = i; } return f; } int ma...
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
C
f00eb0452f5933103f1f77ef06473c6a
2dcab0f844c38febae5fbb31b93766f8
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "number theory", "math" ]
1590327300
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
PASSED
1,300
standard input
2 seconds
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
["2\n8\n1\n999999733\n1"]
#include <stdio.h> #include <stdlib.h> #define N 109 int min(int a, int b) { if (a<b) return a; return b; } // int cmpfunc (const void * a, const void * b) { // return ( *(int*)a - *(int*)b ); // } // qsort(values, 5, sizeof(int), cmpfunc); int main() { int t,n,k,i, ans; scanf("%d", &t); while (t--){ ...
You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \leq i \leq n$$$...
Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print "YES" (without quotes), otherwise print "NO" (without quotes). You can print either lowercase or uppercase letters in the answers.
C
08679e44ee5d3c3287230befddf7eced
f6cdc3e793de91b68bafd533818f732a
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1581604500
["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"]
NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes "bca", $$$b$$$ becomes "bca" and $$$c$$$ becomes "abc". Here the stri...
PASSED
800
standard input
1 second
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contain...
["NO\nYES\nYES\nNO"]
#include<stdio.h> #include<string.h> int main() { int t; scanf("%d",&t); while(t--) { int i=0,j; char a[101], b[101], c[101]; scanf("%s %s %s",a,b,c); for(int j=0;j<strlen(a);j++) { if(a[j]==c[j] || b[j]==c[j]) i++; } if (i==strlen(a)) printf("YES\n"); else prin...
You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \leq i \leq n$$$...
Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print "YES" (without quotes), otherwise print "NO" (without quotes). You can print either lowercase or uppercase letters in the answers.
C
08679e44ee5d3c3287230befddf7eced
4259c92871b308a13ad9ffc1e1599fc5
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1581604500
["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"]
NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes "bca", $$$b$$$ becomes "bca" and $$$c$$$ becomes "abc". Here the stri...
PASSED
800
standard input
1 second
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contain...
["NO\nYES\nYES\nNO"]
#include<stdio.h> #include<string.h> int main() { int t; scanf("%d",&t); while(t--) { char A[101],B[101],C[101]; int i,l; scanf("%s",A); l=strlen(A); scanf("%s",B); scanf("%s",C); for(i=0;i<l;i++) { if(C[i]!=A[i]&&C[i]!=B[i]) ...
You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \leq i \leq n$$$...
Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print "YES" (without quotes), otherwise print "NO" (without quotes). You can print either lowercase or uppercase letters in the answers.
C
08679e44ee5d3c3287230befddf7eced
13e91332c801f286c001b8c8110ac5fc
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1581604500
["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"]
NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes "bca", $$$b$$$ becomes "bca" and $$$c$$$ becomes "abc". Here the stri...
PASSED
800
standard input
1 second
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contain...
["NO\nYES\nYES\nNO"]
#include<stdio.h> #include<string.h> int main() { int t,i; char a[102],b[102],c[102]; scanf("%d",&t); while(t--) { scanf("%s",a); getchar(); scanf("%s",b); getchar(); scanf("%s",c); getchar(); for(i=0;i<strlen(c);i++) { if((a[i]==b[i]&&a[i]==c[i])||a[i]==c[i]||b[i]==c[i]) continue; else b...
You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \leq i \leq n$$$...
Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print "YES" (without quotes), otherwise print "NO" (without quotes). You can print either lowercase or uppercase letters in the answers.
C
08679e44ee5d3c3287230befddf7eced
a331f08d96119afad0d362c01ca21737
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1581604500
["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"]
NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes "bca", $$$b$$$ becomes "bca" and $$$c$$$ becomes "abc". Here the stri...
PASSED
800
standard input
1 second
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contain...
["NO\nYES\nYES\nNO"]
#include<stdio.h> #include<string.h> int main() { int t,i; char a[102],b[102],c[102],ch1,ch2,ch3; scanf("%d",&t); while(t--) { scanf("%s",a); getchar(); scanf("%s",b); getchar(); scanf("%s",c); getchar(); for(i=0;i<strlen(c);i++) { if((a[i]==b[i]&&a[i]==c[i])||a[i]==c[i]||b[i]==c[i]) continu...
You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \leq i \leq n$$$...
Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print "YES" (without quotes), otherwise print "NO" (without quotes). You can print either lowercase or uppercase letters in the answers.
C
08679e44ee5d3c3287230befddf7eced
b38baa416f7071c3b7047298ea4d5c65
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1581604500
["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"]
NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes "bca", $$$b$$$ becomes "bca" and $$$c$$$ becomes "abc". Here the stri...
PASSED
800
standard input
1 second
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contain...
["NO\nYES\nYES\nNO"]
#include <stdio.h> #include <stdlib.h> #include <string.h> char a[100], b[100], c[100]; void check () { int i; scanf("%s %s %s", a, b, c); for (i = 0; i < strlen(a); i++) { if (c[i] != a[i] && c[i] != b[i]) { printf ("NO\n"); return; } } printf ("YES\n"); return; } int mai...
You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \leq i \leq n$$$...
Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print "YES" (without quotes), otherwise print "NO" (without quotes). You can print either lowercase or uppercase letters in the answers.
C
08679e44ee5d3c3287230befddf7eced
cc66d3273c0d9e39d54818481223404f
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1581604500
["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"]
NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes "bca", $$$b$$$ becomes "bca" and $$$c$$$ becomes "abc". Here the stri...
PASSED
800
standard input
1 second
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contain...
["NO\nYES\nYES\nNO"]
#include<stdio.h> #include<string.h> int main() { int t; scanf("%d",&t); while(t--){ int cnt=0; char a[1000]; char b[1000]; char c[1000]; scanf("%s",a); scanf("%s",b); scanf("%s",c); for(int i=0;i<strlen(a);i++){ if(c[i]!=a[i] && c[i]!=b[i]){ printf("NO\n"); cnt++; break; } } if...
You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \leq i \leq n$$$...
Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print "YES" (without quotes), otherwise print "NO" (without quotes). You can print either lowercase or uppercase letters in the answers.
C
08679e44ee5d3c3287230befddf7eced
7b5d276de6a33324ee1ed9b577c8b74a
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1581604500
["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"]
NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes "bca", $$$b$$$ becomes "bca" and $$$c$$$ becomes "abc". Here the stri...
PASSED
800
standard input
1 second
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contain...
["NO\nYES\nYES\nNO"]
#include<stdio.h> #include<string.h> int main() { int n; scanf("%d",&n); while(n--) { char a[101],b[101],c[101]; scanf("%s%s%s",a,b,c); int x; x=strlen(c); for(int i=0;i<x;i++){ if(c[i]!=b[i] && c[i]!=a[i]){ ...
You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \leq i \leq n$$$...
Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print "YES" (without quotes), otherwise print "NO" (without quotes). You can print either lowercase or uppercase letters in the answers.
C
08679e44ee5d3c3287230befddf7eced
ff236d163b9e076cfa4d873cdf40fe18
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1581604500
["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"]
NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes "bca", $$$b$$$ becomes "bca" and $$$c$$$ becomes "abc". Here the stri...
PASSED
800
standard input
1 second
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contain...
["NO\nYES\nYES\nNO"]
#include<stdio.h> #include<string.h> int main() { char a[210],b[200],c[200]; int t,z=0,i,j,l; scanf("%d",&t); for(j=0;j<t;j++) { scanf("%s",a); scanf("%s",b); scanf("%s",c); l=strlen(a); for(i=0;i<l;i++) { if(a[i]!=c[i]&&b[i]!=c[i]) ...
You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n points, which area exceeds S.Alyona tried to construct a triangle with integer coordinates, which contains all n points and which area doesn't exceed 4S, but, by obvious...
Print the coordinates of three points — vertices of a triangle which contains all n points and which area doesn't exceed 4S. Coordinates of every triangle's vertex should be printed on a separate line, every coordinate pair should be separated by a single space. Coordinates should be an integers not exceeding 109 by ab...
C
d7857d3e6b981c313ac16a9b4b0e1b86
efdcd4dbe6a0b7a628c6a257431ee4e7
GNU C
standard output
256 megabytes
train_002.jsonl
[ "two pointers", "geometry" ]
1466181300
["4 1\n0 0\n1 0\n0 1\n1 1"]
Note
PASSED
2,600
standard input
3 seconds
In the first line of the input two integers n and S (3 ≤ n ≤ 5000, 1 ≤ S ≤ 1018) are given — the number of points given and the upper bound value of any triangle's area, formed by any three of given n points. The next n lines describes given points: ith of them consists of two integers xi and yi ( - 108 ≤ xi, yi ≤ 108)...
["-1 0\n2 0\n0 2"]
// Long time no C! #include <stdio.h> #define MAXN 5005 typedef long long int64; int64 abs(int64 x) { return x > 0 ? x : -x; } int n; int x[MAXN], y[MAXN]; //int64 s; int64 area(int i, int j, int k) { return abs( (int64)(x[j] - x[i]) * (y[k] - y[i]) - (int64)(y[j] - y[i]) * (x[k] - x[i])); } int ...
You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n points, which area exceeds S.Alyona tried to construct a triangle with integer coordinates, which contains all n points and which area doesn't exceed 4S, but, by obvious...
Print the coordinates of three points — vertices of a triangle which contains all n points and which area doesn't exceed 4S. Coordinates of every triangle's vertex should be printed on a separate line, every coordinate pair should be separated by a single space. Coordinates should be an integers not exceeding 109 by ab...
C
d7857d3e6b981c313ac16a9b4b0e1b86
1fc6fad98927020e23883e6670b26dc3
GNU C
standard output
256 megabytes
train_002.jsonl
[ "two pointers", "geometry" ]
1466181300
["4 1\n0 0\n1 0\n0 1\n1 1"]
Note
PASSED
2,600
standard input
3 seconds
In the first line of the input two integers n and S (3 ≤ n ≤ 5000, 1 ≤ S ≤ 1018) are given — the number of points given and the upper bound value of any triangle's area, formed by any three of given n points. The next n lines describes given points: ith of them consists of two integers xi and yi ( - 108 ≤ xi, yi ≤ 108)...
["-1 0\n2 0\n0 2"]
#include <stdio.h> #include <stdlib.h> long long int *x, *y; static long long int area(int a, int b, int c) { long long int S; S = (x[a] - x[c]) * (y[b] - y[c]) - (y[a] - y[c]) * (x[b] - x[c]); if(S < 0) S = -S; return S; } int main() { int n, i, a, b, c; long long int S, T; scanf("%d%*s", &n); x = malloc(...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
ab123d4ab5c81d5b3dbe188f07e05a75
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int qcase,l1,l2,r1,r2; scanf("%d",&qcase); while(qcase--) { scanf("%d %d %d %d",&l1,&r1,&l2,&r2); printf("%d %d\n", r1, r1 != l2 ? l2 : r2); } return 0; }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
272c989fec58204d7de46a4c71f9df8d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main(){ int l1, l2, r1, r2; int p, i; scanf("%d", &p); for(i = 0; i < p; i++){ scanf("%d%d%d%d", &l1, &r1, &l2, &r2); if(l1==l2&&r1==r2){ printf("%d %d", r1, l1); }else if(l1==l2&&r1!=r2){ printf("%d ", l1); if(r1 < r2){ printf("%d", r1); }else{ printf("%d", r2); ...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
bc9970d54991cd50d6f551809365ec93
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> main() { int n, a, b, c, d, i, j; scanf("%d", &n); while (n--) { scanf("%d%d%d%d", &a, &b, &c, &d); for (i = a; i <= b; i++) { for (j = c; j <= d; j++) if (i != j) { printf("%d %d\n", i, j); break; } break; } } }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
fa3b7941ce5b800a5daa4a6180521057
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int a,b,c,d,t,i=0; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d%d%d%d",&a,&b,&c,&d); if(a==c) a++; printf("%d %d\n",a,c); } return 0; }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
70faab091f4a732cc212d1b652e3513f
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int n; scanf("%d",&n); int i; for(i=0;i<n;i++) { int num1,num2,num3,num4; scanf("%d %d %d %d",&num1,&num2,&num3,&num4); if(num1==num3&&num2==num4) { printf("%d %d",num1,num2); printf("\n"); } else if(num1!=num3) { printf("%d %d",num1,num3); printf("\n"); }...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
f3af6d78e2ddaaa95acffd5e8cd1646d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include <stdio.h> int main(){ int n; scanf("%d", &n); while(n--){ int l1, r1, l2, r2; scanf("%d %d", &l1, &r1); scanf("%d %d", &l2, &r2); if(l1!=r2){ printf("%d %d", l1, r2); } else if(l1==r2){ printf("%d ", l1); int ans; if(l2>r2){ ans=r2; } else{ ans=l2; } if(...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
9facb9cde6e3f00e078ce50b187132b4
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include <stdio.h> int main(){ int n, l1, r1, l2, r2; scanf("%d", &n); while(n--){ scanf("%d %d\n%d %d", &l1, &r1, &l2, &r2); if(l1 == r1){ printf("%d %d\n", l1, l1 != l2 ? l2 : r2); } else{ printf("%d %d\n", l2 != l1 ? l1: r1, l2); } } }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
310003e6f11602221eaf505a0ac6ffcd
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include <stdio.h> #include <stdlib.h> int main() { int n; scanf("%d",&n); for (int i = 0; i < n; ++i) { int a,b,c,d,min=0; scanf("%d%d%d%d",&a,&b,&c,&d); if (a!=d) { printf("%d %d",a,d ); } else if (a==d) { printf("%d %d",a,c ); } printf("\n"); } }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
1d527c20c73a79794b9942e484be14da
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int n,l,r,L,R; scanf("%d",&n); while(n--) { scanf("%d%d%d%d",&l,&r,&L,&R); if(l!=R) { printf("%d %d\n",l,R); } else { printf("%d %d\n",r,L); } } } //sayeedi mottakin
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
4228a857a7d65aae80ad917b8989858c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int l1,r1,l2,r2; int q1,q2; int n; int i; scanf("%d",&n); for(i=0; i<n; i++) { scanf("%d %d %d %d",&l1,&r1,&l2,&r2); q1=l1; q2=l2; if(q1==q2) { q2=l2+1; } printf("%d %d\n",q1,q2); } return 0; }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
d139b78be0696c99842e749fbd506d37
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
// Two Distinct Point #include<stdio.h> int main(void) { int Q; long int l1, l2, r1, r2; scanf("%d", &Q); while (Q--) { scanf("%ld%ld%ld%ld", &l1, &r1, &l2, &r2); if (l1 != r2) printf("%ld %ld\n", l1, r2); else { printf("%ld %ld\n", r1, l2); } } }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
4c82aa2fea81c85ab58d414318033ba9
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { long int l1,r1,l2,r2; int i,q; scanf("%d",&q); for(i=0;i<q;i++) { scanf("%ld %ld %ld %ld",&l1,&r1,&l2,&r2); if(l1==r2) printf("%ld %ld\n",l1,l2); else printf("%ld %ld\n",l1,r2); } return 0; }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
acaee453c76a2dae32eb124a5ef7e1b6
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int t; scanf("%d",&t); int l1,r1,l2,r2; while(t-->0) { scanf("%d%d%d%d",&l1,&r1,&l2,&r2); int b=r2; for(int a=l1;a<=r1 && b>=l2;a++,b--) { if(a!=b) { printf("%d %d\n",a,b); break; ...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
c8b194e380077b1cc8568ac8caf8254b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int a,b,x,y; scanf("%d%d%d%d",&a,&b,&x,&y); if(a>x&&b<y) printf("%d %d",a,y); else if(a<x&&b<y) printf("%d %d",a,y); else if(a>x&&b>y) printf("%d %d",b,x); else if(a==x&&b==y) printf("%d %d",a,y);...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
2caea3cbff324a3352f7809da54d2799
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int i,j,k,l,n,f,a,b; scanf("%d",&n); for(f=1;f<=n;f++) { scanf("%d%d%d%d",&i,&j,&k,&l); a=(i+j)/2; b=(k+l)/2; if(a!=b) { printf("%d ",a); printf("%d\n",b); } else { printf("%d ",a+1); printf("%d\n",b); } } return 0; }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
9668643d54cf45ab4a8e95fb10c5a60c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main(){int a[500],b[500],c[500],d[500]; int g,h; scanf("%d",&g); for(h=0;h<g;h++){ scanf("%d%d%d%d",&a[h],&b[h],&c[h],&d[h]); } for(h=0;h<g;h++) { {if (a[h]!=d[h]) {printf("%d %d",a[h],d[h]); printf("\n"); continue ;} if(b[h]!=c[h]) {printf("%d %d",b[h],c[h]); printf("\n"); continue;}...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
df35c667fe488a79f8bcbd1d9f4dca0c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include <stdio.h> #include <math.h> int main() { long long int j,p,i,t,l1,l2,r1,r2,c=0,d=0; scanf("%lld",&t); for(i=1;i<=t;i++) { scanf("%lld %lld %lld %lld",&l1,&r1,&l2,&r2); if(l1!=l2){ printf("%lld %lld\n",l1,l2); } else if(l1==l2) { printf("%lld %lld\n",l1,l2+1); } } ...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
0da7d7d904de392ffa9d2b9c4cdcce9d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int q,a,b,c,d,i; scanf("%d",&q); for(i=1;i<=q;i++) { scanf("%d%d%d%d",&a,&b,&c,&d); if(c<=b&&d>=b) { if(a==b) printf("%d %d\n",a,b-1); else printf("%d %d\n",a,b); } ...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
40547659886d45104b37721193a24db8
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main() { int n; scanf("%d",&n); int a,b,c,d; while(n--){ scanf("%d%d%d%d",&a,&b,&c,&d); if(a==c) { if(b>a) printf("%d %d\n",a+1,c); else printf("%d %d\n",a,c+1); } else printf("%d %d\n",a,c); } }
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
95d47d29015aaa1cfe5a241d5a636d4c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include <stdio.h> int main(){ int q,L1[500],L2[500],R2[500],R1[500],m[500]; int i,t,h=0,hh=0,tt; scanf("%d",&q); for (i=1;i<=q;i++) scanf("%d%d%d%d",&L1[i],&R1[i],&L2[i],&R2[i]); for (i=1;i<=q;i++){ h=L1[i]; if (L1[i]==R2[i]) hh=L2[i]; else hh=R2[i]; printf("%d %d\n",h,hh); } re...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
d8bd67a781d9386c5f860938b8588c9b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include <stdio.h> int main() { int q; scanf("%d",&q); while(q--) { int l1,r1,l2,r2; scanf("%d %d %d %d",&l1,&r1,&l2,&r2); int a=(l1+r1)/2,b=(l2+r2)/2; int c=(l1+r1+1)/2,d=(l2+r2+1)/2; int e=(l1+r1-1)/2,f=(l2+r2-1)/2; if(a!=b) { printf(...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
a4d6a07d55fb5dbaa1c87e1969f9a6d8
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include<stdio.h> int main(){ int n; scanf("%d", &n); int i, l1, r1, l2, r2; for(i=0; i<n; i++){ scanf("%d%d%d%d", &l1, &r1, &l2, &r2); if(l1 != l2) printf("%d %d\n", l1, l2); else if(l1 == l2 && r1 != r2) printf("%d %d\n", r1, r2); else printf("%d %d\n", l1, r1); }...
You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 &lt; r_1$$$ and $$$l_2 &lt; r_2$$$. Segments may intersect, overlap or even coincide with each other. The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$...
Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers,...
C
cdafe800094113515e1de1acb60c4bb5
4dbda4534e12f5aa8da80d5b6e151569
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation" ]
1548254100
["5\n1 2 1 2\n2 6 3 4\n2 4 1 3\n1 2 1 3\n1 4 5 8"]
null
PASSED
800
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} &lt; r_{1_i}, l_{2_i} &lt; r_{2_i}$$$) — the en...
["2 1\n3 4\n3 2\n1 2\n3 7"]
#include <stdio.h> int main() { int l1,r1,l2,r2,q,a,b,i; scanf("%d",&q); for(i=0;i<q;i++){ scanf("%d%d%d%d",&l1,&r1,&l2,&r2); a=l1,b=l2; if(a==b) b=++l2; printf("%d %d\n",a,b); } return 0; }
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
4d0e1bdd5d244ed0eab9ff46c74a54e6
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include <stdio.h> #include <stdlib.h> #include<string.h> int main() { short n,k=0,i,j,m,flag=0,flag1=0; int big,u=0,sum=0,pos; scanf("%d",&n); pos=n; char **name=(char **)malloc(sizeof(char *)*n); char **name1=(char **)malloc(sizeof(char *)*n); int *pts=(int *)malloc(sizeof(int)*n); in...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
963123304163a8cc036afcc65cb69c84
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include<stdio.h> #include<string.h> struct game { char nm[35]; int pnt; }rnd[1005]; int tt(char name[],int n) { int i,sum=0; for (i=0;i<=n;i++) { if(strcmp(name,rnd[i].nm)==0) { sum+=rnd[i].pnt; } } return sum; } int main() { int n,pt,len=0,k,i,j; ...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
754c4f8b375d983061c172ad48cd81ed
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include<stdio.h> #include<string.h> struct order{ int num; int i; }command[1005]; int main(){ char name[1005][100]; int num[1005]; char peo[100]; int k, n, i, j, m = 0; int max=0; int time = 1005; scanf("%d",&n); for(j=0;j<n;j++){ scanf("%s%d",peo,&k); for(i=0;i...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
f54111b02013ff7ed9c46acb6dc8e1a5
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include<stdio.h> #define true 1 #define false 0 #define is_max_col 0 #define total_score_col 1 #define number_of_index_col 2 #define unique_index_col 3 int main(){ typedef int bool; int n,i,j,score[1000],person,count=1,k=0,max; int round_table[1000][1003]={0,},winner_index,f=unique_index_col,row,more_max=...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
5a343b4eca1352a783cf5dbebe21d235
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include<stdio.h> #include<stdlib.h> #include<string.h> #define HM 107 struct dict{ char name[34]; int points[1000]; int sum; int index[1000]; int total; }; struct table{ struct dict *D; int entry; }; int hash(char *name){ int i=0; int sum=0; while(name[i]){ sum=(sum*...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
1eaf55ffadc0f9fff09c8c150407320e
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include<stdio.h> #include<string.h> int n,m,x,u,max,i,ii,j,h[1002],hh[1002],hhh[1002],d,max; char a[1002][34],b[34]; int main() { scanf("%d",&n); scanf("%s %d",a[u++],&x); h[0]+=x; hh[0]=x; for(i=1;i<n;i++) { scanf("%s %d",b,&x); for(j=0;j<u;j++) { if(strcmp(b,a[j])==0) break; } if(j==u) { ...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
eb30b645e6074f7c285db487c41ca770
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { int n, m; int i = 0, j = 0, k = 0; struct nameSorceSt { char name[33]; int sorce; }; struct nameSorceSt nameSorce[1000] = {{0, 0}}; struct nameSorceSt nameSorce2[1000] = {{0, 0}}; struct maxSorceSt...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
f3cb7b1480e24721a4039f8856ff863c
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n,i,j,max=-200000000,score[1000],t=0,dew[1000],a=0; int score2[1000]; char name[1000][50]; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%s",name[i]); scanf("%d",&dew[i]); if(i==1) { ...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
61631a613afeff99d478f6cab11ed55b
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include <stdio.h> struct _game { char name[33]; int score; }; int number = 0; struct _game data[1000]; struct _game game[1000]; struct _game game2[1000]; int max_iis[1000]; int max_iis_number = 0; int main(void) { int nn = 0; int ii = 0; scanf("%d", &nn); for(; ii < nn; ii ++) { ...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
b7e83e8a5ca51c0e00fe1846d317b728
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include <stdio.h> #include <string.h> //û������������ˣ��������� char s[1005][40]; int a[1005];//������¼����ֵ int a1[1005];//������¼ÿһ����ͻ��ֵ int a2[1005];//������¼ÿһ����ͻ��ֵ�Ƿ������ĸ�ֵ��ͻ�� int main() { int n; int i,j; int max; scanf("%d\n", &n); for (i = 0; i < n; i++) { scanf("%s%d", &s[i], &a[i]); } fo...
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
Print the name of the winner.
C
c9e9b82185481951911db3af72fd04e7
35752214c78686b5c0123a38c047f430
GNU C
standard output
64 megabytes
train_002.jsonl
[ "implementation", "hashing" ]
1267117200
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
null
PASSED
1,500
standard input
1 second
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
["andrew", "andrew"]
#include<stdio.h> #include<string.h> #include<stdlib.h> struct name { char ch[33]; int m; }; int main() { int n,a; scanf("%d",&n); char na[33];int s; struct name mt[1001],nt[1001]; int i; scanf("%s %d",mt[0].ch,&mt[0].m); strcpy(nt[0].ch,mt[0].ch); nt[0].m=mt[0].m; int max=mt[0].m; int k=0,j; for(i=1;i<...
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.Let number i be in positions xi, yi (xi &lt; yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the val...
Print 2n integers — the permuted array a that minimizes the value of the sum s.
C
c234cb0321e2bd235cd539a63364b152
b058b77dc09eeba36e21e7157e127be3
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms" ]
1455116400
["2", "1"]
null
PASSED
1,900
standard input
1 second
The only line contains integer n (1 ≤ n ≤ 5·105).
["1 1 2 2", "1 1"]
#include<stdio.h> int main() { int n; int i = 1; scanf("%d", &n); while(i<n) { printf("%d ", i); i+=2; } i-=2; if((n&1) && n!=i) printf("%d ", n); while(i>0) { printf("%d ", i); i-=2; } i = 2; while(i<n) { printf("%d ", i); i+=2; } i-=2; if((!(n&1)) && n!=i) printf("%d ", n); while(i>0) ...
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.Let number i be in positions xi, yi (xi &lt; yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the val...
Print 2n integers — the permuted array a that minimizes the value of the sum s.
C
c234cb0321e2bd235cd539a63364b152
018e8c5b2e4ddb57d3402d8b65d15257
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms" ]
1455116400
["2", "1"]
null
PASSED
1,900
standard input
1 second
The only line contains integer n (1 ≤ n ≤ 5·105).
["1 1 2 2", "1 1"]
#include<stdio.h> int arr[1000000]; int main() { int n,even,odd=0,i; scanf("%d",&n); even=n; for(i=1;i<n;i++) { if(!(i&1)) { arr[even]=arr[even+n-i]=i; even++; } else { arr[odd]=arr[odd+n-i]=i; odd++; } } arr[2*n-1]=n; if(n&1) arr[(n-1)/2]=n; else arr[(3*(n)-2)/2]=n; for(i=0;i<2*n;i...
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.Let number i be in positions xi, yi (xi &lt; yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the val...
Print 2n integers — the permuted array a that minimizes the value of the sum s.
C
c234cb0321e2bd235cd539a63364b152
ae57a7fb2c0a14c3ad79adbdc84dd7a2
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms" ]
1455116400
["2", "1"]
null
PASSED
1,900
standard input
1 second
The only line contains integer n (1 ≤ n ≤ 5·105).
["1 1 2 2", "1 1"]
#include <stdio.h> #define N 500000 int main() { static int aa[N * 2]; int n, i, j, a; scanf("%d", &n); for (a = 1, i = 0, j = n - 1; i < j; a += 2, i++, j--) aa[i] = aa[j] = a; for (a = 2, i = n, j = n * 2 - 2; i < j; a += 2, i++, j--) aa[i] = aa[j] = a; aa[n * 2 - 1] = n; if (n % 2 == 1) aa[(n - 1) / ...
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.Let number i be in positions xi, yi (xi &lt; yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the val...
Print 2n integers — the permuted array a that minimizes the value of the sum s.
C
c234cb0321e2bd235cd539a63364b152
1993f3c3ee6e1cb1bdeef0acd9c6c0af
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms" ]
1455116400
["2", "1"]
null
PASSED
1,900
standard input
1 second
The only line contains integer n (1 ≤ n ≤ 5·105).
["1 1 2 2", "1 1"]
#include <stdio.h> #include <stdlib.h> int mat[1000010]; int main () { int n; int x; int i; scanf("%d", &n); if (n == 1) { printf("1 1\n"); } else if (n == 2) { printf("1 1 2 2\n"); } else { int i1 = (n - 1) / 2, i2 = n + (n - 2) / 2; x = 1; for (i = 0; i < 2 * n; i++) { if (i <= i1) { ...
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.Let number i be in positions xi, yi (xi &lt; yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the val...
Print 2n integers — the permuted array a that minimizes the value of the sum s.
C
c234cb0321e2bd235cd539a63364b152
f5a60f0fa42ea01c7b50443a81886d88
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms" ]
1455116400
["2", "1"]
null
PASSED
1,900
standard input
1 second
The only line contains integer n (1 ≤ n ≤ 5·105).
["1 1 2 2", "1 1"]
#include<stdio.h> int main() { int n; int i = 1; scanf("%d", &n); while(i<n) { printf("%d ", i); i+=2; } i-=2; if((n&1) && n!=i) printf("%d ", n); while(i>0) { printf("%d ", i); i-=2; } i = 2; while(i<n) { printf("%d ", i); i+=2; } i-=2; if((!(n&1)) && n!=i) printf("%d ", n); while(i>0) ...
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.Let number i be in positions xi, yi (xi &lt; yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the val...
Print 2n integers — the permuted array a that minimizes the value of the sum s.
C
c234cb0321e2bd235cd539a63364b152
962c5473feb957be6d45baa30dedcfed
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms" ]
1455116400
["2", "1"]
null
PASSED
1,900
standard input
1 second
The only line contains integer n (1 ≤ n ≤ 5·105).
["1 1 2 2", "1 1"]
#include <stdio.h> int main() { int n; scanf("%d",&n); int a[2*n],i; for(i=0;i<2*n;i++) a[i] = n; for(i =1;i<n;i++) { int x ; if(i & 1) x = i>>1; else x = (n-1) + (i>>1); int y = n-i + x; a[x] = a[y]= i; // = i; } for(i=0;i<2*n;i++) { printf("%d ",a[i]); } return 0; }
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.Let number i be in positions xi, yi (xi &lt; yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the val...
Print 2n integers — the permuted array a that minimizes the value of the sum s.
C
c234cb0321e2bd235cd539a63364b152
e3fd5b5bc73a0e807ef9802e8cc8eabf
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms" ]
1455116400
["2", "1"]
null
PASSED
1,900
standard input
1 second
The only line contains integer n (1 ≤ n ≤ 5·105).
["1 1 2 2", "1 1"]
/* f(i) = abs((n - i) * Di - (n - i)^2) s = sigma i from [1, n] : f(i) best Di = n - i Yi = Xi + Di = Xi + n - i let n = 10 D1 = 9 D2 = 8 D3 = 7 D4 = 6 D5 = 5 D6 = 4 D7 = 3 D8 = 2 D9 = 1 D10 = 0 <- impossible, but f(n) = 0 anyway 9 9 9 9 8 10 8 7 9 9 7 8 10 8 7 9 9 7 6 8 10 8 6 . . . 1 3 5 7 9 9 7 ...
You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.Let number i be in positions xi, yi (xi &lt; yi) in the permuted array a. Let's define the value di = yi - xi — the distance between the positions of the number i. Permute the numbers in array a to minimize the val...
Print 2n integers — the permuted array a that minimizes the value of the sum s.
C
c234cb0321e2bd235cd539a63364b152
3fb7863f6d43f93f764d77a08670f2bb
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms" ]
1455116400
["2", "1"]
null
PASSED
1,900
standard input
1 second
The only line contains integer n (1 ≤ n ≤ 5·105).
["1 1 2 2", "1 1"]
#include <stdio.h> int main() { int n,i; scanf("%d",&n); if(n%2==0){ for(i=1;i<n;i+=2) printf("%d ",i); for(i=n-1;i>0;i-=2) printf("%d ",i); for(i=2;i<=n;i+=2) printf("%d ",i); for(i=n-2;i>0;i-=2) printf("%d ",i); printf("%d",n); } else{ for(i=1;i<=...
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
22cd41752470442dd4d34cd674ac8fbb
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include<stdio.h> int main() { unsigned long long int n,temp,r1,r2,r3,i,f=0; unsigned long long int r; unsigned long long int m=5040,k=120,l=720; scanf("%I64d",&n); temp=n; for(i=1;i<=4;i++) { temp= temp*(n-i); } r1=temp/120; f=0; temp=n; for(i=1;i<=5;i++) ...
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
39f8a7d9e23b69de570e948c85d380f2
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include <stdio.h> #include <math.h> long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a; } int main() { long long n = 1; scanf("%I64d", &n); long long res = 0, t, a, d; t = 1; a = 1; for (int i = 2; i <= 5; i++) { a *= i; } for (int i = 0; i < 5; i++) { d = gcd(n - i, a); t *= (n -...
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
fb870c290c8f668762075224848119f1
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include<stdio.h> int main(){ long long n; scanf("%I64d",&n); unsigned long long i,sum=0,factof5=1,factof6=1,factof7=1; for(i=1;i<=7;i++){ if(i<=6){ factof6*=i; } if(i<=5){ factof5*=i; } factof7*=i; } unsigned long long x1=1,x2=1,x3...
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
c6f37d7145ba033861456ca2f1921118
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #define MAX 1010 #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) long long binomial[MAX][MAX]; void Generate(){ int i, j; clr(binomial); for (i = 0; i < MAX; i++){ for (j = 0; j <= i; j++){ ...
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
2bc45def3edc3ba970308c592d48fdac
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #define prime 1000000007 long long combi(int n,int k) { long long ans=1; k=k>n-k?n-k:k; int j=1; for(;j<=k;j++,n--) { if(n%j==0) { ans*=n/j; }else if(ans%j==0) { ans=ans/j*n; }else { ...
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
8d94ce78e192b9cbbe7c5f9746ff1a1c
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include <stdio.h> unsigned long long comb(int n, int k ) { if(k==0) return 1; return (comb(n-1,k-1)*n)/k; } int main() { int n; scanf("%d",&n); printf("%lli",comb(n,5) + comb(n,6) + comb(n,7)); }
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
400f35b0009a32e043361e101612bbfc
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include<stdio.h> int main() { unsigned long long n=0,k=0; scanf("%llu",&n); k = ((n*(n-1)*(n-2)*(n-3)*(n-4))/120) + (( ( (n*(n-1)*(n-2)*(n-3)*(n-4)/120) * (n-5) ) )/6) + (( ( (n*(n-1)*(n-2)*(n-3)*(n-4)/120) * (n-5) * (n-6) ) )/42); printf("%llu",k); return 0; }
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
03122aaf4644a0fcd8d339154c4a9902
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include <stdio.h> #include <stdlib.h> long long int fact5(int a) { long long int x=1; int i; for(i=1;i<=5;i++) { x*=(long long int)a; a--; } x/=120; return x; } long long int fact6(int b) { long long int y=1; int j; for(j=1;j<=5;j++) { y*=(long long int)b; b--; } y/=120; y*=(long long...
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
9bb2b6cc4ac22dfc3c94695d65346b17
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include<stdio.h> int main() { unsigned long long n,num5,num6,num7,k,arr[780]; for(n=7; n<=777; n++) { k=(n*(n-1)*(n-2)*(n-3)*(n-4)); num5=k/120; num6=(k*(n-5))/720; num7=n*(n-1)/2*(n-2)/3*(n-3)/4*(n-4)/5*(n-5)/6*(n-6)/7; arr[n]=num5+num6+num7; } while(scanf(...
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the n...
Output one integer — the number of different variants of group composition.
C
09276406e16b46fbefd6f8c9650472f0
d692ee91bd528a173f239ef931b8cbfb
GNU C
standard output
64 megabytes
train_002.jsonl
[ "combinatorics", "math" ]
1455807600
["7"]
null
PASSED
1,300
standard input
0.5 seconds
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
["29"]
#include<stdio.h> int main () { long long int n,i,a,b,c; scanf("%I64d",&n); a=n*(n-1)/2*(n-2)/3*(n-3)/4*(n-4)/5; b=n*(n-1)/2*(n-2)/3*(n-3)/4*(n-4)/5*(n-5)/6; c=n*(n-1)/2*(n-2)/3*(n-3)/4*(n-4)/5*(n-5)/6*(n-6)/7; printf("%I64d\n",a+b+c); return 0; }
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
8b1f02d1561559582359b647ec502add
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
#include<stdio.h> int main() { long int n[10000000],q; scanf("%d",&q); for (int i=1;i<=q;i++) scanf("%d",&n[i]); for (int i=1;i<=q;i++) { if (n[i]<4) puts("-1");else if (n[i]%4==0) printf("%d\n",n[i]/4); else if (n[i]%4==1) { if(n[i]/4-1<=0) puts("-1");else printf("%d\n",n[i]/4-1);} else if (n[i]%4==2) { printf("%d\...
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
32e64c587b4b8c228205ca7773470c5b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
#include<stdio.h> int main () { int a,n; scanf ("%d",&n); for (long long i=1; i<=n ;i++) { scanf("%d",&a); if(a<4 || a==5||a==7||a==11) printf ("-1\n"); else if (a%2==0) printf ("%d\n",a/4); else printf ("%d\n",a/4-1); } }
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
26639ec9b040a72572a4738011218ad0
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
/* Coached by rainboy */ #include <stdio.h> int main() { int q; scanf("%d", &q); while (q--) { int n, ans; scanf("%d", &n); if (n % 4 == 0) ans = n / 4; else if (n % 4 == 1) if (n >= 9) ans = (n - 9) / 4 + 1; else ans = -1; else if (n % 4 == 2) if (n >= 6) ans = (n - 6) / 4 + 1; ...
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
1e832e5a3154704e5a39d690a4a7e68e
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
/* Coached by rainboy */ #include <stdio.h> int main() { int q; scanf("%d", &q); while (q--) { int n, ans; scanf("%d", &n); if (n % 4 == 0) ans = n / 4; else if (n % 4 == 1) ans = n >= 9 ? (n - 9) / 4 + 1 : -1; else if (n % 4 == 2) ans = n >= 6 ? (n - 6) / 4 + 1 : -1; else ans = n >= 15 ? ...
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
81816bee42b3913e15a5a34d648782cc
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
#include <stdio.h> int main() { int q, n; scanf("%d", &q); while(q--) { scanf("%d", &n); if(n == 4 || n == 6 || n == 9) { puts("1"); } else if(n == 8 || n == 10) { puts("2"); } else if(n >= 12) { int table[4] = {3, 2, 3, 2}; pr...
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
f5bbc9c4a9e0d62bb18c2aa63fe7b413
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
#include<stdio.h> #include<stdlib.h> int main() { long long int i,j,k,n,ara[100000],t,a,b,c,ans; scanf("%lld",&t); for(i=0;i<t;i++){ scanf("%lld",&ara[i]); } for(i=0;i<t;i++){ a=ara[i]-6; b=ara[i]-9; c=ara[i]-15; if(ara[i]%4==0){ ans=ara[i]/4; ...
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
dac9e315491d29273ce3a08094df07bd
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
#include <stdio.h> #include <stdlib.h> int FindCh(int n) { return n / 4; } int Calc(int n) { if (n % 2 == 0) { if (FindCh(n) == 0) return -1; else return FindCh(n); } else { if (n - 9 < 0 || n - 9 == 2) return -1; else return 1 + FindCh(n - 9); } } int main() { int q, *mas, i; scanf("%d",...
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
9bce4373a993df58f55d422b55d577c2
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
#include<stdio.h> int main() { int q; scanf("%d",&q); while(q--) { int n,cnt=0; scanf("%d",&n); if(n%2==0) { if(n==2) printf("-1\n"); else { cnt=n/4; printf("%d\n",cnt); } } else { if(n<=11) { if(n==9) printf("1\n"); else p...
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.An integer greater than 1 is composite, if it is not prime, i.e. if i...
For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.
C
0c2550b2df0849a62969edf5b73e0ac5
92f978aa9a46e0884d2426ef5ea53be3
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dp", "number theory", "greedy", "math" ]
1508054700
["1\n12", "2\n6\n8", "3\n1\n2\n3"]
Note12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.8 = 4 + 4, 6 can't be split into several composite summands.1, 2, 3 are less than any composite number, so they do not have valid splittings.
PASSED
1,300
standard input
2 seconds
The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries. q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.
["3", "1\n2", "-1\n-1\n-1"]
#include <stdio.h> #include <stdlib.h> int main(void){ int q = 0, otv = 0, n = 0; scanf("%d",&q); for(int i = 0; i < q; i++){ otv = 0; scanf("%d",&n); while(n >= 4){ otv++; n = n - 4; } if(n == 0){ printf("%d\n",otv); }else if(n == 2){ if(otv >= 1) printf("%d\n",otv); else printf("%d\n",-...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
0e5acfc7b88f2a6f808c9bd3d0c3084e
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include<stdio.h> #include<stdlib.h> struct node { int val; struct node* next; }; struct node* a[100005]; int cat[100005],m,ans=0,ct[100005]; int verified[100005]; void insert (int u,int v) { struct node* q; q=(struct node*)malloc(1*sizeof(struct node)); q->val=v; q->next=NULL; ...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
e954547febb993703707013b49b0fad9
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include <stdio.h> #include <malloc.h> const int N = 1e5 + 4 ; int deg[100010] ; int U[100010],V[100010] ; int *a[100010] ; int sz[100010] ; int n , m ; int ans ; int col[100010] ; void dfs(int u , int p , int c) { if (c > m) return ; if (sz[u] == 1 && u != 1) ans++ ; int i ; for (i = 0 ; i < sz[u] ;...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
5252e91f402dcfa655f7299175a0f67b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include <stdio.h> #include <malloc.h> int deg[100010] ; int U[100010],V[100010] ; int *a[100010] ; int sz[100010] ; int n , m ; int ans ; int col[100010] ; void dfs(int u , int p , int c) { if (c > m) return ; if (sz[u] == 1 && u != 1) ans++ ; int i ; for (i = 0 ; i < sz[u] ; i++) { int v = ...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
fee65973d5dc4001c104f5f614b2b793
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef long long int LLI; #define TRUE (1==1) #define FALSE (!TRUE) #define fo3(i,a,b) for(i=((int)a);i<=((int)b);i++) #define of3(i,a,b) for(i=((int)a);i>=((int)b);i--) #define in1(n) scanf("%d",&(n)) #def...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
ea738afb8963549a5fbf21c9cac27bd0
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include <stdio.h> #include <stdlib.h> typedef struct ll { int x; struct ll* next; }node; node* a[100020]; long long int b[100020],count=0; node* nnode(void) { node* temp = (node*)malloc(sizeof(node)); temp->next = NULL; return temp; } void initialize(void) { long long int i; for(i=0; i<100020; i++) { a[...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
883eb8275480a4942b07733f089884c5
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include "stdio.h" #include "stdlib.h" #define MAX_VERTICES_COUNT 100005 #define BASE "%d" typedef int Base; typedef struct UTreeNode { Base *Childrens; Base ChildrenCount; Base IsCatHere; Base IsVisited; } UTreeNode; static UTreeNode Tree[MAX_VERTICES_COUNT]; Base DFSWithCatCount(UTreeNode *Tree, ...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
b592d771e8163689f200488e2d3a0c8c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
/* Coached by rainboy */ #include <stdio.h> #define N 100000 int oo[1 + (N - 1) * 2], oj[1 + (N - 1) * 2]; int link(int o, int j) { static int _ = 1; oo[_] = o, oj[_] = j; return _++; } int cc[N], ae[N]; int m, cnt; void dfs(int p, int i, int k) { int o; k = cc[i] ? k + 1 : 0; if (k > m) return; if (p !...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
25d5dace9090788257a74a1e2a37da73
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include <stdio.h> #include <stdlib.h> typedef struct node { int num; struct node* next; }Node; typedef struct { int cat; int total_cat; int vis; Node* head; Node* use; }Point; int ans; void Add(int, int, Point*); void Dfs(Point*,int ,int, int); int main() { int n,m; while(scanf(...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
2bce64148beb5282a3217770c9f2d71f
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include<stdio.h> #include<stdlib.h> #define sf scanf #define pf printf #define sz 100001 struct arr { int a; struct arr *next; }; typedef struct arr linklist; linklist *G[sz]; int vis[sz],cat[sz],m,ans; int length(linklist *head) { int count=0; linklist *cur=head; while(cur!=NULL) { cou...
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti...
A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.
C
875e7048b7a254992b9f62b9365fcf9b
01a69e37f80ef07d060bf4f9b5ed9c69
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "dfs and similar", "trees", "graphs" ]
1442939400
["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"]
NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i...
PASSED
1,500
standard input
2 seconds
The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1...
["2", "2"]
#include <stdio.h> #include <stdlib.h> #define max(a,b) a > b ? a : b; #define START_SIZE 16 #define print(int_var) printf("%d\n", int_var); typedef struct { int* content; size_t size; size_t pos; } Stack; Stack* init() { Stack *new_stack = malloc(sizeof(Stack)); new_stack->content = malloc(STA...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
af32a80038e5cb73858186f93b1d49f6
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <stdbool.h> #include <ctype.h> #define INT_MAX 200000 int palindrome(char str[],int N){ int i=0,j=0; while(i<=N/2-1 && j<=N/2-1){ if(abs((str[i])-(str[N-i-1]))==2 || str[i]==str[N-i-1]){ j++; } i++; } return j; } int ma...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
a99c73f943560c828883a961fd0a8b2d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include<stdio.h> main() { int t; scanf("%d",&t); while(t--) { int n,i,p=0; scanf("%d",&n); char str[n+1]; scanf("%s",str); for(i=0; i<n/2; i++) { if((str[i]+1)==(str[n-i-1]+1)) { p=1; } else if((str[i]+1)==...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
77cbc17694e3b523b75b6536fe67fe2d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include <stdio.h> int main(){ int n,counter=0,i,x,l,z,e,c=0; scanf("%d",&n); while(counter<n){ scanf("%d",&x); c=0; char s[x]; scanf("%s",s); for(i=0,e=x-1-i;i<x/2;i++,e--){ if(s[i]==s[e]) c++; else{ l=s[i]; z=s[e]; if((l+2==z) || (l-2==z)) c++; } } if(c*2 ...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
5dd5229565ca252b73f4e79f3dbd3144
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include<stdio.h> #include<math.h> main() { int t, n, f, i, p, j; char a[102]; scanf("%d", &t); while (t--) { scanf("%d", &n); scanf("%s", a); for (i=0, j=n-1, f=0; j>i; i++, j--) { p=abs(a[i]-a[j]); if (p!=0 && p!=2) { f=1; break; } } if (f==0) { printf("YES\n"); } else ...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
c94e1c5ec9c0e752074e9f718f7113ff
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include<stdio.h> #include<string.h> int main() { int f,k; scanf("%d\n",&k); while(k>0) { scanf("%d\n",&f); char s[f]; int q; gets(s); int d=strlen(s),i=0,z=0,n,m; int j=d-1; while(i!=j&&i<=(d/2)&&j>=(d/2)) { n=(int)s[i]; m=(int)s[j]; if(m==n||(m+1)==(n+1)||(m-1)==(n-1)||(m+1)==(n-1)||...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
2f81ab1621e3698cff05f13f2c860ce5
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include <stdio.h> int areequal(char a, char b){ int p=a, q =b; int parr[3]={0,1,-1}, qarr[3]={0,1,-1}; if(p=='z') parr[1]=-1; if(q=='z') qarr[1]=-1; if(p=='a') parr[2]=1; if(q=='a') qarr[2]=1; for(int i=1; i<3; i++){ for(int j=1; j<3; j++){ if(p+parr[i] == q+qarr[j]) return 1; } } return 0...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
8833533ab83993c630fd68d088ed484c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include<stdio.h> #include<string.h> int main( ){ int s; scanf("%d",&s); for(int i=0;i<s;i++){ int x; scanf("%d",&x); char a[x]; scanf("%s",a); int f=0; for(int i=0;i<x/2;i++){ if((a[i]!=a[x-1-i])&&(abs(((a[x-1-i]-a[i])))!=2)){ f=1; } } if(f==1){ ...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
9073390c5cea9361f9df66f6e6b97804
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include<stdio.h> #include<string.h> int main() { int f,k; scanf("%d\n",&k); while(k>0) { scanf("%d\n",&f); char s[f]; int q; gets(s); int d=strlen(s),i=0,z=0,n,m; int j=d-1; while(i!=j&&i<=(d/2)&&j>=(d/2)) { n=(int)s[i]; m=(int)s[j]; if(m==n||(m+1)==(n+1)||(m-1)==(n-1)||(m+1)==(n-1)||...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
bead47dce5b0db72656d8f5ce90a798b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include<stdio.h> #include<string.h> int main(){ int t; scanf("%d",&t); for(int i=0;i<t;i++){ int n,m=0; scanf("%d",&n); char s[n]; scanf("%s",s); int k=strlen(s); for(int j=0;j<k/2;j++){ if(s[j]==s[k-j-1]||s[j]==s[k-j-1]+2||s[j]==s[k-j-1]-2){ m+=1; } } if(m==k/2)printf("YES\n"); else pri...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
41b7440edd8019e2fb643cb6d74fbc39
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include <stdio.h> #include <stdlib.h> int main () { int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); char s[n]; int c=0,i,j; scanf("%s",s); for(i=0;i<n/2;i++) { j=abs(s[i]-s[n-1-i]); if(j==2||j==0) c++; } if(c==n/2) printf("YES\n"); else printf("NO\n"); } }
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
3e7cd13ba6b9dcc3cc0fc81228ef0ba8
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include<stdio.h> #include<math.h> int main() { int p; scanf("%d",&p); while(p--) { int n,b=0,i; scanf("%d",&n); char s[n]; scanf("%s",s); for(i=0;i<n/2;i++) { if(s[i]-s[n-1-i]==2 || s[i]-s[n-i-1]==-2 || s[i]-s[n-i-1]==0) { b++; } } if(b==n/2) printf("YES\n"); else printf("NO\n"...
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one o...
Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.
C
cc4cdcd162a83189c7b31a68412f3fe7
13abe16dd49a07ddb2943d3306357902
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "strings" ]
1534602900
["5\n6\nabccba\n2\ncf\n4\nadfa\n8\nabaazaba\n2\nml"]
NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — th...
["YES\nNO\nYES\nNO\nNO"]
#include<stdio.h> int check(char s[],int n){ int f=0,c=0; for(int i=0,j=n-1;i<=n/2,j>=n/2;i++,j--){ int p=s[i];int q=s[j]; if(p==q || p-q==2 || p-q==-2){ f=0;c++; } else{f=1;} } if(c==n/2) {return f;} else return -1; } int main(){ int t; scanf("%d\n",&t); for(int i=0;i<t;i++){ int n; scanf("%d...