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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 3305100d5db3e2e30a12304f466fa66a | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
#include<math.h>
#include<string.h>
int main() {
int n,l=0;
char a[101];
int len;
scanf("%d",&n);
while(n--)
{
scanf("%d",&len);
scanf("%s",a);
l=0;
for(int i=0; i<len/2; i++)
{
if(a[i]==a[len-1-i] || (a[i]-a[len-1-i])==2 || a[i]-a[len-1-i]==-2)
l++;
}
if(l==len/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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 7dbf5da413535ccd941414b0bc0285e8 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<string.h>
char s[110];
int n;
int pal(char s[],int n)
{
int flag=0;
for(int i=0;i<n/2;i++)
{
if(s[i]==s[n-i-1])
flag++;
}
if(flag==n/2)
return 1;
else
return 0;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
char a[110];
int cnt=0;
scanf("%d %s",&n,a);
if(pal(a,n)==1)
printf("YES\n");
else
{
for(int j=0;j<n/2;j++)
{
int num=a[j]-a[n-j-1];
if(num==0 || num == 2 || num == -2)
cnt++;
}
if(cnt==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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 9bc938366ba2e8d907180777c0d05c88 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
#include <string.h>
int main(){
int t,a,n,i,c,bh,x;
scanf("%d\n",&t);
char str[10000];
while(t--){
scanf("%d",&n);
scanf("%s",str);
int a[n/2];
for(i=0;i<(n/2);i++){
x=(str[i]-str[n-i-1]);
if (x>0)
a[i]=x;
else
a[i]=(-x);
}
c=0;
for(i=0;i<(n/2);i++){
if(a[i]==0 || a[i]==2)
c=c+1;
}
if(c==(n/2))
printf("YES\n");
else
printf("NO\n");
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | bbd7f955d5f52f8e96b702dd4855a82e | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<string.h>
int flag=0,l;
int check(char s[],int l)
{
char ch1[2],ch2[2];
for(int i=0;i<(l/2);i++)
{
ch1[0]=(char)(((int)s[i])+1);
ch1[1]=(char)(((int)s[i])-1);
ch2[0]=(char)(((int)s[l-i-1])+1);
ch2[1]=(char)(((int)s[l-i-1])-1);
// printf("HEy %c %c %c %c\n",ch1[0],ch1[1],ch2[0],ch2[1]);
if((ch1[0]!=ch2[0])&&(ch1[0]!=ch2[1])&&(ch1[1]!=ch2[0])&&(ch1[1]!=ch2[1]))
return 1;
}
return 0;
}
int main()
{
int T;
scanf("%d",&T);
for(int i=0;i<T;i++)
{
char s[100];
scanf("%d",&l);
scanf("%s",s);
if(check(s,l)==1)
printf("NO\n");
else
printf("YES\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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | c308783be4497f5086b8bf0b888d782d | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int t, n, i, j, diff;
scanf("%d", &t);
while (t != 0)
{
scanf("%d", &n);
char a[n];
int flag = 0;
scanf("%s", a);
for (i=0, j=(n-1); i<n && j>=0; i++, j--)
{
diff = abs(a[i] - a[j]);
if (diff != 2 && diff != 0)
{
flag = 1;
}
}
if (flag == 0)
printf("\nYES");
else
printf("\nNO");
t--;
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | cbcb8c75079d3aaaf15098755c35b681 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int t, n, i, j, diff;
scanf("%d", &t);
while (t>0)
{
scanf("%d", &n);
char a[n];
int flag = 0;
scanf("%s", a);
for (i=0, j=(n-1); i<n && j>=0; i++, j--)
{
diff = abs(a[i] - a[j]);
if (diff != 2 && diff != 0)
flag = 1;
}
if (flag == 0)
printf("\nYES");
else
printf("\nNO");
t--;
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 9f6b8e56044da5ac5410b85270f74996 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
#include <math.h>
int main(void){
int t,T;
scanf("%d",&T);
for(t=1;t<=T;t++){
int n,i,an=0;
scanf("%d",&n);char a[n];
scanf("%s",a);
for(i=0;i<n/2;i++){
if(a[i]=='a'){if( a[n-1-i]=='a' || a[n-1-i]=='c')an++;}
else if(a[i]=='z'){if( a[n-1-i]=='z' || a[n-1-i]=='x' )an++;}
else {if(fabs(a[i]-a[n-i-1])==2 ||fabs(a[i]-a[n-i-1])==0)an++;}
// printf("%d ",an);
}
if(an==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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | fd6f4df8a759aefcc78d49f3d162e9c2 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<string.h>
int main(t)
{scanf("%d",&t);
int i,l,j,a,c,T[t];
for(i=0;i<t;i++)
{
c=1;
T[i]=0;
scanf("%d",&l);
char s[l+1];
scanf("%s",s);
for(j=0;j<(l/2);j++)
{
a=abs(s[j]-s[l-1-j]);
if(a==0 || a==2)
;
else
{
c=0;
break;
}
}
if(c)
T[i]=1;
}
for(i=0;i<t;i++)
if(T[i])
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 40726736c02892ad54bbe4c4b5e1b4da | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int i,j,x,c=0,t,k;
scanf("%d",&t);
for(k=0;k<t;k++)
{
scanf("%d",&x);
char a[x];
scanf("%s",&a);
for(i=0,j=x-1;i<x/2;i++,j--)
{
if( ( a[i]+1 != a[j]+1 ) && (a[i]-1 !=a[j]-1 ) && ( a[i]+1 != a[j]-1 ) && ( a[i]-1 !=a[j]+1 ) )
{
c++;
}
}
if(c==0)
{
printf("YES\n");
}
else
{
printf("NO\n");
c=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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 9f04dcfc80d73ca1f4c604e2798d8217 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<string.h>
int main(){
int t,c;
scanf("%d",&t);
for(int i=0;i<t;i++){
int l;
c=0;
scanf("%d",&l);
char s[l];
scanf("%s",s);
int n=l/2;
for(int j=0;j<n;j++){
int a=s[j];
int b=s[l-1-j];
if(a==b||a-1==b+1||a+1==b-1){
c=c+1;
}
}
if(c==n){
printf("YES\n");
}
else{
printf("NO\n");
}
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 4bf588e43f44678ac5e62aa7814f5ffa | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int t,i,count=0,k,j;
scanf("%d",&t);
int a[t];
char b[t][200];
for(i=0;i<t;i++)
scanf("%d %s",&a[i],b[i]);
for(i=0;i<t;i++)
{
for(j=0,k=a[i]-1;j<a[i]/2;j++,k--)
{
if(b[i][j]==b[i][k] || abs(b[i][j]-b[i][k])==2)count++;
}
if(count==a[i]/2)printf("YES\n");
else printf("NO\n");
count=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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | c4478d7a4098a6fad27a483a575d3446 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<string.h>
int main(){
int t,c;
scanf("%d",&t);
for(int i=0;i<t;i++){
int l;
c=0;
scanf("%d",&l);
char s[l];
scanf("%s",s);
int n=l/2;
for(int j=0;j<n;j++){
int a=s[j];
int b=s[l-1-j];
if(a==b||a-1==b+1||a+1==b-1){
c=c+1;
}
}
if(c==n){
printf("YES\n");
}
else{
printf("NO\n");
}
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 1cc4ccad26edee630f3a6a7a3cd2c23a | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int q;
scanf("%d", &q);
while(q--)
{
int n,i,t=1;
char s[101];
scanf("%d%s", &n, s);
for(i=0; i<(n/2); i++)
{
int d= (s[i]-s[n-i-1]);
if(d!=0 && d!=2 && d!=-2)
{
t=0;
}
}
if(t)
printf("YES\n");
else
printf("NO\n");
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | bbe410ce3ddc403495674e8b199518b3 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#define N 102
int main(){
int T;
scanf("%d",&T);
int n;
char s[N];
while(T--){
scanf("%d",&n);
scanf("%s",s);
int ok=1;
int i;
for(i=0;i<n/2;i++){
//printf("%d: %c %c\n",i,s[i],s[n-1-i]);
//df的例子两个字母可以相距2个,而不是1个
//必须保持改变,不能保持不变?
if(s[i]-1==s[n-1-i]-1 || s[i]-1==s[n-1-i]+1
|| s[i]+1==s[n-1-i]-1 || s[i]+1==s[n-1-i]+1){
//情况合格
}else{
ok=0;
break;
}
}
if(ok){
printf("YES\n");
}else{
printf("NO\n");
}
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 9354a4d4ef3164548cf57160bfcba1ed | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<string.h>
int main(){
int t;
scanf("%d",&t);
while(t--){
int n,l=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){
l+=1;
}
}
if(l==k/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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | a93a32ae1ee5de763b1686adbf98298c | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int t,n,i,j;
scanf("%d",&t);
while(t--)
{
scanf("%d\n",&n);
char x[n+1];
gets(x);
for(i=0,j=n-1;i<n/2;i++,j--) if(abs(x[i]-x[j])>2||abs(x[i]-x[j])==1) break;
if(i==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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | f51587e9c1b651f30d7ef5f98b6e17f8 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n,k,i,count;
scanf("%d",&n);
for(i=0;i<n;i++){
char c1,c2;
count=0;
scanf("%d",&k);
char str[k+1];
scanf("%s",str);
for(int j=0;j<k/2;j++)
{
c1=str[j];
c2=str[k-j-1];
if(!((c1==c2) || (c1-c2)==2 || (c2-c1)==2))
{
count++;
}
}
if(count>0){
printf("NO\n");}
else{printf("YES\n");};
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | e480e9b4d9857ad7578b795b928866d1 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<stdlib.h>
char str[100];
int flag;
int check(int p,int n)
{
if(p>=n/2)
{ if(flag==1)
return 1;
else
return 0;
}
if( abs(str[p]-str[n-p-1] ) <= 2 && abs(str[p]-str[n-p-1]) != 1)
{
flag=1;
check(p+1,n);
}
else
{flag=0;
}
if(flag==1)
return 1;
else
return 0;
}
int main()
{
int T;
scanf("%d",&T);
for(int i=0;i<T;i++)
{
int n;
scanf("%d",&n);
scanf("%s",str);
int x=check(0,n);
if(x==1)
printf("YES\n");
else
printf("NO\n");
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 3c9597127a4cb82d4fb672bdc500303d | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 0bde167da197e9c301e0d84d0ffa33fa | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
#include <stdlib.h>
int twist(char *str, int length) {
int lim=(length+1)/2,diff;
for (int i=0; i<lim; i++) {
diff=abs(str[i]-str[length-1-i]);
if (diff>2 || diff==1) return 0;
}
return 1;
}
int main() {
int queries,len;
char word[100];
scanf("%d\n",&queries);
for (int i=0; i<queries; i++) {
scanf("%d",&len);
scanf("%s",word);
if (twist(word,len)) {
printf("YES\n");
} else {
printf("NO\n");
}
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 34e83710aa235669fcf21d106e075ee1 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void)
{
int i,t;
scanf("%d",&t);
for(i=0;i<t;i++)
{
int size;
scanf("%d",&size);
int flag=0;
char st[100];
scanf("%s",st);
int start=0,end=size-1;
while(start<=end)
{
if(st[start] =='a')
if(st[end]!='a'&&st[end]!='c')
{flag=1;break;}
if(st[end]=='z')
if(st[end]!='z'&&st[end]!='x')
{flag=1;break;}
if(abs(st[start]-st[end])!=0 && abs(st[start]-st[end])!=2)
{flag=1;break;}
start++;end--;
}
if(flag==1)
printf("NO\n");
else
printf("YES\n");
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 1005650f5a663a3466163b6579e64ad2 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<string.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int i,n,count=0;
scanf("%d",&n);
char a[n];
scanf("%s",a);
for(i=0;i<n/2;i++)
{
if(a[i]==a[n-1-i])
count++;
else if ( (a[i]==a[n-1-i]+2) || (a[n-1-i]==a[i]+2) )
count++;
}
if(count==(n/2)) printf("\nYES");
else printf("\nNO");
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 8fc7e662000a29189e4a71862a5ae559 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<stdlib.h>
int main(void)
{
int t,j;
scanf("%d",&t);
while(t--)
{
int n,flag=1;
char str[100];
scanf("%d",&n);
int start=0,end=n-1;
scanf("%s",str);
while(start<end)
{
if(str[start]!=str[end])
{
int c=str[start];
int d=str[end];
if(abs(c-d)!=2)
{
flag=0;
break;
}
}
start++;
end--;
}
if(flag==1)
printf("YES\n");
else
printf("NO\n");
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 0b46529980f5dfba4cfb13fecfdac1c1 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<stdlib.h>
int main(){
int n,k,i;
int o;
scanf("%d",&n);
for(i=0;i<n;i++){
o=0;
scanf("%d",&k);
char s[k+1];
scanf("%s",s);
for(int j=0;j<k/2;j++){
char a=s[j];
char b=s[k-j-1];
if(!(a==b || a-b==2 || b-a==2)){
o++;
}
}
if(o>0){
printf("NO\n");
}else{printf("YES\n");};
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 25d58409a7ba7624aa008df9fa805726 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main(){
int n,k;char a[1000];
scanf("%d",&n);
while(n!=0){
int i,j,flag;
scanf("%d",&k);
i=0;j=k-1;
scanf("%s",a);
while(i<j){
flag=1;
if(((a[i]+1)!=(a[j]+1))&&((a[i]-1)!=(a[j]-1))&&((a[i]+1)!=(a[j]-1))&&((a[i]-1)!=(a[j]+1))){
flag=0;
break;
}
i++;j--;}
if(flag==1) printf("YES\n");
else printf("NO\n");
n--;
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 86402fb7366ee9b3965bb5c1e1785282 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int a,b,c,n,i,j,k,l;
char s[250];
scanf("%d",&n);
for(i=0;i<n;i++)
{
j=0;
scanf("%d",&b);
scanf("%s",s);
for(c=0,l=b-1;c<=b/2-1;c++,l--)
{
if(s[c]-1==s[l]-1)
j++;
else if(s[c]+1==s[l]+1)
j++;
else if(s[c]+1==s[l]-1)
j++;
else if(s[c]-1==s[l]+1)
j++;
}
if(j==b/2)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | b7f0af5dff1ea2a135ca1b28718091d9 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
#include <string.h>
#include <math.h>
int main ()
{
int h,t,a[1000];
scanf("%d",&t);
for(h=0;h<t;h++)
{
int n;
scanf("%d",&n);
char st[n+1];
scanf("%s",st);
//printf("%d\n",n);
int cnt=0;
for(int i=0;i<n/2;i++)
{
if(st[i]=='a')
{if(st[i]==st[n-i-1]||st[n-i-1]-st[i]==2)
cnt++;}
else if(st[i]=='z')
{if(st[i]==st[n-i-1]||st[i]-st[n-i-1]==2)
cnt++;}
//printf("a %d\n",cnt);
else if(st[i]==st[n-i-1]||fabs(st[i]-st[n-i-1])==2)
cnt++;
//printf("else %d\n",cnt);}
}
if(cnt==n/2)
a[h]=1;
else
a[h]=0;
}
for(int k=0;k<t;k++)
if(a[k]==1)
printf("YES\n");
else if(a[k]==0)
printf("NO\n");
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | abdea3e2f50f21d62a33a164afaeff85 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["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){
printf("NO\n");
}
else{
printf("YES\n");
}
}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 3b92165568b5f2c77bad34f23f6da8ea | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main(void){
int a;
scanf("%d",&a);
while(a--){
int b;
scanf("%d",&b);
char c[b+1];
scanf("%s",c);
int i=0,j=b-1,k=1;
while(i<j){
if(c[i]-c[j]!=2 && c[j]-c[i]!=2 && c[i]!=c[j]){
printf("NO\n");
k=0;
break;
}
i++;
j--;
}
if(k){
printf("YES\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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | a498dedd4b30b08d010768e8226c0c8c | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
char a[n+2];
scanf("%s",a);
int k=0;
for(int i=0,j=n-1;i<j;i++,j--)
{
if(a[i]==a[j]||a[i]-a[j]==2||a[i]-a[j]==-2)
{
k++;
}
}
if(k==n/2)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
}
/*
ixzg, n=4
এখানে ১ম(i=0) কেরেক্টার
i এবং শেষ কেরেক্টার
(j=n-1 that's mean j=3) গ
এর আস্কি ভেলু
ডিফারেন্স 2, এ দুটোকেই
চেঞ্জ করে h করা যায়,
আবার,২য় কেরেক্টার
x(i=1) এবং j=n-1
(that's mean j=3) মানে ৩য় কেরেক্টার z এর
আস্কি ভেলু ডিফারেন্স 'z'-'x' =-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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 38ea599c749c5cde0c40fed739c6981c | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["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)||(m-1)==(n+1))
{
z++;
}
i++;
j--;
}
if(z==(strlen(s))/2)
{
printf("YES\n");
}
else{
printf("NO\n");}
k--;}
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 of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately. | 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 | 641f1974b9413557a4dc0041395ccab3 | 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 string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm". | 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) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters. | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int isPalindrome(char string[],int size) {
int check=0,i,j;
if(size<=1)
return 1;
for(i=-1;i<2;i+=2) {
for(j=-1;j<2;j+=2) {
if((string[0]+i)==(string[size-1]+j))
check=1;
}
}
if(check)
return isPalindrome(string+1,size-2);
else
return 0;
}
int main(void) {
int T,n;
for(scanf("%d",&T);T--;) {
scanf("%d",&n);
char string[n];
scanf("%s",string);
if(isPalindrome(string,n))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 091e6aaf77619df5ce2645566bd7ecc6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
int main(){
int n;
int x,y,z;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d %d %d",&x,&y,&z);
if(x==y&&y==z)
printf("YES\n%d %d %d\n",x,y,z);
else if((x==y)&&(x>z))
printf("YES\n%d %d 1\n",x,z);
else if((y==z)&&(y>x))
printf("YES\n1 %d %d\n",y,x);
else if((x==z)&&(x>y))
printf("YES\n%d 1 %d\n",x,y);
else
printf("NO\n");
}
return 0;
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 7d3d222869b1c9fb04274a81ba03b7b1 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int t,m;
scanf("%d",&t);
long long x,y,z;
long long a[t],b[t],c[t],r[t];
for(int i=0;i<t;i++)
{
scanf("%lld %lld %lld",&x,&y,&z);
if(x==y&&y==z)
{
m=1;
a[i]=x;
b[i]=y;
c[i]=z;
}
else if(x==y&&x!=z)
{
if(z<x)
{
m=1;
a[i]=z;
b[i]=x;
c[i]=z;
}
else
{
m=0;
}
}
else if(y==z&&y!=x)
{
if(x<y)
{
m=1;
a[i]=x;
b[i]=x;
c[i]=z;
}
else
{
m=0;
}
}
else if(x==z&&x!=y)
{
if(y<x)
{
m=1;
a[i]=y;
b[i]=x;
c[i]=y;
}
else
{
m=0;
}
}
else
{
m=0;
}
r[i]=m;
}
for(int i=0;i<t;i++)
{
if(r[i]==1)
{
printf("YES\n");
printf("%lld %lld %lld\n",a[i],b[i],c[i]);
}
else if(r[i]==0)
{
printf("NO\n");
}
}
return 0;
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 5159b16deb0f62580624574347bc68ec | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include <stdio.h>
void max(int x, int y, int z) {
int a = -1;
int b = -1;
int c = -1;
if (z > x && z > y) {
fprintf(stdout, "NO\n");
return;
}
if (x == z && z == y) {
a = x;
b = x;
c = x;
} else {
if (x > y) {
a = y;
b = x;
} else if (y > x){
a = x;
c = y;
} else {
a = x;
b = z;
c = z;
fprintf(stdout, "YES\n");
fprintf(stdout, "%d %d %d\n", a, b, c);
return;
}
if (b > z || c > z) {
fprintf(stdout, "NO\n");
return;
} else {
if (b != z && c != z) {
fprintf(stdout, "NO\n");
return;
} else {
if (b == z) {
c = 1;
} else {
b = 1;
}
}
}
}
if (a < 0 || b < 0 || c < 0) {
fprintf(stdout, "NO\n");
return;
}
fprintf(stdout, "YES\n");
fprintf(stdout, "%d %d %d\n", a, b, c);
}
int main(void) {
int t = 0;
scanf("%d", &t);
int x = 0;
int y = 0;
int z = 0;
for (int i = 0; i < t; ++i) {
scanf("%d", &x);
scanf("%d", &y);
scanf("%d", &z);
max(x, y, z);
}
return 0;
} | |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | e92b29f232f9051b1e6f1f5487b19356 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
int main()
{
long long int t,x,y,z;
scanf("%lld",&t);
while(t>0)
{
scanf("%lld %lld %lld",&x,&y,&z);
if(x==y && x>=z|| y==z && z>=x || z==x && z>=y)
{
printf("YES\n");
if(x==y && x>=z)
printf("%lld %lld %lld\n",x,z,z);
else if(z==y && z>=x)
printf("%lld %lld %lld\n",z,x,x);
else if(x==z && z>=y)
printf("%lld %lld %lld\n",x,y,y);
}
else
printf("NO\n");
t--;
}
return 0;
} | |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 0ed1a48688aab950d82ddb50d8bee5c6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
int main()
{
int t,x,y,z;
scanf("%d",&t);
while(t--){
scanf("%d%d%d",&x,&y,&z);
if(x!=y && y!=z && z!=x){
printf("NO\n");
}
else if(x==y && y==z){
printf("YES\n");
printf("%d %d %d\n",x,y,z);
}
else if(x==y && x>z){
printf("YES\n");
printf("%d %d 1\n",x,z);
}
else if(x==y && x<z){
printf("NO\n");
}
else if(x==z && x>y){
printf("YES\n");
printf("%d %d 1\n",x,y);
}
else if(x==z && x<y){
printf("NO\n");
}
else if(y==z && y>x){
printf("YES\n");
printf("%d %d 1\n",y,x);
}
else if(y==z && y<x){
printf("NO\n");
}
}
return 0;
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | a384ac6731eb8d6dc0cc9cdb793a8a8d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
int main(){
int t,s;
int x,y,z;
scanf("%d",&t);
for(s = 0; s < t; s++){
scanf("%d %d %d",&x,&y,&z);
if(x>y && x == z){
printf("YES\n%d %d %d\n",x, y, y);
}
else if(y>x && y == z){
printf("YES\n%d %d %d\n",y, x, x);
}
else if(x == y && y > z){
printf("YES\n%d %d %d\n",x,z,z);
}
else if(x == y && x == z){
printf("YES\n%d %d %d\n",x, x, x);
}
else{
printf("NO\n");
}
}
return 0;
} | |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 11343bf91b2db777cd031d658a544842 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
void sort(int a[]){
for(int i = 0; i < 3; i++){
for(int j = 2; j > i; j--){
if(a[i] < a[j]){
int temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
// for(int i = 0; i < 3; i++){
// printf("%d\n", a[i]);
// }
}
int main(){
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++){
int a[3];
for(int j = 0; j < 3; j++){
scanf("%d", &a[j]);
}
sort(a);
if(a[0] == a[1]){
if( a[1] != a[2]){
printf("YES");
printf("\n%d %d %d\n", a[0], a[2], a[2]);
}else{
printf("YES");
printf("\n%d %d %d\n", a[0], a[0], a[0]);
}
}else{
printf("NO\n");
}
}
return 0;
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 33c2b2e2b944f32b71459bcdabed834c | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
int main(){
int t;
long long int x,y,z;
scanf("%d",&t);
while(t!=0){
scanf("%lld%lld%lld",&x,&y,&z);
if(x==y){
if(x>=z){
printf("YES\n");
printf("%lld\t%lld\t%lld\n",x,z,z);
}
else{
printf("NO\n");
}
}
else if(y==z){
if(y>=x){
printf("YES\n");
printf("%lld\t%lld\t%lld\n",y,x,x);
}
else{
printf("NO\n");
}
}
else if(x==z){
if(x>=y){
printf("YES\n");
printf("%lld\t%lld\t%lld\n",x,y,y);
}
else{
printf("NO\n");
}
}
else{
printf("NO\n");
}
t--;
}
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 5ee5ddeb4299d993a7e6f3d1a0c1afb4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long int x, y, z, max, min;
scanf("%ld %ld %ld",&x,&y,&z);
if(x!=y && x!=z && y!=z)
{
printf("NO\n");
}
else if(x==y && y==z)
{
printf("YES\n");
printf("%ld %ld %ld\n",x,y,z);
}
else
{
if(x>=y && x>=z)
{
max=x;
if(y>z)
{
min=z;
printf("YES\n");
printf("%ld %ld %ld\n",max,min,min);
}
else if(z>y)
{
min=y;
printf("YES\n");
printf("%ld %ld %ld\n",max,min,min);
}
else
{
printf("NO\n");
}
}
else if(y>=z && y>=x)
{
max=y;
if(x>z)
{
min=z;
printf("YES\n");
printf("%ld %ld %ld\n",max,min,min);
}
else if(z>x)
{
min=x;
printf("YES\n");
printf("%ld %ld %ld\n",max,min,min);
}
else
{
printf("NO\n");
}
}
else if(z>=x && z>=y)
{
max=z;
if(x>y)
{
min=y;
printf("YES\n");
printf("%ld %ld %ld\n",max,min,min);
}
else if(y>x)
{
min=x;
printf("YES\n");
printf("%ld %ld %ld\n",max,min,min);
}
else
{
printf("NO\n");
}
}
}
}
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 13fc48734cd77238e139bf78dce2c4df | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int a[3];
for(int i=0;i<3;i++)
{
scanf("%lld",&a[i]);
}
int t;
for(int i=0;i<2;i++)
{
for(int j=i+1;j<3;j++)
{
if(a[j]<a[i])
{
t=a[j];
a[j]=a[i];
a[i]=t;
}
}
}
if(a[1]!=a[2])
printf("NO\n");
else
printf("YES\n%lld %lld %lld\n",a[2],a[0],a[0]);
}
return 0;
} | |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 1818723e3461ee6cb4bfd0ee07837bb6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main()
{
int a,b,c,x,y,z,t,k;
scanf("%d",&t);
for (k=0 ; k < t ; k++)
{
scanf("%d %d %d",&x,&y,&z);
if (x>1000000000 || x<=0)
printf("NO\n");
else if (y>1000000000 || y<=0)
printf("NO\n");
else if (z>1000000000 || z<=0)
printf("NO\n");
else if(x != y && y != z && x != z)
printf("NO\n");
else if(x==y)
{if (z>x)
printf("NO\n");
else if (z==x)
{
a = x;
b = y;
c = z;
printf("YES\n%d %d %d\n",a,b,c);
}
else if (z<x)
{
a = x;
b = z;
c = 1;
printf("YES\n%d %d %d\n",a,b,c);
}
}
else if(x==z)
{if (y>x)
printf("NO\n");
else if (y==x)
{
a = x;
b = y;
c = z;
printf("YES\n%d %d %d\n",a,b,c);
}
else if (y<x)
{
b = x;
a = y;
c = 1;
printf("YES\n%d %d %d\n",a,b,c);
}
}
else if(y==z)
{if (x>y)
printf("NO\n");
else if (x==y)
{
a = x;
b = y;
c = z;
printf("YES\n%d %d %d\n",a,b,c);
}
else if (x<y)
{
a = 1;
b = x;
c = y;
printf("YES\n%d %d %d\n",a,b,c);
}
}
}
return 0;
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 8eb39fd5ac7af11b7a63008143949722 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
#include<stdlib.h>
typedef long long int lli;
int main() {
int testcases;
scanf("%d", &testcases);
while(testcases--){
lli x,y,z;
scanf("%lld %lld %lld", &x, &y, &z);
if(x==y && y==z){
printf("YES\n");
printf("%lld %lld %lld\n", z,z,z);
}
else if(x==y && x>z){
printf("YES\n");
printf("%lld %lld %lld\n", x,z,z);
}
else if(x==z && x>y){
printf("YES\n");
printf("%lld %lld %lld\n", y,x,y);
}
else if(y==z && y>x){
printf("YES\n");
printf("%lld %lld %lld\n", x,x,y);
}
else{
printf("NO\n");
}
printf("\n");
}
}
| |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 72f7dca62a0ee98e65eafa1896f5270b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
unsigned long long int a,b,c;
unsigned long long int t,x,y,z,i;
void word(void);
int main()
{
scanf("%llu",&t);
for(i=1 ;i<=t ;i++)
{
scanf("%llu %llu %llu",&x,&y,&z);
if((x==y)||(y==z)||( x==z))
{
if(y==z && y>x) {a=z; b=x; c=x-1; word();}
else if(y==x && y>z) {a=y; b=z; c=z-1; word();}
else if(z==x && z>y) {a=z; b=y; c=y-1; word();}
else if(y==x && x==z && y==z ) {a=x; b=y; c=z; word();}
else printf("NO");
}
else printf("NO");
printf("\n");}
}
void word(void)
{
if(c>0) printf("YES\n%llu %llu %llu",a,b,c);
if(c==0) printf("YES\n%llu %llu %llu",a,b,c+1);
} | |
You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order. | For each test case, print the answer: "NO" in the only line of the output if a solution doesn't exist; or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. | C | f4804780d9c63167746132c35b2bdd02 | 700b17cd0e59e9039f261ebce0b529ad | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1594996500 | ["5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$). | ["YES\n3 2 1\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000"] | #include<stdio.h>
int g[5];
int main()
{
int t;
scanf("%d",&t);
while(t--){
int x,y,z;
int a,b,c;
int i;
scanf("%d%d%d",&x,&y,&z);
if(x==y && y==z)
{
printf("YES\n%d %d %d\n",x,y,z);
goto end;
}
a=x;
b=y;
c=z;
if(a==b)
a=a/b;
if(b==c)
b=b/c;
if(c==a)
c=c/a;
i=0;
g[i]=a>=b?a:b;
i++;
g[i]=a>=c?a:c;
i++;
g[i]=b>=c?b:c;
for(i=0;i<3;i++)
{
if(g[i]==x)
{
g[i]=-99;
x=-99;
}
if(g[i]==y)
{
g[i]=-99;
y=-99;
}
if(g[i]==z)
{
g[i]=-99;
z=-99;
}
}
for(i=0;i<3;i++)
{
if(g[i]!=-99)
{
printf("NO\n");
goto end;
}
}
printf("YES\n");
printf("%d %d %d\n",a,b,c);
end: continue;
}
} | |
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces).Your task is to write a part of the program, responsible for «standardization» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format l1-r1,l2-r2,...,lk-rk, where ri + 1 < li + 1 for all i from 1 to k - 1, and li ≤ ri. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element i from the new sequence li = ri, this element should be output as li, and not as «li - li».For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6. | Output the sequence in the required format. | C | 3969ba3e3eb55a896663d2c5a5bc4a84 | b6e84b17feaba2e03952931f6c6750db | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings",
"expression parsing",
"strings"
] | 1286802000 | ["1,2,3,1,1,2,6,6,2", "3,2,1", "30,20,10"] | null | PASSED | 1,300 | standard input | 2 seconds | The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row. | ["1-3,6", "1-3", "10,20,30"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
char bigstr[600];
//int my_array[] = { 10, 5, 25, 15, 20, 30 };
int comparetor (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main()
{
char str[1000];
char c;
int a[1000];
int s,i,j,b,k,l,prev,last;
s=0;
i=0;
b=0;
scanf("%s",bigstr);
//c=bigstr[0];
while(1)
{c=bigstr[b];
//scanf("%c",&c);
if(c==',')
{str[s]='\0';
s=0;
a[i]=atoi(str);
i++;
b++;
continue;
}
else if(c=='\0')
{
str[s]='\0';
a[i]=atoi(str);
b++;
break;
}
else
{
str[s]=c;
s++;
b++;
}
}
//for(j=0;j<=i;j++)
//printf("%d\n",a[j]);
if(i==0){
printf("%d",a[i]);
return 0;}
qsort (a, i+1, sizeof(int), comparetor );
//for(j=0;j<i;j++)
// printf("%d ",a[j]);
//printf("\n");
for(j=0;j<i;j++){
//printf("%d\n",a[j]);
k=j+1;
while(a[k]==a[k-1] || a[k]==a[k-1]+1)
k++;
if(k-j==1){
if(j==0)
printf("%d",a[j]);
else
printf(",%d",a[j]);
continue;
}
else{
if(a[j]==a[k-1])
{if(j==0)
printf("%d",a[j]);
else
printf(",%d",a[j]);
}
else{
if(j==0)
printf("%d-%d",a[j],a[k-1]);
else
printf(",%d-%d",a[j],a[k-1]);
}
j=k-1;
continue;
}}
if(j==i)
printf(",%d",a[i]);
} | |
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces).Your task is to write a part of the program, responsible for «standardization» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format l1-r1,l2-r2,...,lk-rk, where ri + 1 < li + 1 for all i from 1 to k - 1, and li ≤ ri. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element i from the new sequence li = ri, this element should be output as li, and not as «li - li».For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6. | Output the sequence in the required format. | C | 3969ba3e3eb55a896663d2c5a5bc4a84 | 33a597630706b15f4178f6750f593866 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings",
"expression parsing",
"strings"
] | 1286802000 | ["1,2,3,1,1,2,6,6,2", "3,2,1", "30,20,10"] | null | PASSED | 1,300 | standard input | 2 seconds | The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row. | ["1-3,6", "1-3", "10,20,30"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 499
#define K 100
int compare(const void *a, const void *b) {
int ia = *(int *) a;
int ib = *(int *) b;
return ia - ib;
}
int main() {
static char s[N + 1];
static int aa[K], ll[K], rr[K];
int n, i, j, k, x;
scanf("%s", s);
n = strlen(s);
k = 0;
for (i = 0; i < n; ) {
j = i;
while (j < n && s[j] != ',') {
aa[k] = aa[k] * 10 + (s[j] - '0');
j++;
}
i = j + 1;
k++;
}
qsort(aa, k, sizeof *aa, compare);
x = 0;
for (i = 0; i < k; ) {
j = i + 1;
while (j < k && aa[j] <= aa[j - 1] + 1)
j++;
ll[x] = aa[i];
rr[x] = aa[j - 1];
x++;
i = j;
}
if (ll[0] < rr[0])
printf("%d-%d", ll[0], rr[0]);
else
printf("%d", ll[0]);
for (i = 1; i < x; i++) {
printf(",");
if (ll[i] < rr[i])
printf("%d-%d", ll[i], rr[i]);
else
printf("%d", ll[i]);
}
printf("\n");
return 0;
}
| |
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces).Your task is to write a part of the program, responsible for «standardization» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format l1-r1,l2-r2,...,lk-rk, where ri + 1 < li + 1 for all i from 1 to k - 1, and li ≤ ri. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element i from the new sequence li = ri, this element should be output as li, and not as «li - li».For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6. | Output the sequence in the required format. | C | 3969ba3e3eb55a896663d2c5a5bc4a84 | 11f1f215bfe2fe55fa73c802070fb247 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings",
"expression parsing",
"strings"
] | 1286802000 | ["1,2,3,1,1,2,6,6,2", "3,2,1", "30,20,10"] | null | PASSED | 1,300 | standard input | 2 seconds | The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row. | ["1-3,6", "1-3", "10,20,30"] | /* https://codeforces.com/contest/34/submission/20931503 (rainboy) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define A 1000
int main() {
static char s[1024], good[A + 1], *t, cc[1048576], *p = cc;
int k, l, r, first;
scanf("%s", s);
k = 0;
for (t = strtok(s, ","); t != NULL; t = strtok(NULL, ","))
good[atoi(t)] = 1;
first = 1;
for (l = 1; l <= A; l = r) {
while (l <= A && !good[l])
l++;
r = l + 1;
while (r <= A && good[r])
r++;
if (l <= A) {
if (!first)
p += sprintf(p, ",");
first = 0;
p += sprintf(p, "%d", l);
if (l < r - 1)
p += sprintf(p, "-%d", r - 1);
}
}
printf("%s\n", cc);
return 0;
}
| |
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces).Your task is to write a part of the program, responsible for «standardization» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format l1-r1,l2-r2,...,lk-rk, where ri + 1 < li + 1 for all i from 1 to k - 1, and li ≤ ri. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element i from the new sequence li = ri, this element should be output as li, and not as «li - li».For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6. | Output the sequence in the required format. | C | 3969ba3e3eb55a896663d2c5a5bc4a84 | d846ce5ed0fafa499821512a2c52af72 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings",
"expression parsing",
"strings"
] | 1286802000 | ["1,2,3,1,1,2,6,6,2", "3,2,1", "30,20,10"] | null | PASSED | 1,300 | standard input | 2 seconds | The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row. | ["1-3,6", "1-3", "10,20,30"] | #define TYPE int
#define CMP(a, b) (b-a)
//#define LOG(a) fprintf(LOGFILE, "%d", a)
/*quirinpa gist.github.com*/
#ifndef AVL_H
#define AVL_H
/* creates a mask that can be applied each time we need to invert
* a value depending on the boolean that was provided
* to new_bool_inv_mask(bool) aka bool?value:-value, this
* is done to prevent forking. Am i right to do it like so? */
#include <stdbool.h>
__inline__
static signed char
new_bool_inv_mask(bool value) {
return (signed char) ~( ((int)value) * 0xff );
}
/* applies a mask created with new_bool_inv_mask() */
__inline__
static signed char
apply_mask(register signed char balance, register signed char mask)
{
return (signed char)
( ((int)(balance^mask)) + (mask&1) );
}
#endif
#ifndef LOGFILE
#define LOGFILE stderr
#endif
#ifdef LOG
#include <stdio.h>
#endif
#define AVL_NODE struct AVL_NODE_##TYPE
AVL_NODE {
signed char balance;
AVL_NODE *left, *right, *parent;
TYPE data;
};
/* We use this to measure the height of the subtree rooted at c. See:
*
* https://upload.wikimedia.org/wikipedia/commons/c/c4/The_Rebalancing.gif
*
* We then infer the heights of the children d, b and a, respectively,
* in order to calculate node balances afterwards, something implemented
* for the performance benefits of it vs calculating or storing heights. */
#define GET_HEIGHT GET_HEIGHT_##TYPE
#include <stddef.h>
__inline__ static size_t
GET_HEIGHT(register AVL_NODE *curr) {
register size_t h = 0;
while (curr) {
h++;
curr = *( &curr->left + (curr->balance > 0) );
}
return h;
}
/* refer to:
* https://upload.wikimedia.org/wikipedia/commons/c/c4/The_Rebalancing.gif */
#define REBALANCE REBALANCE_##TYPE
static AVL_NODE* REBALANCE(AVL_NODE *n, bool n_rheavy, signed char n_balance) {
AVL_NODE **ns_heaviest_ref = &n->left + n_rheavy,
*f = *ns_heaviest_ref;
signed char f_balance = f->balance;
/* FIXME !f_balance is here just for some delete situations.. how to optimize? */
bool same_dir = n_balance == (f_balance<<1) || !f_balance,
/* is f's tallest subtree to the right? */
f_rheavy = same_dir == n_rheavy;
AVL_NODE **fs_left_child_ref = &f->left,
**fs_heaviest_ref = fs_left_child_ref + f_rheavy,
*l = *fs_heaviest_ref,
**ls_left_child_ref = &l->left,
**ls_c_ref = ls_left_child_ref + !f_rheavy,
*c = *ls_c_ref,
**ns_parent_ref = &n->parent,
*ns_parent = *ns_parent_ref;
signed char imask_n_rheavy = new_bool_inv_mask(n_rheavy),
imask_f_rheavy = new_bool_inv_mask(f_rheavy),
l_balance = l->balance;
size_t c_height = GET_HEIGHT(c),
d_height = ( size_t ) ( (long long int)c_height +
apply_mask(l_balance, imask_f_rheavy) ),
l_height = (c_height>d_height?c_height:d_height) + 1,
b_height = ( size_t ) ( (long long int)l_height -
apply_mask(f_balance, imask_f_rheavy) ),
a_height = ( size_t ) ( (long long int)l_height + 1 -
apply_mask(n_balance, imask_n_rheavy) );
/* fprintf(LOGFILE, "{dh:%zu, lh:%zu, bh:%zu, ah:%zu}", */
/* d_height, l_height, b_height, a_height); */
#ifdef LOG
fputs(n_rheavy?">":"<", LOGFILE);
fputs((same_dir == n_rheavy)?">":"<", LOGFILE);
#endif
if (same_dir) { /* one rotation */
n->balance = apply_mask((signed char)
b_height - a_height, imask_n_rheavy);
f->balance = apply_mask((signed char) /* FIXME problem is here */
l_height - ((b_height>a_height?b_height:a_height) + 1),
imask_n_rheavy);
/* fprintf(LOGFILE, "{nb:%d, fb:%d}", n->balance, f->balance); */
*ns_parent_ref = f;
{
AVL_NODE **fs_lightest_ref = fs_left_child_ref + !f_rheavy,
*b = *fs_lightest_ref;
if (b) b->parent = n;
f->parent = ns_parent;
if (ns_parent) *(&ns_parent->left + (n == ns_parent->right)) = f;
*fs_lightest_ref = n;
*ns_heaviest_ref = b;
}
return f;
}
/* two */
n->balance = apply_mask((signed char)
(d_height - a_height), imask_n_rheavy);
f->balance = apply_mask((signed char)
(b_height - c_height), imask_n_rheavy);
l->balance = apply_mask((signed char)
( (b_height>c_height?b_height:c_height) -
(d_height>a_height?d_height:a_height)
), imask_n_rheavy);
*ns_parent_ref = l;
f->parent = l;
{
register AVL_NODE **ls_d_ref = ls_left_child_ref + f_rheavy,
*d = *ls_d_ref;
if (d) d->parent = n;
if (c) c->parent = f;
l->parent = ns_parent;
if (ns_parent) *(&ns_parent->left + (n == ns_parent->right)) = l;
*fs_heaviest_ref = c;
*ls_c_ref = f;
*ns_heaviest_ref = d;
*ls_d_ref = n;
}
return l;
}
#include <stdlib.h>
#define AVL_INSERT AVL_INSERT_##TYPE
AVL_NODE * AVL_INSERT(AVL_NODE *root, TYPE data) {
AVL_NODE *l = (AVL_NODE*) malloc(sizeof(AVL_NODE));
l->left = l->right = NULL;
l->balance = 0;
l->data = data;
if (root) {
register AVL_NODE **n_r = &root, *n;
register int side;
register bool bside;
do {
n = *n_r;
side = CMP(n->data, data);
bside = side>0;
n_r = &n->left + bside;
#ifdef LOG
fputs(bside?"r":"l", LOGFILE);
#endif
} while (*n_r);
#ifdef LOG
LOG(data);
#endif
l->parent = n;
*n_r = l;
{
register AVL_NODE *p;
avl_insert_go_up:
{
signed char *n_balance_r = &n->balance,
n_balance = (*n_balance_r + (bside<<1) - 1);
if (n_balance) {
if ((n_balance&3) == 2) {
n = REBALANCE(n, bside, n_balance);
} else {
*n_balance_r = n_balance;
if ((p = n->parent)) {
bside = n == p->right;
n = p;
goto avl_insert_go_up;
}
return root;
}
} else *n_balance_r = 0;
}
if (!(p = n->parent)) return n;
return root;
}
}
#ifdef LOG
LOG(data);
#endif
l->parent = NULL;
return l;
}
#define AVL_FIND AVL_FIND_##TYPE
AVL_NODE *AVL_FIND(AVL_NODE *root, TYPE data) {
if (root) {
register AVL_NODE **parent_ref = &root, *parent;
register int side;
do {
parent = *parent_ref;
side = CMP(parent->data, data);
if (!side) return parent;
parent_ref = &parent->left + (side>0);
} while (*parent_ref);
}
return NULL;
}
#include<stdio.h>
int l=-1,y;AVL_NODE *nn;void print(AVL_NODE *n){
if(!n)return;print(n->left);if(n->data>l+1){l=n->data;printf("%d",l);if(AVL_FIND(nn,l+1))printf("-");else l<y?printf(","):0;}else{l=n->data;if(!AVL_FIND(nn,l+1)){printf("%d",l);l<y?printf(","):0;}}print(n->right);}
int main(){char c;do{int x;scanf("%d",&x);if(!AVL_FIND(nn,x))nn = AVL_INSERT(nn,x);x>y?y=x:0;scanf("%c",&c);}while(c==',');print(nn);printf("\n");return 0;} | |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 77993338414f9c25503b00adea887895 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] |
#include <stdio.h>
int main(void) {
int t;
scanf("%d",&t);
while(t--){
int n,c=0;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]%2!=0)
c++;
}
if((c==n && n%2==0) || c==0)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 48fef790564c208ce2512f91d33abc40 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int i,n,t,a,sum,det1,det2,j;
scanf("%d", &t);
for(i=0;i<t;i++)
{
scanf("%d", &n);
sum=det1=det2=0;
for(j=0;j<n;j++)
{
scanf("%d", &a);
if(a%2==0)det1=1;
else det2=1;
sum+=a;
}
if(sum%2!=0)printf("YES\n");
else{
if(det2==0||(det1==0&&n%2==0))printf("NO\n");
else if((det1==1&&det2==1)||(n%2!=0&&det2==1))printf("YES\n");
}
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 37c849ffe9481e7b8081f9a9c2e230b8 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int t,n,a[2000],i,c=0,k=0,flag=0;
scanf("%d",&t);
while(t--)
{
flag=0;
c=0;
k=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
if(n%2==0)
{
for(i=0;i<n;i++)
{
if(a[i]%2==0)
{
c++;
}
}
if(c==0)
{
flag=1;
}
}
else
{
for(i=0;i<n;i++)
{
if(n%2!=0)
{
if(a[i]%2==0)
{
k++;
}
}
}
}
if(c==n || k==n ||flag==1 )
{
printf("NO\n");
}
else
{
printf("YES\n");
}
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 7bdb8dd1c19f16fc20bf85be4a1468ad | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int a,b,sum,count;
scanf("%d",&a);
for(int i=0;i<a;i++)
{ sum=0,count=0;
scanf("%d",&b);
int s[b];
for(int j=0;j<b;j++)
{
scanf("%d",&s[j]);
sum+=s[j];
if(s[j]%2!=0)
count++;
}
if(sum%2)
printf("YES\n");
else if(count!=0&&count!=b)
printf("YES\n");
else
printf("NO\n");
}
return 0;
} | |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | f908b7789741018c871f16576d2954ae | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
for (int i=0;i<t;i++)
{
int n;
scanf("%d",&n);
int a[n];
int e=0,o=0;
for (int j=0;j<n;j++)
{
scanf("%d",&a[j]);
if (a[j]%2==0)
e++;
else
o++;
}
if (o==0)
printf("NO\n");
else if (e==0 && n%2==0)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 4216ca2fef3aa65423ed9c7520672b6d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
int main(){
int n;
scanf("%d", &n);
while(n--){
int a, odd = 0, even = 0;
unsigned long long int toplam = 0;
scanf("%d", &a);
int arr[a];
for(int i = 0; i < a; i++){
scanf("%d", &arr[i]);
if(arr[i] % 2 == 0){
even++;
}
else{
odd++;
}
toplam += arr[i];
}
printf("%s", toplam % 2 == 1 ? "YES\n" : odd != 0 && even != 0 ? "YES\n" : "NO\n");
}
} | |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 185f165583f43535ea807105afac7814 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n,i,j,l;
scanf("%d\n",&n);
for(int k=0;k<n;k++)
{ int o=0,e=0;
scanf("%d\n",&l);
int *a=(int*)calloc(l,sizeof(int));
for(int m=0;m<l;m++)
{
scanf("%d",a+m);
if(*(a+m)%2!=0)
o++;
else
e++;
}
if(o==0)
printf("NO\n");
else if(o%2==0 && e==0)
printf("NO\n");
else
printf("YES\n");
}
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | f208eb72c2b023c166770dab59cd70d3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int t,n,i,a[2000],x=0;
scanf("%d",&t);
while(t>0){
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&a[i]);
if(a[i]%2!=0)
x=x+1;
}
if((n==x&&n%2==0)||x==0){
printf("NO\n");
}
else{
printf("YES\n");
}
t=t-1;
x=0;
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 65f1c3d3091b631a849adee64ce8bbac | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int t,n,a[2000],i,c,s;
scanf("%d",&t);
while(t--)
{
c=0;s=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
s=s+a[i];
if(a[i]%2==0)c++;
}
if(s%2!=0)printf("YES\n");
else
{
if(n-c>0 && c!=0)printf("YES\n");
else printf("NO\n");
}
}
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 228c589bd1de3b1b641db45a141048d3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int i,j,t,n,k;
scanf("%d",&t);
while(t--)
{
int sum=0,y=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&k);
sum+=k;
if(k%2==0)
y++;
}
if(sum%2==1)
printf("YES\n");
else if(y==n || y==0)
printf("NO\n");
else
printf("YES\n");
}
return 0;
} | |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 5eed41db561b4b072226e70c08957c22 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int T,t,i,j,n,s;
scanf("%d",&T);
while(T--){
s=0;
t=0;
scanf("%d",&n);
int ara[n];
for(i=0;i<n;i++){
scanf("%d",&ara[i]);
s=s+ara[i];
}
if(s%2!=0)
t=1;
else{
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(ara[i]%2==0 && ara[j]%2!=0){
t=1;
break;
}
}
if(t==1)
break;
}
}
if(t==1)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | bf7219e9ce3ecc425b01d6ae15a84f9b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int T,t,i,j,n,s;
scanf("%d",&T);
while(T--){
s=0;
t=0;
scanf("%d",&n);
int ara[n];
for(i=0;i<n;i++){
scanf("%d",&ara[i]);
s=s+ara[i];
}
if(s%2!=0)
t=1;
else{
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(ara[i]%2==0 && ara[j]%2!=0){
t=1;
break;
}
}
if(t==1)
break;
}
if(t==0){
for(i=n-1;i>0;i--){
for(j=i-1;j>=0;j--){
if(ara[i]%2==0 && ara[j]%2!=0){
t=1;
break;
}
}
if(t==1)
break;
}
}
}
if(t==1)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | dbbf436feef795eab299983a60ab6809 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
int ktra(int a[], int n) {
int x=0, y=0;
for (int i=0; i<n; ++i) {
if (a[i]%2==0) x=1;
else y=1;
}
if (n%2!=0 && x==0) return 1;
else if (x>=1 && y>=1) return 1;
return 0;
}
int main (){
int n ;
scanf("%d",&n);
for (int i=1;i<=n;i++){
int m;
scanf ("%d",&m);
int a[m+5];
for (int j=0;j<m;j++){
scanf ("%d",&a[j]);
}
if (ktra(a,m)) printf("YES\n");
else if (!ktra(a,m)) printf("NO\n");
}
return 0;
} | |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 1a4c76b3c9880aaadb7d2ab6b755f503 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
#include<stdlib.h>
int main(){
int n,i,t,el,k,even,odd;
char temp;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++){
odd=0;
even=0;
scanf("%d",&t);
for(k=0;k<t;k++){
scanf("%d%c",&el,&temp);
if( el%2 == 0 )
even++;
if( el%2 == 1 )
odd++;
}
if(even==t || (odd==t && t%2==0) )
a[i]=0;
else
a[i]=1;
}
for(i=0;i<n;i++){
if(a[i]==0)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
//1052 445 683 995 722 1012 1263
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | a1de8be0373f309dea01150f424628e7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int t, n, a[2010], i, j, odd, even;
scanf("%d", &t);
while(t--){
odd=0;
even=0;
scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%d", &a[i]);
if(a[i]%2!=0)
odd++;
else
even++;
}
if((odd == n && n%2!=0)||(odd<n && odd!=0))
printf("YES\n");
else
printf("NO\n");
}
return 0;
} | |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 33ce3994ed56d99b8ad8e97d2ff8b8b2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
int i,ara[n];
int sum=0,odd=0,even=0;
for(i=0;i<n;i++)
{
scanf("%d",&ara[i]);
if(ara[i]%2!=0||ara[i]==1)
{
odd++;
}
else{
even++;
}
sum=sum+ara[i];
}
if (sum%2!=0||sum==1)
printf("YES\n");
else
{
if (odd!=0&&even!=0)
printf("YES\n");
else
printf("NO\n");
}
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | 1fd0ce5567d791c2ac2308bf1da1cafa | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include <stdio.h>
int main()
{
int x,o,e;
scanf("%d",&x);
int y,z,arr[2020],sum,c,j,sum1;
for(int i=0; i<x; i++)
{
sum=0;
c=0,o=0,e=0,sum1=0;
scanf("%d",&y);
for( j=0; j<y; j++)
{
scanf("%d",&z);
arr[j]=z;
sum+=z;
}
// printf("%d\n",sum);
if(sum%2!=0)
printf("YES\n");
else
{
for(j=0; j<y; j++)
{
if(arr[j]%2==0)
c++;
}
if(c==y)
printf("NO\n");
else if(c==0)
printf("NO\n");
else
{
for(j=0; j<y; j++)
{
o++;
if(arr[j]%2!=0)
break;
}
for(j=0; j<y; j++)
{
e++;
if(arr[j]%2==0)
break;
}
arr[e]=arr[o];
//for(j=0; j<y; j++)
//sum1+=arr[j];
// if(sum1%2!=0)
printf("YES\n");
//else
// printf("NO\n");
}
}
}
return 0;
}
| |
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | C | 2e8f7f611ba8d417fb7d12fda22c908b | ce7d82189a79c3fe08923100fe3aebb0 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1580826900 | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$). | ["YES\nNO\nYES\nNO\nNO"] | #include<stdio.h>
int main() {
int n, a, b, c ,d, j,m,l, temp;
scanf("%d",&c);
for (int j = 0; j <c ; ++j) {
scanf("%d",&n);
l=0;
for (int i = 0; i < n; i++) {
scanf("%d",&a);
if(a%2!=0)
l++;
}
if (l==n&&n%2==0||l==0){
printf("NO\n");
}
else{
printf("YES\n");
}
}}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 747fc9f697eb0f8454a21a4890b62b5d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #pragma warning (disable: 4996)
#include <stdio.h>
#include <stdio.h>
int main(void)
{
int n, p, q, k, ps, qs, did, m, j, l;
char str[101];
scanf("%d %d %d", &n, &p, &q);
scanf("%s", str);
k = 0;
ps = 0;
qs = 0;
m = n;
while (n > 0)
{
did = 0;
if (n % p == 0)
{
n -= p;
ps++;
did = 1;
}
else if (n % q == 0)
{
n -= q;
qs++;
did = 1;
}
else if (n - p >= 0)
{
n -= p;
ps++;
did = 1;
}
else if (n - q >= 0)
{
n -= q;
qs++;
did = 1;
}
if (!did)
break;
}
l = 0;
if (n != 0)
{
printf("-1\n");
return 0;
}
else
{
k = ps + qs;
printf("%d\n", k);
for (int i = ps; i > 0; i--)
{
for (j = 1; j <= p; j++)
putchar(str[l++]);
putchar('\n');
}
for (int i = qs; i > 0; i--)
{
for (j = 1; j <= q; j++)
putchar(str[l++]);
putchar('\n');
}
}
return 0;
} | |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 983795ea5645a4d490e90e40e519c8a3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main()
{
int n,q,p,i,j,m,k,l,trouve=0;
scanf("%d %d %d",&n,&p,&q);
char s[150];
scanf("%s",&s);
if(q+p==n){
trouve=1;
printf("2\n");
for(i=0;i<p;i++)
printf("%c",s[i]);
printf("\n");
for(j=p;j<n;j++)
printf("%c",s[j]);
}
else {
for(i=0;i*p<=n;i++){
for(j=0;j*q<=n;j++){
if(i*p+j*q==n)
break;
}
if(i*p+j*q==n){
printf("%d\n",i+j);
trouve=1;
m=0;
for(k=0;k<i;k++){
int l=0;
while(l<p){
printf("%c",s[m]);
m++;
l++;
}
printf("\n");
}
for(k=0;k<j;k++){
int l=0;
while(l<q){
printf("%c",s[m]);
m++;
l++;
}
printf("\n");
}
break;
}
}
}
if (trouve==0)
printf ("-1");
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 011fa852e7905ef740e613fc2ac7788f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include<stdio.h>
int main()
{
int a,b,c;
char niz[500];
int p,q,s;
scanf("%d%d%d",&p,&q,&s);
getchar();
gets(niz);
int stop=0;
int indikator=0;
for(a=0;a<100;a++){
for(b=0;b<100;b++){
if( ( (a*q) + (b*s) ) == p){
indikator=1;
goto end;
}
}
}
end:;
char *x=niz;
if(!indikator)
printf("%d",-1);
else{
printf("%d\n",a+b);
for(c=1;c<=a*q;c++){
putchar(*x++);
if(c%q==0)
printf("\n");
}
for(c=1;c<=b*s;c++){
putchar(*x++);
if(c%s==0 && c!=b*s)
printf("\n");}
}
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | d6cc603a7c293ed7cc7e87845299f21f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,p,q,i=0,j,a,b,c=0;
scanf("%d%d%d",&n,&p,&q);
char A[n+1];
scanf("%s",A);
if((p+q)==n){
printf("2\n");
for(i=0;i<p;i++){
printf("%c",A[i]);
}
printf("\n");
for(i=p;A[i]!='\0';i++){
printf("%c",A[i]);
}
}
else if((2*p==n)){
printf("2\n");
for(i=0;i<p;i++){
printf("%c",A[i]);
}
printf("\n");
for(i=p;A[i]!='\0';i++){
printf("%c",A[i]);
}
}
else if((2*q==n)){
printf("2\n");
for(i=0;i<q;i++){
printf("%c",A[i]);
}
printf("\n");
for(i=q;A[i]!='\0';i++){
printf("%c",A[i]);
}
}
else if(n%p==0){
printf("%d\n",n/p);
int k=0;
while(n>0){
for(i=k;i<(k+p);i++){
printf("%c",A[i]);
}
printf("\n");
k=k+p;
n=n-p;
}
}
else if(n%q==0){
printf("%d\n",n/q);
int k=0;
while(n>0){
for(i=k;i<(k+q);i++){
printf("%c",A[i]);
}
printf("\n");
k=k+q;
n=n-q;
}
}
else if(n==p||n==q){
printf("1\n");
puts(A);
}
else if(p+q>n){
printf("-1");
}
else {
if(p<q){
a=p;
b=q;
}
else{
a=q;
b=p;
}
j=n;
while(j%a!=0&&j>0){
c++;
j=j-b;
}
if((j)%a==0&&j>0){
while(j-a>=0){
c++;
j=j-a;
}
printf("%d\n",c);
int k=0;
while(n%a!=0&&n>0){
for(i=k;i<(k+b);i++){
printf("%c",A[i]);
}
printf("\n");
k=k+b;
n=n-b;
}
while(n-a>=0){
for(i=k;i<(k+a);i++){
printf("%c",A[i]);
}
k=k+a;
n=n-a;
printf("\n");
}
}
else
printf("-1");
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 7ed11c5561c018fa93e4f85b4ab3a1b3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include<stdio.h>
#include<string.h>
int main()
{
int a,b,c,i,j,k=-1,n=0,t,w;
scanf("%d%d%d",&a,&b,&c);
char str[a+1];
scanf("%s",str);
if(b+c==a)
{ puts("2");
for(i=0;i<b;i++)
{
printf("%c",str[i]);
}
printf("\n");
for(i=b;i<a;i++)
{
printf("%c",str[i]);
}
}
else if(a%c==0)
{
printf("%d\n",a/c);
for(i=1;i<=a/c;i++)
{
for(j=0;j<c;j++)
{
k++;
printf("%c",str[k]);
}
printf("\n");
}
}
else if(a%b==0)
{
printf("%d\n",a/b);
for(i=1;i<=a/b;i++)
{
for(j=0;j<b;j++)
{
k++;
printf("%c",str[k]);
}
printf("\n");
}
}
else
{ i=a;
while(i%c!=0&&i>=0)
{
i=i-b;
n++;
}
if(i%c==0&&i>=0)
{
t=i/c;
printf("%d\n",t+n);
for(i=1;i<=n;i++)
{
for(j=0;j<b;j++)
{
k++;
printf("%c",str[k]);
}
printf("\n");
}
for(i=1;i<=t;i++)
{
for(j=0;j<c;j++)
{
k++;
printf("%c",str[k]);
}
printf("\n");
}
}
else if(i<=0)
{
puts("-1");
}
}
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 782dbb89d7cb6f6d76b164755a19213a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | /* Coached by rainboy */
#include <stdio.h>
int main() {
static char s[128];
int n, p, q, k, l, h, i;
scanf("%d%d%d%s", &n, &p, &q, s);
l = -1;
for (k = 0; k * p <= n; k++)
if ((n - k * p) % q == 0) {
l = (n - k * p) / q;
break;
}
if (l == -1) {
printf("-1\n");
return 0;
}
printf("%d\n", k + l);
for (h = 0; h < k; h++) {
for (i = h * p; i < (h + 1) * p; i++)
printf("%c", s[i]);
printf("\n");
}
for (h = 0; h < l; h++) {
for (i = h * q; i < (h + 1) * q; i++)
printf("%c", s[k * p + i]);
printf("\n");
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 43b7e98d2c4b9ee62a5b68b595570b6d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
int main(void) {
int n,p,q;
scanf("%i %i %i\n",&n,&p,&q);
int f=0;
int t=0;
int j=0;
int odd;
int choto;
int v;
if(n%p==0){
t=n/p;
j=p;
}
else{
if(n%q==0){
t=n/q;
j=q;
}
else{
if(n==(p+q)){
t=2;
f=1;
}
else{
if(p+q<n){
if(p>q){
odd=p;
choto=q;
}
else{
odd=q;
choto=p;
}
int sum;
int cnt=1;
int baki;
while(sum<n){
sum=odd*cnt;
baki=n-sum;
if(sum<n){
if(baki%choto==0){
sum=n;
break;
}
}
cnt++;
}
if(sum==n){
v=cnt;
baki=n-odd*v;
t=v+(baki/choto);
f=2;
}
else{
t=-1;
}
}
else{
t=-1;
}
}
}
}
printf("%i\n",t);
if(f==1){
int m;
if(p<q){
m=p;
}
else{
m=q;
}
int l=0;
while(l<2){
int x=0;
if(l==0){
x=m;
}
else{
x=n-m;
}
char c;
int y=0;
while(y<x){
scanf("%c",&c);
printf("%c",c);
y++;
}
printf("\n");
l++;
}
}
else{
if(f==0){
int i=0;
while(i<t){
char c;
int k=0;
while(k<j){
scanf("%c",&c);
printf("%c",c);
k++;
}
printf("\n");
i++;
}
}
else{
int l=0;
while(l<v){
char c;
int y=0;
while(y<odd){
scanf("%c",&c);
printf("%c",c);
y++;
}
printf("\n");
l++;
}
l=0;
v=t-v;
while(l<v){
char c;
int y=0;
while(y<choto){
scanf("%c",&c);
printf("%c",c);
y++;
}
printf("\n");
l++;
}
}
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | dcd76faa89990bad6b482701b38b5a4b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
#include <stdlib.h>
int main(){
int n,p,q,i;
char str[200]={0};
scanf("%d%d%d",&n,&p,&q);
getchar();
fgets(str,200,stdin);
if(str[n]=='\n')str[n]='\0';
int first=0,second=0;
for(i=0;i<=n/p;i++){
int other=n-p*i;
if(other<0) break;
if(other==0){
first=i;
break;
}
else if(!(other%q)){
first=i;
second=other/q;
break;
}
}
if(first==0&&second==0) printf("-1\n");
else{
int j,k=0;
printf("%d\n",first+second);
for(i=0;i<first;i++){
for(j=0;j<p;j++){
printf("%c",str[k++]);
}
puts("");
}
for(i=0;i<second;i++){
for(j=0;j<q;j++)printf("%c",str[k++]);
puts("");
}
}
return 0;
} | |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 11f8b0dbcd630e586d1e82fea0c9a648 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
int x,y;
int s,p;
int dp(int n)
{
int i,d,n2;
for(i=0;i<=n;i++)
{
d=i*s;
n2=n-d;
if(n2<0)break;
if(n2%p==0)
{
x=i;
y=n2/p;
return 1;
}
}
return 0;
}
int main()
{
int n;
int i,k=0,j,a, b;
scanf("%d %d %d\n",&n,&s,&p);
if(dp(n))
{
char input[150];
fgets(input,120,stdin);
int i,j=0,k,z;
z=x+y;
printf("%d\n", z);
for(i=0;i<z;i++)
{
if(x)
{
x--;
k=s;
}
else k=p;
while(k--)printf("%c", input[j++]);
printf("\n");
}
}
else
{
printf("-1\n");
}
return 0;
} | |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | b071c95f3e46526afd7be655ac68409c | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
int main()
{
int i ,q,p,n,j;
scanf("%d %d %d",&n,&p,&q);
char str[n+1];
scanf("%s",str);
if (n%p==0)
{
printf("%d\n",n/p);
for(i=0; i<n; i++)
{
if(i%p==0&&i!=0)
printf("\n");
printf("%c",str[i]);
}
}
else if (n%q==0)
{
printf("%d\n",n/q);
for(i=0; i<n; i++)
{
if(i%q==0&&i!=0)
printf("\n");
printf("%c",str[i]);
}
}
else
{
int big,small,split,numbig=0,numsmall=0,tmp = n ;
if(p>q)
{
big=p;
small=q;
}
else
{
big=q;
small=p;
}
while(tmp>0)
{
tmp-=big;
numbig++;
if(tmp%small==0&&tmp>0)
{
numsmall=tmp/small;
break;
}
}
if(numsmall!=0)
{
split = numbig+numsmall;
printf("%d",split);
j=0 ;
while(numbig)
{
printf("\n");
for(i=0; i<big; i++,j++)
printf("%c",str[j]);
numbig--;
}
while(numsmall)
{
printf("\n");
for(i=0; i<small; i++,j++)
printf("%c",str[j]);
numsmall--;
}
}
else
{
printf("-1");
}
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 9beca48f3a39a7fc31764842e6a666df | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
int main()
{
int n, p, q, flg = 0;
scanf("%d %d %d", &n, &p, &q);
char str[101] = { 0 };
scanf("%s", str);
int P = n / p, Q = n / q;
for (int i = 0; i <= P; i++) {
for (int j = 0; j <= Q; j++) {
if (i * p + j * q != n) continue;
flg = 1;
P = i, Q = j;
break;
}
}
if (!flg) P = 0, Q = 0;
printf("%d\n", P + Q == 0 ? -1 : P + Q);
int pos = 1;
for (; pos <= P * p; pos++) {
printf("%c", str[pos - 1]);
if (pos % p == 0) printf("\n");
}
for (; pos <= P * p + Q * q; pos++) {
printf("%c", str[pos - 1]);
if ((pos - P * p) % q == 0) printf("\n");
}
return 0;
} | |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 147a4e8522071f3c8b2fd71ebc154a34 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include<stdio.h>
#include<string.h>
int main()
{
char str[1010];
int n,p,q,i,x,y,j,aux;
scanf("%d%d%d",&n,&p,&q);
scanf("%s",str);
if(n%p==0){
printf("%d\n",n/p);
for(i=1;i<=n;i++){
printf("%c",str[i-1]);
if(i%p==0)printf("\n");
}
}else if(n%q==0){printf("%d\n",n/q);
for(i=1;i<=n;i++){
printf("%c",str[i-1]);
if(i%q==0) printf("\n");
}
}else
{
aux=0;
for(i=0;i<=n;i++)
for(j=0;j<=n;j++)
{
if(i*p+j*q==n){
x=i;
y=j;
aux=1;
break;
}
}
if(!aux) printf("-1\n");
else
{
printf("%d\n",x+y);
for(i=1;i<=x*p;i++){
printf("%c",str[i-1]);
if(i%p==0)printf("\n");
}
for(i=x*p+1;i<=n;i++){
printf("%c",str[i-1]);
if((i-x*p)%q==0)printf("\n");
}
}
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | e035bf64e2f875285d28067a5ad16d61 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include<stdio.h>
#include<string.h>
int main()
{
char str[1010];
int n,p,q,i,x,y,j,aux;
scanf("%d%d%d",&n,&p,&q);
scanf("%s",str);
if(n%p==0){
printf("%d\n",n/p);
for(i=1;i<=n;i++){
printf("%c",str[i-1]);
if(i%p==0)printf("\n");
}
}else if(n%q==0){printf("%d\n",n/q);
for(i=1;i<=n;i++){
printf("%c",str[i-1]);
if(i%q==0) printf("\n");
}
}else
{
aux=0;
for(i=0;i<=n;i++)
for(j=0;j<=n;j++)
{
if(i*p+j*q==n){
x=i;
y=j;
aux=1;
break;
}
}
if(!aux) printf("-1\n");
else
{
printf("%d\n",x+y);
for(i=1;i<=x*p;i++){
printf("%c",str[i-1]);
if(i%p==0)printf("\n");
}
for(i=x*p+1;i<=n;i++){
printf("%c",str[i-1]);
if((i-x*p)%q==0)printf("\n");
}
}
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 8cf7261c1912b98fb7a7b20280bdae85 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
#define SIZE 1000
int main()
{
int n, p, q, i, j;
int cnt = 0;
char s[SIZE];
// freopen("input.txt", "r", stdin);
scanf("%d %d %d\n", &n, &p, &q);
gets(s);
while (n % q != 0 && n >= p) {
++cnt;
n -= p;
}
if (n % q != 0)
puts("-1");
else {
printf("%d\n", cnt + n / q);
for (i = 0; i < cnt; i++) {
for (j = 0; j < p; j++)
putchar(s[i*p + j]);
printf("\n");
}
for (i = 0; i < n / q; i++) {
for (j = 0; j < q; j++)
putchar(s[cnt*p + i*q + j]);
printf("\n");
}
}
} | |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | a0fd340e6cc449fe5acd21f98dee979b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
int main()
{
int n,p,q,k=0,c=0,x,y,ant1,ant2;
char s[100];
scanf("%d %d %d",&n,&p,&q);
scanf("%s",&s);
if (n%p==0)
{
printf("%d\n",n/p);
for (int j=0;j<n;j++)
{
printf("%c",s[j]);
if ((j+1)%p==0)
printf("\n");
}
}
else if (n%q==0)
{
printf("%d\n",n/q);
for (int j=0;j<n;j++)
{
printf("%c",s[j]);
if ((j+1)%q==0)
printf("\n");
}
}
else
{
for (int j=0;j<n;j++)
{
if (j*p>n)
{
c=0;
break;
}
for (int h=0;h<n;h++)
{
if (h*q > n){
break;
}
if(j*p+h*q==n)
{
x=j;
y=h;
c=1;
}
}
if (c==1)
break;
}
if (c==1)
{
printf("%d\n",x+y);
int o=0;
for (int b=0;b<x;b++)
{
for (int m=0;m<p;m++)
printf("%c",s[o++]);
printf("\n");
}
for (int r=0;r<y;r++)
{
for (int m=0;m<q;m++)
printf("%c",s[o++]);
printf("\n");
}
}
else
printf("-1\n");
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | c33df6c78189be2000596433f2bf6385 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
#include <string.h>
int minmax(int a, int b, int *min, int *max)
{
*max=a>b?a:b;
*min=a<b?a:b;
}
int main()
{
int n,p,q,i,j,k,m;
char s[1000];
scanf("%d %d %d",&n,&p,&q);
scanf("%s",&s);
int duzina=strlen(s);
int brojac=0;
int brDelova=0;
int min, max;
int pcount=0,qcount=0;
minmax(p,q,&min,&max);
if(n%(max)==0)
{
i=0;
do
{
i=i+max;
brDelova+=1;
}
while(i!=duzina);
printf("%d\n",brDelova);
k=0;
while(brojac!=duzina)
{
for(i=k;i<max+k;i++)
{
printf("%c",s[i]);
brojac+=1;
}
k=i;
printf("\n");
}
return 0;
}
else if(n%(min)==0)
{
i=0;
do
{
i=i+min;
brDelova+=1;
}
while(i!=duzina);
printf("%d\n",brDelova);
k=0;
while(brojac!=duzina)
{
for(i=k;i<min+k;i++)
{
printf("%c",s[i]);
brojac+=1;
}
k=i;
printf("\n");
}
return 0;
}
else
{
for(i=1;i<=n/p;i++)
{
for(j=1;j<=n/j;j++)
{
if((i*p+j*q)==n)
{
pcount=i;
qcount=j;
break;
}
}
if(qcount!=0&&pcount!=0)
break;
}
if(pcount==0 && qcount==0)
{
printf("-1");
return 0;
}
printf("%d\n",brDelova=qcount+pcount);
k=0;
while (brojac!=qcount)
{
for(i=0+k;i<q+k;i++)
printf("%c",s[i]);
brojac+=1;
k=i;
printf("\n");
}
brojac=0;
while (brojac!=pcount)
{
for(i=0+k;i<p+k;i++)
printf("%c",s[i]);
brojac+=1;
k=i;
printf("\n");
}
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | b1c2ed7fd9f859598193de2f4724f549 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
#include <string.h>
#define SIZE 150
int main()
{
int n, p, q, i, cnt_p, cnt_q, flag_1 = 0, flag_2 = 0;
char s[SIZE];
scanf("%d %d %d\n", &n, &p, &q);
gets(s+1);
for (i = 1; i <= n; i++)
if (i % p == 0 && (n - i) % q == 0) {
flag_1 = 1;
break;
} else if (i % q == 0 && (n-i) % p == 0) {
flag_2 = 1;
break;
}
if (flag_1) {
printf("%d\n", i / p + (n - i) / q);
cnt_p = i / p;
cnt_q = (n - i) / q;
} else if (flag_2) {
printf("%d\n", i / q + (n - i) / p);
cnt_p = (n-i)/p;
cnt_q = i / q;
} else {
printf("-1");
return 0;
}
for (i = 1; i <= n; i++) {
printf("%c", s[i]);
if (i % p == 0 && cnt_p) {
cnt_p--;
printf("\n");
} else if (!cnt_p && (n-i)% q == 0 && cnt_q) {
cnt_q--;
printf("\n");
}
}
return 0;
}
| |
You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test). | If it's impossible to split the string s to the strings of length p and q print the only number "-1". Otherwise in the first line print integer k — the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right. If there are several solutions print any of them. | C | c4da69789d875853beb4f92147825ebf | 68f029e508ec2b32c6df1159c05a9d25 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1451055600 | ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100). The second line contains the string s consists of lowercase and uppercase latin letters and digits. | ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"] | #include <stdio.h>
int main(){
int n,p,q,p2,q2,tt=0;
scanf("%d%d%d",&n,&p,&q);
p2=p;
q2=q;
char kelime[n];
scanf("%s",kelime);
int i,j=0,j2=0;
if(p+q==n){
printf("2\n");
for(i=0;i<p;i++){
printf("%c",kelime[i]);
}
printf("\n");
for(i=p;i<n;i++){
printf("%c",kelime[i]);
}
return 0;
}else if(n%p==0){
printf("%d\n",n/p);
for(i=0;i<n/p;i++){
for(;j<p2;j++){
printf("%c",kelime[j]);
}
printf("\n");
p2+=p;
}
q2=q;
p2=p;
return 0;
}else if(n%q==0){
printf("%d\n",n/q);
for(i=0;i<n/q;i++){
for(;j<q2;j++){
printf("%c",kelime[j]);
}
printf("\n");
q2+=q;
}
q2=q;
p2=p;
return 0;
} else{
for(i=1;i<n;i++){
if((n-(i*p))%q==0 & p+q<=n & (n-(i*p))>=q){
printf("%d\n",i+((n-(i*p))/q));
for(j=0;j<i;j++){
for(;j2<p2;j2++){
printf("%c",kelime[j2]);
}
printf("\n");
p2+=p;
}
for(j=0;j<((n-(i*p))/q);j++){
for(;j2<n;j2++){
printf("%c",kelime[j2]);
tt+=1;
if(tt%q==0){
printf("\n");
}
}
printf("\n");
}
return 0;
}
}
printf("-1");
return 0;
}
}
| |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | 9de8e4b6f3fd04284ba288cf781a2c86 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include"stdio.h"
char cmmd[100100];
main()
{
long long n;
int t;
long long st,pos;
char *s;
scanf("%I64d%d",&n,&t);
while (t--){
scanf("%I64d%s",&st,&cmmd);
s=cmmd;
while (*s){
pos=st&(-st);
switch (*s){
case 'L' :{
st-=(pos>>1);
}break;
case 'R' :{
st+=(pos>>1);
}break;
default :
if ((pos<<1)<n){
if (st&(pos<<1))st-=pos;
else st+=pos;
}
}
s++;
}
printf("%I64d\n",st);
}
} | |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | 6755a8a87a623a2231b4a94f9442c6d6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include <stdio.h>
typedef long long unsigned int u64;
#define getlevel __builtin_ctzll
u64 n, q;
u64 go(char move, u64 v) {
int level = getlevel(v);
u64 testl, testr;
switch(move) {
case 'U':
if(v == n >> 1ULL) return v;
if(v == 1ULL) return 2;
if(v == n - 1ULL) return n - 2;
testl = v + (1ULL << level);
testr = v - (1ULL << level);
if(getlevel(testl) == level + 1) return testl;
else return testr;
case 'L':
if(v & 1) return v;
return v - (1ULL << (level - 1));
case 'R':
if(v & 1) return v;
return v + (1ULL << (level - 1));
}
}
int main(void) {
scanf("%llu%llu\n", &n, &q);
n++;
for(int i = 0; i < q; i++) {
u64 v;
scanf("%llu\n", &v);
for(int c = getchar(); c != EOF && c != '\n'; c = getchar()) {
v = go(c, v);
}
printf("%llu\n", v);
}
return 0;
} | |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | f221575a955c53a037f44732582fa221 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include <stdio.h>
#include <string.h>
int count(long long x) {
return x % 2 == 1 ? 0 : 1 + count(x / 2);
}
int main() {
long long n;
int q, k;
scanf("%lld%d", &n, &q);
k = count(n + 1);
while (q-- > 0) {
static char cc[100001];
long long u;
int b, l, i;
scanf("%lld", &u);
scanf("%s", cc);
l = strlen(cc);
b = count(u);
for (i = 0; i < l; i++)
if (cc[i] == 'U') {
if (b + 1 < k) {
u >>= b + 1;
u |= 1;
u <<= b + 1;
b++;
}
} else {
if (b - 1 >= 0) {
u >>= b - 1;
u += cc[i] == 'L' ? -1 : 1;
u <<= b - 1;
b--;
}
}
printf("%lld\n", u);
}
return 0;
}
| |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | b826b5fbb62c391dbf01cc057790b4bd | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include <stdio.h>
#include <string.h>
int main() {
long long n;
int q;
scanf("%lld%d", &n, &q);
while (q-- > 0) {
static char s[100001];
long long u;
int b, l, i;
scanf("%lld", &u);
scanf("%s", s);
l = strlen(s);
b = 0;
while ((u & (1LL << b)) == 0)
b++;
b--;
for (i = 0; i < l; i++)
if (s[i] == 'U') {
if (u != (n + 1) / 2) {
if ((u & (1LL << (b + 2))) == 1)
u = u - (1LL << (b + 1));
else
u = (u - (1LL << (b + 1))) | (1LL << (b + 2));
b++;
}
} else if (s[i] == 'L') {
if (b >= 0) {
u = (u - (1LL << (b + 1))) | (1LL << b);
b--;
}
} else {
if (b >= 0) {
u |= 1LL << b;
b--;
}
}
printf("%lld\n", u);
}
return 0;
}
| |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | 20cda2bda0a304078c40011774d59de3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include <stdio.h>
#include <string.h>
#define LB(X) ((X)&(-(X)))
typedef long long LL;
LL n;
int q;
char str[100010];
int main(void)
{
//freopen("tree.in","r",stdin);
//freopen("tree.out","w",stdout);
scanf("%I64d%d",&n,&q);
int i,j;
LL u;
for(i=1;i<=q;i++)
{
scanf("%I64d%s",&u,str);
for(j=0;str[j];j++)
if( str[j]=='L' && u>LB(u)/2 )
u-=LB(u)/2;
else if( str[j]=='R' && u+LB(u)/2<=n )
u+=LB(u)/2;
else if( str[j]=='U' && LB(u-LB(u))==LB(u)*2 )
u-=LB(u);
else if( str[j]=='U' && LB(u+LB(u))<=n && LB(u+LB(u))==LB(u)*2 )
u+=LB(u);
printf("%I64d\n",u);
}
return 0;
}
| |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | a1cc8b6742d87a004e78607ebba9cf95 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include <stdio.h>
#include <stdlib.h>
typedef long long LL;
LL curNode;
char path[100001];
int main()
{
LL n, last_1_bit, root;
int i, q;
char *p, c ;
scanf("%I64d%d", &n,&q);
root = (n + 1) >> 1;
for(i=0; i<q; i++){
scanf("%I64d%s", &curNode, path);
p = path;
while(c = *p++){
last_1_bit = curNode & -curNode;
switch(c){
case 'L':
if(last_1_bit>1)
curNode -= last_1_bit >> 1;
break;
case 'R':
if(last_1_bit>1)
curNode += last_1_bit >> 1;
break;
default:
if(curNode != root){
if(curNode & (last_1_bit << 1)) curNode -= last_1_bit;
else curNode += last_1_bit;
}
break;
}
}
printf("%I64d\n", curNode);
}
return 0;
}
| |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | cafe297571d6d0bcbfb061df2e48610c | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define LOG2(_X) ((unsigned) (8 * sizeof (unsigned long long) - __builtin_clzll((_X)) - 1))
// https://stackoverflow.com/questions/11376288/fast-computing-of-log2-for-64-bit-integers
int main() {
long long int n, q, root;
int D, len_p;
char *p;
scanf("%lld %lld", &n, &q);
root = (n + 1) / 2;
D = LOG2(n + 1);
p = malloc(D * sizeof(char));
len_p = 0;
for (int i = 0; i < q; i++) {
long long int u, x = root, delta = (1LL << (D - 2));
char c;
scanf("%lld", &u);
len_p = 0;
while (x != u) {
if (x > u)
x -= delta, p[len_p++] = 'L';
else
x += delta, p[len_p++] = 'R';
delta >>= 1;
}
do {
c = getchar();
} while (isspace(c));
do {
if (len_p < D - 1) {
if (c == 'L')
x -= delta, p[len_p++] = 'L', delta >>= 1;
else if (c == 'R')
x += delta, p[len_p++] = 'R', delta >>= 1;
}
if (len_p > 0 && c == 'U') {
if (!(delta <<= 1))
delta = 1;
x += (p[--len_p] == 'L' ? delta : -delta);
}
c = getchar();
} while (!isspace(c));
printf("%lld\n", x);
}
free(p);
return 0;
}
| |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | 89341b0174a65ba03603735fa4b35bc1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#define MAX 100010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
char str[MAX], command[MAX];
int get_path(long long v, long long n){
int len = 0;
while (1){
long long m = (n + 1) >> 1;
if (v == m) break;
if (v < m) str[len++] = 'L';
else str[len++] = 'R', v -= m;
n >>= 1;
}
str[len] = 0;
return len;
}
long long encode(const char* str, long long n){
int i;
n = (n + 1) >> 1;
long long res = n;
for (i = 0; str[i] != 0; i++){
n >>= 1;
if (str[i] == 'L') res -= n;
else res += n;
}
return res;
}
int main(){
int q, i, j, l, len;
long long n, k, u, x, y, res;
while (scanf("%lld %d", &n, &q) != EOF){
l = __builtin_popcountll(n) - 1;
while (q--){
scanf("%lld", &u);
scanf("%s", command);
len = get_path(u, n);
for (i = 0; command[i]; i++){
if (command[i] == 'U'){
if (len) str[--len] = 0;
}
else if (len != l){
str[len++] = command[i];
str[len] = 0;
}
}
printf("%lld\n", encode(str, n));
}
}
return 0;
}
| |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | 8740799565cc5ef443685407a9b13bf5 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include<stdio.h>
int main() {
long long int n, a, k, a2, q;
int i, j, b[64], d, tn, l;
char s[100000];
scanf("%lld %lld", &n, &q);
//printf("%lld %d\n", n, q);
a2 = n;
for(tn = 0; a2 != 0; a2 = a2/2)
tn++;
//printf("digitos de n: %d\n", tn);
for(i = 0; i != q; i++) {
scanf("%lld", &a);
//printf("%lld\n", a);
scanf("%s", s);
//printf("%s\n", s);
for(d = 0; d != tn; d++) {
b[d] = a%2;
a = a/2;
}
/*for(d = tn - 1; d != -1; d--)
printf("%d", b[d]);
printf("\n");*/
for(k = 0; b[k]== 0; k++){}
for(j = 0; s[j] != '\0'; j++) {
//printf("primeiro não nulo em %d\n", k);
if(s[j] == 'L' && b[0] != 1) {
b[k] = 0;
b[k-1] = 1;
k--;
}
if(s[j] == 'R' && b[0] != 1) {
b[k - 1] = 1;
k--;
}
if(s[j] == 'U' && k != tn - 1) {
//printf("%lld %lld\n", a%(4*k), k);
b[k + 1] = 1;
b[k] = 0;
k++;
}
/*for(l = tn - 1; l != -1; l--)
printf("%d", b[l]);
printf("\n");*/
//printf("%lld -> %lld\n", a2, a);
}
a = 0;
for(j = tn - 1; j!= -1; j--)
a = 2*a + b[j];
printf("%lld\n", a);
}
return 0;
}
/* 1491598661707 */
| |
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n + 1 is a power of 2.In the picture you can see a complete binary tree with n = 15. Vertices are numbered from 1 to n in a special recursive way: we recursively assign numbers to all vertices from the left subtree (if current vertex is not a leaf), then assign a number to the current vertex, and then recursively assign numbers to all vertices from the right subtree (if it exists). In the picture vertices are numbered exactly using this algorithm. It is clear that for each size of a complete binary tree exists exactly one way to give numbers to all vertices. This way of numbering is called symmetric.You have to write a program that for given n answers q queries to the tree.Each query consists of an integer number ui (1 ≤ ui ≤ n) and a string si, where ui is the number of vertex, and si represents the path starting from this vertex. String si doesn't contain any characters other than 'L', 'R' and 'U', which mean traverse to the left child, to the right child and to the parent, respectively. Characters from si have to be processed from left to right, considering that ui is the vertex where the path starts. If it's impossible to process a character (for example, to go to the left child of a leaf), then you have to skip it. The answer is the number of vertex where the path represented by si ends.For example, if ui = 4 and si = «UURL», then the answer is 10. | Print q numbers, i-th number must be the answer to the i-th query. | C | dc35bdf56bb0ac341895e543b001b801 | 3ca180fd5b07f3a801975a4804c5900a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"bitmasks",
"trees"
] | 1490625300 | ["15 2\n4\nUURL\n8\nLRLLLLLLLL"] | null | PASSED | 1,900 | standard input | 3 seconds | The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any characters other than 'L', 'R' and 'U'. It is guaranteed that the sum of lengths of si (for each i such that 1 ≤ i ≤ q) doesn't exceed 105. | ["10\n5"] | #include <stdio.h>
long long bin[62];
int main() {
long long n,q,root;
int deg=0;
n = 1;
for(int i=0; i<=62; i++) {
bin[i] = n;
n<<=1;
}
scanf("%lld %lld",&n,&q);
root = (n+1)/2;
while(n) {
deg++; n/=2;
}
for(int i=0; i<q; i++) {
long long x,y;
int dep = 1;
char s[100005];
scanf("%lld",&x);
scanf("%s",s);
y=root;
while(x!=y) {
if(x<y) {
y -= bin[deg-dep-1];
}
else {
y += bin[deg-dep-1];
}
dep++;
}
for(int j=0; s[j]; j++) {
if(s[j]=='L' || s[j] == 'R') {
if(dep==deg) continue;
if(s[j]=='L') {
x -= bin[deg-dep-1];
}
if(s[j]=='R') {
x += bin[deg-dep-1];
}
dep++;
}
else {
if(dep == 1) continue;
if( (x / bin[deg-(dep-1)]) & 1) {
x -= bin[deg-dep];
}
else x += bin[deg-dep];
dep--;
}
}
printf("%lld\n",x);
}
}
| |
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want? | In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 09f5623c3717c9d360334500b198d8e0 | a83211b47128eceab0d42329d0877a9e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"math"
] | 1380295800 | ["3\n3 2 2", "4\n2 2 2 2"] | NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game). | PASSED | 1,600 | standard input | 2 seconds | The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play. | ["4", "3"] | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 100000
int main()
{
int i, n, amigos[N] = {0}, rondasA = 0;
double rondasB , juegos = 0;
scanf("%d", &n);
for(i = 0; i < n; i++)
{
scanf("%d", &amigos[i]);
juegos = juegos + amigos[i];
}
for(i = 0; i < n; i++)
{
if(amigos[i] > rondasA)
{
rondasA = amigos[i];
}
}
rondasB = ceil(juegos / (n-1));
if(rondasB > rondasA)
{
printf("%d", (int)rondasB);
}
else
{
printf("%d", rondasA);
}
return 0;
} | |
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want? | In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 09f5623c3717c9d360334500b198d8e0 | 042c6b24af2fc3e9ec3ca6fb96e79f65 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"math"
] | 1380295800 | ["3\n3 2 2", "4\n2 2 2 2"] | NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game). | PASSED | 1,600 | standard input | 2 seconds | The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play. | ["4", "3"] | #include<stdio.h>
#include<stdlib.h>
long long int max_num(long long int a, long long int b){
if(a > b)
return a;
else return b;
}
int main(){
int n;
scanf("%d", &n);
int i, j , k;
long long int a[n], max = -1, sum = 0, ans;
for(i = 0; i < n; i++)
scanf("%lld", &a[i]);
for(i = 0; i < n-1; i++)
if(max < a[i])
max = a[i];
for(i = 0; i < n; i++)
sum += a[i];
if(sum % (n-1) == 0)
ans = max_num(max, sum/(n-1));
else
ans = max_num(max, (sum/(n-1) + 1));
printf("%lld\n", ans);
return 0;
}
| |
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want? | In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 09f5623c3717c9d360334500b198d8e0 | 1dbacbe4763bdbcfb93f4fac418e4d94 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"math"
] | 1380295800 | ["3\n3 2 2", "4\n2 2 2 2"] | NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game). | PASSED | 1,600 | standard input | 2 seconds | The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play. | ["4", "3"] | #include <stdio.h>
#include <math.h>
int max(int a, int b);
int main(int argc, char const *argv[])
{
long long int players, rounds, n, sumaRounds = 0, res = 0, ma = 0;
scanf("%I64d", &players);
n = players;
while(n--)
{
scanf("%I64d", &rounds);
sumaRounds += rounds;
if(rounds > ma){
ma = rounds;
}
}
res = ceil((double)sumaRounds/(players-1));
res = max(res, ma);
printf("%I64d\n", res);
return 0;
}
int max(int a, int b)
{
int m = a;
if (m < b)
{
m = b;
}
return m;
} | |
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want? | In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 09f5623c3717c9d360334500b198d8e0 | 1ce3b041c72fcd1935b726bd41e110e4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"math"
] | 1380295800 | ["3\n3 2 2", "4\n2 2 2 2"] | NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game). | PASSED | 1,600 | standard input | 2 seconds | The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play. | ["4", "3"] | #include <stdio.h>
int main(){
long long total=0, rminimos=0, rnds; //rnds: cantidad de rondas minimas que deben jugarse
long ai, p, n; //n:numero de amigos
scanf("%ld", &n);
for(p=0; p<n; p++){
scanf("%ld", &ai);
total=total+ai;
if(ai>rminimos){
rminimos=ai;
}
rnds=total/(n-1);
if(total%(n-1) > 0){
rnds++;
}
if(rnds<rminimos){
rnds=rminimos;
}
}
printf("%I64d\n", rnds);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.