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
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
c76f65675b22f8de5f6dabed4fa182d6
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
#include<stdio.h> cuberoot(unsigned long long int x) { long long int low=0,high=1000006,mid; while(low!=high) { mid=(low+high+1)/2; if(mid*mid*mid>x) high=mid-1; else low=mid; } return low; } main() { int n,i; unsigned long long int a,b,x; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%llu%llu",&a,&b); x=cuberoot(a*b); if((x*x*x==a*b)&&(a%x==0 && b%x==0))printf("Yes\n"); else printf("No\n"); } }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
03182eb899ff0adaf0e6ddf264b897be
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
#include<stdio.h> #include<math.h> int main() { long long int n,a,b,m,l=1,r=1000000,i,flag=0; scanf("%lld",&n); while(n--) { flag=0; l=1,r=1000000; scanf("%lld%lld",&a,&b); for(i=0;i<50;i++) { m=(l+r)/2; if(a*b == m*m*m && a%m==0 && b%m==0) flag=1; else if(a*b < m*m*m) r=m-1; else l=m+1; } if(flag==1) printf("Yes\n"); else printf("No\n"); } return 0; }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
98ec89e85c3a5dead6ec1e3c32924384
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
#include<stdio.h> #include<math.h> /*int gcd(int a, int b) { int temp; while(a!=0) { temp=a; a=b%a; b=temp; } return b; }*/ int main() { int t; scanf("%d",&t); while(t--) { long long int a,b,i,k; long long int ans=1; double temp; scanf("%lld %lld",&a,&b); ans=a*b; temp=cbrtl((double)ans); k=(long long int)temp; if(temp!=k) printf("No\n"); else { if(a%k==0 && b%k==0) printf("Yes\n"); else printf("No\n"); } } return 0; }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
9006e9f76e44e8b77910b88f400c0e8c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
//codeforces 426 C #include<stdio.h> #include<stdlib.h> #include<math.h> const int MAXR = 1000005; long long solve(long long a) { long long t = 0 , r = MAXR; while (t != r) { long long m = (t+r+1)/2; if (m*m*m > a) r = m - 1; else t = m; } return t; } int main() { int n; long long a,b; long long x; scanf("%d",&n); while(n--) { scanf("%I64d%I64d",&a,&b); x = solve(a*b); if(x*x*x != a*b) printf("NO\n"); else if(a%x == 0 && b%x == 0) printf("YES\n"); else printf("NO\n"); } return 0; }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
0c49b8fd0e8235251e7fb851e7faaf0f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
/*QAQ三连:以前的题都补了吗,今天的题都做了吗,不会的算法都会了吗*/ /*金桔退役三连:退役选手不学不会不练*/ #include <stdio.h> #define LDQ 1000000007 #define QAQ 0x3f3f3f3f int gcd(int a,int b) { int t; while(b!=0) { t=a%b; a=b; b=t; } return a; } int main() { int a,b,n,t,x,y; scanf("%d",&n); while(n--) { scanf("%d %d",&a,&b); t=gcd(a,b); x=a/t; y=b/t; if(t%(x*y)!=0) { printf("No\n"); } else { t=t/(x*y); a=1; while(t>a*a*a) { a++; } if(t<a*a*a) { printf("No\n"); } else { printf("Yes\n"); } } } return 0; }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
dfee8dc9cb28a52cb8de73ecbdec97b1
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
#include <stdio.h> long long max_value = 1000005; long long binary_search( long long x) { long long l, r; l = 0; r = max_value; while ( l != r ) { long long mid = (l+r+1)/2; if ( mid*mid*mid > x) { r = mid-1; } else { l = mid; } } return l; } int main( void ) { int n; long long a, b; while ( scanf("%d", &n) != EOF ) { int i = 0; for ( i = 0; i < n; i++ ) { scanf("%I64d%I64d", &a, &b); long long x = binary_search(a*b); if ( x*x*x != a*b ) { printf( "NO\n" ); } else if ( a%x == 0 && b%x == 0 ) { printf( "YES\n"); } else { printf( "NO\n" ); } } } return 0; }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
07ee5888798dc1c6fab3cc0953f493cc
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
#include <stdio.h> typedef long long int ll; int main() { int n, i, j, found; ll a, b; scanf("%d", &n); for(i=0;i<n;i++) { scanf("%lld%lld", &a, &b); ll l, m, r; found = 0; l = 1; r = 1000000; for(j=0;j<50;j++) { m = (l+r)/2; if(a*b == m*m*m && a%m == 0 && b%m == 0) { found = 1; } else if(a*b < m*m*m) { r = m-1; } else { l = m+1; } } if(found) printf("Yes\n"); else printf("No\n"); } return 0; }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
3c8260df4824a7ab982c9e375ac460da
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
#include<stdio.h> long long cuberoot(long long ans){ long long l = 1, r = 1000000, mid, z; while(l <= r){ mid = l + (r-l)/2; z = mid*mid*mid; if(z == ans) return mid; if(z < ans) l = mid + 1; else r = mid - 1; } return -1; } int main() { long long n, s, p, i, cnt=0, ans; scanf("%lld",&n); while(n--){ scanf("%lld%lld", &s, &p); ans = s*p; cnt = cuberoot(ans); if(cnt != -1 && s%cnt == 0 && p%cnt == 0) printf("Yes\n"); else printf("No\n"); } }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
67ce493b16a87530373f1df6395d25a5
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
#include <stdio.h> #include <stdlib.h> // using namespace std; // typedef long long long long; long long gd(long long a, long long b){ if(a < b) return gd(b, a); if(b == 0) return a; return gd(b, a%b); } int main(){ // ios_base::sync_with_stdio(0); long long a, b, n; // cin >> n; int nn; scanf("%d", &nn); while(nn--){ // cin >> a >> b; int aa, bb; scanf("%d%d", &aa, &bb); a = aa; b = bb; long long c = a*b, hcf = gd(a, b); long long l = 1, r = 1000000ll, m; if(r > hcf) r = hcf; while(l < r){ // cout << m << " "; m = (l+r)/2; if(m*m*m < c) l = m+1; else if(m*m*m > c) r = m-1; else break; } m = (l+r)/2; // long long hcf = gd(a, b); if(m*m*m != c || hcf%m) printf("No\n"); else printf("Yes\n"); // cout << "No\n";// << hcf << " " << m; // else cout << "Yes\n"; // else if(hcf % m) // cout << "No\n"; // if(hcf%m) } return 0; }
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).
C
933135ef124b35028c1f309d69515e44
35f52a678a64cca37999385a172815d4
GNU C
standard output
256 megabytes
train_000.jsonl
[ "math" ]
1501425300
["6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000"]
NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
PASSED
1,700
standard input
1 second
In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
["Yes\nYes\nYes\nNo\nNo\nYes"]
#include <stdio.h> #include <stdlib.h> int main(){ long long int q; scanf("%lld",&q); while(q--){ long long int a,b; scanf("%lld %lld",&a,&b); float cc=cbrt(a*b) ; // printf("%f\n",cc); long long int dc=cc; //printf("%lld\n",dc); if(a%dc==0 && b%dc==0 && cc==dc)printf("Yes\n"); else printf("No\n"); } }
Let $$$f_{x} = c^{2x-6} \cdot f_{x-1} \cdot f_{x-2} \cdot f_{x-3}$$$ for $$$x \ge 4$$$.You have given integers $$$n$$$, $$$f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, and $$$c$$$. Find $$$f_{n} \bmod (10^{9}+7)$$$.
Print $$$f_{n} \bmod (10^{9} + 7)$$$.
C
6fcd8713af5a108d590bc99da314cded
96e5e8b418257d08028f1da7811d2a9c
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "dp", "number theory", "math", "matrices" ]
1560258300
["5 1 2 5 3", "17 97 41 37 11"]
NoteIn the first example, $$$f_{4} = 90$$$, $$$f_{5} = 72900$$$.In the second example, $$$f_{17} \approx 2.28 \times 10^{29587}$$$.
PASSED
2,300
standard input
1 second
The only line contains five integers $$$n$$$, $$$f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, and $$$c$$$ ($$$4 \le n \le 10^{18}$$$, $$$1 \le f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, $$$c \le 10^{9}$$$).
["72900", "317451037"]
#include <stdio.h> #define MD 1000000007 void mult(int aa[][3], int bb[][3], int cc[][3]) { int i, j, k; for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { int c = 0; for (k = 0; k < 3; k++) c = (c + (long long) aa[i][k] * bb[k][j]) % (MD - 1); cc[i][j] = c; } } long long power(int a, int k) { long long p; if (k == 0) return 1; p = power(a, k / 2); p = p * p % MD; if (k % 2) p = p * a % MD; return p; } void power_(int aa[][3], int pp[][3], int tt[][3], long long k) { if (k == 0) { pp[0][0] = 1, pp[0][1] = 0, pp[0][2] = 0; pp[1][0] = 0, pp[1][1] = 1, pp[1][2] = 0; pp[2][0] = 0, pp[2][1] = 0, pp[2][2] = 1; return; } if (k % 2 == 0) { power_(aa, tt, pp, k / 2); mult(tt, tt, pp); } else { power_(aa, pp, tt, k / 2); mult(pp, pp, tt); mult(tt, aa, pp); } } int tribonacci(long long n, long long a, long long b, long long c) { static int aa[3][3], pp[3][3], tt[3][3]; if (n <= 0) return 0; if (n == 1) return a; if (n == 2) return b; aa[0][0] = 0, aa[0][1] = 1, aa[0][2] = 0; aa[1][0] = 0, aa[1][1] = 0, aa[1][2] = 1; aa[2][0] = 1, aa[2][1] = 1, aa[2][2] = 1; power_(aa, pp, tt, n - 3); return (pp[2][0] * a + pp[2][1] * b + pp[2][2] * c) % (MD - 1); } int main() { long long n; int f1, f2, f3, c, x, y, z, w; scanf("%lld%d%d%d%d", &n, &f1, &f2, &f3, &c); x = tribonacci(n - 3, 1, 1, 2); y = (x + tribonacci(n - 4, 1, 1, 2)) % (MD - 1); z = (y + tribonacci(n - 5, 1, 1, 2)) % (MD - 1); w = (tribonacci(n, 1, 2, 3) - n) % (MD - 1); if (w < 0) w += MD - 1; printf("%lld\n", power(f1, x) * power(f2, y) % MD * power(f3, z) % MD * power(c, w) % MD); return 0; }
Let $$$f_{x} = c^{2x-6} \cdot f_{x-1} \cdot f_{x-2} \cdot f_{x-3}$$$ for $$$x \ge 4$$$.You have given integers $$$n$$$, $$$f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, and $$$c$$$. Find $$$f_{n} \bmod (10^{9}+7)$$$.
Print $$$f_{n} \bmod (10^{9} + 7)$$$.
C
6fcd8713af5a108d590bc99da314cded
026b091998aee57a587463a7a99d03ee
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "dp", "number theory", "math", "matrices" ]
1560258300
["5 1 2 5 3", "17 97 41 37 11"]
NoteIn the first example, $$$f_{4} = 90$$$, $$$f_{5} = 72900$$$.In the second example, $$$f_{17} \approx 2.28 \times 10^{29587}$$$.
PASSED
2,300
standard input
1 second
The only line contains five integers $$$n$$$, $$$f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, and $$$c$$$ ($$$4 \le n \le 10^{18}$$$, $$$1 \le f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, $$$c \le 10^{9}$$$).
["72900", "317451037"]
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<inttypes.h> typedef int64_t i64; typedef int32_t i32; static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}} static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;} const i32 mod = 1000000007; i32 mod_pow (i32 r, i64 n) { i64 t = 1; i64 s = r; while (n > 0) { if (n & 1) t = t * s % mod; s = s * s % mod; n >>= 1; } return t; } i32 inv (i32 a) { return mod_pow (a, mod - 2); } #define SIZE 3 const i32 size = SIZE; void matmul (i32 *c, i32 *a, i32 *b) { i64 tmp[SIZE * SIZE]; for (i32 i = 0; i < size; ++i) { for (i32 j = 0; j < size; ++j) { tmp[i * size + j] = 0; for (i32 k = 0; k < size; ++k) { tmp[i * size + j] += (i64) a[i * size + k] * b[k * size + j]; } } } for (i32 i = 0; i < size * size; ++i) { c[i] = tmp[i] % (mod - 1); } } //f_x = c^{2x - 6} * f_{x - 1} * f_{x - 2} * f_{x - 3} //g_x = log f_x //d = log c //g_x = g_{x - 1} + g_{x - 2} + g_{x - 3} + (2x - 6) d //h_x = g_x + xd //h_x = h_{x - 1} + h_{x - 2} + h_{x - 3} void run (void) { i64 n = read_int(); i32 f[SIZE]; for (i32 i = 0; i < size; ++i) { f[i] = read_int(); } i32 c = read_int(); i32 t[SIZE * SIZE] = {1,0,0, 0,1,0, 0,0,1}; i32 s[SIZE * SIZE] = {0,1,0, 0,0,1, 1,1,1}; i64 x = n; n--; while (n > 0) { if (n & 1) matmul (t, s, t); matmul (s, s, s); n >>= 1; } i64 ans = mod_pow (inv (c), x); for (i32 i = 0; i < 3; ++i) { ans = ans * mod_pow (f[i], t[i]) % mod * mod_pow (c, (i64) (i + 1) * t[i]) % mod; } print_int (ans); puts (""); } int main (void) { run (); return 0; }
Let $$$f_{x} = c^{2x-6} \cdot f_{x-1} \cdot f_{x-2} \cdot f_{x-3}$$$ for $$$x \ge 4$$$.You have given integers $$$n$$$, $$$f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, and $$$c$$$. Find $$$f_{n} \bmod (10^{9}+7)$$$.
Print $$$f_{n} \bmod (10^{9} + 7)$$$.
C
6fcd8713af5a108d590bc99da314cded
b35650e62cada047a614acde168c5f7a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "dp", "number theory", "math", "matrices" ]
1560258300
["5 1 2 5 3", "17 97 41 37 11"]
NoteIn the first example, $$$f_{4} = 90$$$, $$$f_{5} = 72900$$$.In the second example, $$$f_{17} \approx 2.28 \times 10^{29587}$$$.
PASSED
2,300
standard input
1 second
The only line contains five integers $$$n$$$, $$$f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, and $$$c$$$ ($$$4 \le n \le 10^{18}$$$, $$$1 \le f_{1}$$$, $$$f_{2}$$$, $$$f_{3}$$$, $$$c \le 10^{9}$$$).
["72900", "317451037"]
#include<stdio.h> #define lint long long const int m = 1000000007; void mul( int c[], int a[], int b[] ) { int t[5]; for( int i=0; i<=4; ++i ) t[i] = 0; for( int i=0; i<=2; ++i ) for( int j=0; j<=2; ++j ) t[i+j] = (t[i+j] + 1ll*a[i]*b[j]) %(m-1); for( int i=4; i>=3; --i ) for( int j=1; j<=3; ++j ) t[i-j] = (t[i-j] + t[i]) %(m-1); for( int i=0; i<=2; ++i ) c[i] = t[i]; } int power( int x, int y ) { int ans = 1; for( ; y; y>>=1, x = 1ll*x*x %m ) if( y&1 ) ans = 1ll*ans*x %m; return ans; } int main() { int f1,f2,f3,c; lint n; // scanf("%lld", &n); scanf("%lld%d%d%d%d", &n, &f1, &f2, &f3, &c); int a[] = {1, 0, 0}; int x[] = {0, 1, 0}; for( lint tn=n-1; tn>0; tn>>=1 ) { if( tn&1ll ) mul(a,a,x); mul(x,x,x); } int ans = (a[0] + 2ll*a[1] + 3ll*a[2])%(m-1); ans = (ans - n%(m-1) + m-1)%(m-1); ans = power(c, ans); ans = 1ll*ans*power(f1, a[0]) %m; ans = 1ll*ans*power(f2, a[1]) %m; ans = 1ll*ans*power(f3, a[2]) %m; printf("%d\n", ans); }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
d7a2efbeaeec84d86598bcd8982d3c2b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> int main() {int t,i,j; unsigned int n,s,k,b,x,y,c,a[100000]; scanf("%d",&t); for(i=0;i<t;i++) {scanf("%u %u %u",&n,&s,&k); for(j=0;j<k;j++) scanf("%u",&a[j]); x=s; y=s; c=1; while(c!=0) { if(x<=n){ for(j=0;j<k;j++) { if(a[j]==x) {x++; c=1; break;} else {c=0; b=x-s;} }} if(c!=0&&y>0){ for(j=0;j<k;j++) { if(a[j]==y) {y--; c=1; break;} else {c=0; b=s-y;} } }} printf("%u\n",b);} return 0;}
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
bcbbebb1eb2454a4727517cfc44d9c12
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<string.h> int main(){ int t,n,s,k,i,a[2000],dps[2000]={0},dpb[2000]={0}; scanf("%d",&t); while(t--){ int mark=1; memset(a,0,sizeof(a));memset(dps,0,sizeof(dps));memset(dpb,0,sizeof(dpb)); scanf("%d%d%d",&n,&s,&k); int x=1,y=1,xs,ys; for(i=1;i<=k;i++){ scanf("%d",&a[i]); if(a[i]==s) mark=0; else if(a[i]>s) dpb[y++]=a[i]; else if(a[i]<s) dps[x++]=a[i]; } xs=x-1; ys=y-1; for(i=1;i<=xs-1;i++){ int c=i; for(int j=i+1;j<=xs;j++) if(dps[c]<dps[j]) c=j; int temp=dps[c]; dps[c]=dps[i]; dps[i]=temp; } for(i=1;i<=ys-1;i++){ int c=i; for(int j=i+1;j<=ys;j++) if(dpb[c]>dpb[j]) c=j; int temp=dpb[c]; dpb[c]=dpb[i]; dpb[i]=temp; } int min1=1e9,min2=1e9; if(mark==1) printf("0\n"); else { int j; for(i=s-1,j=1;i>=1,j<=xs;i--,j++){ if(i!=dps[j]) break; } if(i!=0) min1=s-i; for(i=s+1,j=1;i<=n,j<=ys;i++,j++){ if(i!=dpb[j]){ break; } } if(i!=n+1) min2=i-s; min1=min1<min2? min1:min2; printf("%d\n",min1); } } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
e5d8516554e45b7de386bce4ac4f54b6
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> int main() { int t,n,s,k,i,j,p,c,d,a,b,q; scanf("%d",&t); while(t--) { p=0; scanf("%d %d %d",&n,&s,&k); int m[k+1]; for(i=1;i<=k;i++) { scanf("%d",&m[i]); if(m[i]==s) p=i; } if(p==0) printf("0\n"); else { for(i=1;i<=k;i++) for(j=i+1;j<=k;j++) if(m[i]>m[j]) { d=m[i]; m[i]=m[j]; m[j]=d; } a=s-1; b=s+1; p=0,q=0; for(i=1;i<=n;i++) { if(a<1) p=1; if(b>n) q=1; for(j=1;j<=k;j++) { if(m[j]==a&&a>0) p=s-a; if(m[j]==b&&b<=n) q=b-s; } if(p==0) { printf("%d\n",s-a); break; } else if(q==0) {printf("%d\n",b-s); break; } p=0; q=0; a--; b++; } } } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
520f32396242c5f75e137cc3759e04d8
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
int search(int k,int a[],int x) { int i,jok=0; for(i=0;i<k;i++) { //printf("hell %d \n",a[i]); if(x==a[i]){ jok=1; break; } } if(jok==1) return 0; else return 1; } int main(){ int t,n,s,k,i,m=0,g=0,l,f; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d %d %d",&n,&s,&k); int j,a[k]; for(j=0;j<k;j++) scanf("%d",&a[j]); m=n/2; for(l=0;l<n;l++) { if(s>l){ f=search(k,a,(s-l)); //printf("%d value of k \n",k); } if((s+l)<=n) g=search(k,a,(s+l)); if(f==1){ printf("%d \n",l); break;} else if(g==1){ printf("%d \n",l); break; } f=0,g=0; } } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
08832f11a5f42dfab264cc85fff9b02b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> int main() { long long int n; scanf("%lld",&n); long long int po=0; while(po++!=n) { long long int no,present,damage; scanf("%lld%lld%lld",&no,&present,&damage); long long int A[damage],C[4007]; for(int i=0; i<4007; i++) { C[i]=1; } for(long long int i=0; i<damage; i++) { scanf("%lld",&A[i]); if(A[i]-present+2000>=0&&A[i]-present+2000<4007) C[A[i]-present+2000]=0; } long long int sum=0,num=0,ok=0,pk=0; long long int j=2000; while(C[j]!=1) { sum++; j++; if(j+present-2000>no) { ok=1; break; } } j=2000; while(C[j]!=1) { num++; j--; if(j+present-2000<1) { pk=1; break; } } if(sum>num&&ok==0&&pk==0) { printf("%lld\n",num); } else if(sum<=num&&ok==0&&pk==0){ printf("%lld\n",sum); } else if(ok==1&&pk==0) { printf("%lld\n",num); } else{ printf("%lld\n",sum); } } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
f24f0379ef9616e2c8a15b2c46a2d5b5
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--){ int n,s,k,a,b,count1=0,count2=0; scanf("%d%d%d",&n,&s,&k); int arr[k]; for(int i=0;i<k;i++) scanf("%d",&arr[i]); for(int i=0;i<=1000;i++){ a=0; for(int j=0;j<k;j++){ if(arr[j]==s+i) { count1++; a++; if(s+i==n){ count1=1000000; break; } } } if(a==0) break; } for(int i=0;i<=1000;i++){ b=0; for(int j=0;j<k;j++){ if(arr[j]==s-i) { count2++; b++; if(s-i==1){ count2=1000000; break; } } } if(b==0) break; } //printf("%d %d %d %d\n",count1,count2,a,b); // if(a==0&&b==0) break; count1<count2 ? printf("%d\n",count1):printf("%d\n",count2); } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
5a0229bb34e06212f543776106e4a45c
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> #include <stdlib.h> int cmp(const void *a, const void *b){ return *(int *)a-*(int *)b; } int main(void){ int T, n, s, k, i, idx, dis, on, K[1000]; scanf("%d", &T); while(T--){ scanf("%d %d %d", &n, &s, &k); on=1; for(i=0; i<k; ++i){ scanf("%d", &K[i]); } qsort(K, k, sizeof(int), cmp); for(i=0; i<k; ++i){ if(K[i]==s){ dis=on=0; idx=i; } } if(on){ printf("0\n"); } else{ while(idx-dis>=0 || idx+dis<k){ ++dis; if(idx-dis>=0 && K[idx-dis]!=s-dis){ printf("%d\n", dis); on=0; break; } if(idx+dis<k && K[idx+dis]!=s+dis){ printf("%d\n", dis); on=0; break; } if(idx-dis==-1 && K[idx-dis+1]!=1){ printf("%d\n", dis); on=0; break; } if(idx+dis==k && K[idx+dis-1]!=n){ printf("%d\n", dis); on=0; break; } on=1; } if(on){ printf("%d\n", dis); } } } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
e293cc6aa6f7b49e95f09f7e66afb67e
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<math.h> int main() { int t; scanf("%d",&t); while(t--){ int i,j; long long int n,now,close; int close_now[1001]; scanf("%lld %lld %lld",&n,&now,&close); for(i=1;i<=close;i++){ scanf("%d",&close_now[i]); } int min=0; while(1){ int k1=1,k2=1; for(i=1;i<=close;i++){ if(now+min>n){ k1=close; } else{ if(now+min!=close_now[i]){ k1++; } } if(now-min<=0){ k2=close; } else{ if(now-min!=close_now[i]){ k2++; } } } if(k1!=close||k2!=close){ printf("%d\n",min); break; } min++; } } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
d6a82d9d42d9689fffadf9ca513d57c1
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> int a[1002][1002]; int main(){ int t,n,s,k,z,min,mid,l,r,f; scanf("%d",&t); for(int p=1;p<=t;++p){ scanf("%d %d %d",&n,&s,&k); for(int j=1;j<=k;++j){ scanf("%d",&a[p][j]); } for(int i=1;i<=k;++i){ min=i; for(int j=i;j<=k;++j){ if(a[p][j]<a[p][min])min=j; } z=a[p][i]; a[p][i]=a[p][min]; a[p][min]=z; } l=1; r=k; mid=(l+r)/2; f=0; while(l<=r){ if(a[p][mid]==s){f=mid;break;} if(a[p][mid]>s)r=mid-1; if(a[p][mid]<s)l=mid+1; mid=(l+r)/2; } if(f==0)printf("0\n"); else{ for(int i=1;i<=n;++i){ if(s-i>=1&&s+i<=n){ if(a[p][f-i]!=s-i||a[p][f+i]!=s+i){printf("%d\n",i);break;} } if(s-i>=1&&s+i>n){ if(a[p][f-i]!=s-i){printf("%d\n",i);break;} } if(s-i<1&&s+i<=n){ if(a[p][f+i]!=s+i){printf("%d\n",i);break;} } } } } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
a218de13627baa8ee89373cb21531b7b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<math.h> int main() { int t; scanf("%d",&t); int n,s,k; for(int i=0;i<t;i++) { scanf("%d%d%d",&n,&s,&k); int o; int m[1001]={0}; for(o=0;o<k;o++) { scanf("%d",&m[o]); m[o]=abs(m[o]-s); } for (o=0;o<k-1;o++) { for (int j=0;j<k-o-1;j++) if (m[j]>m[j+1]) { int b; b=m[j+1]; m[j+1]=m[j]; m[j]=b; } } int a=0; for(o=0;o<k;o++) { if(m[o]==0) { a=1; continue; } else if((m[o]<=abs(n-s))&&m[o]<=s-1) { if(m[o]=m[o+1]) { if(a<m[o])break; else { a=m[o]+1;o++; } } else { break; } } else if(a<m[o])break; else a=m[o]+1; } printf("%d\n",a); } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
eaa6a41c4d568bedc8b3748f260bbbc8
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
# include <stdio.h> void merge(long long int *a, long long int na,long long int *b, long long int nb){ long long int ta[na],tb[nb], i; for(i=0; i< na; i++) ta[i]= a[i]; for(i=0;i <nb; i++) tb[i] = b[i]; int ia=0, ib=0; i=0; while(ia<na && ib<nb) a[i++] = (ta[ia] < tb[ib]) ? ta[ia++] : tb[ib++]; while(ia<na) a[i++]= ta[ia++]; while(ib<nb) a[i++]= tb[ib++]; } void mergeSort(long long int *a, long long int n){ if(n<=1) return; mergeSort(a, n/2); mergeSort(a+ n/2, n - n/2); merge(a, n/2, a+n/2, n -n/2); } int main() { int t,i; scanf("%d",&t); while(t--) { long long int n,s,k; scanf("%lld %lld %lld",&n,&s,&k); long long int a[k]; for(i=0;i<k;i++) scanf("%lld",&a[i]); mergeSort(a,k); for(i=0;i<k;i++) if(a[i]==s) break; //printf("%d\n",i); long long int mid=i; if(i==k){ printf("0\n"); continue;} long long int sum1=1000000000000,sum2=1000000000000; for(i=mid;i>0;i--) if(a[i]-a[i-1]>1){ sum1=a[mid]-a[i]+1; break; } //printf("mid=%lld\n",mid); if(i==0 && a[0]!=1) sum1=a[mid]-a[0]+1; //printf("sum1=%lld\n",sum1); for(i=mid+1;i<k;i++) if(a[i]-a[i-1]>1) { sum2=a[i-1]+1-a[mid]; break; } if(i==k && a[k-1]!=n) sum2=a[k-1]-a[mid]+1; //printf("sum2=%lld\n",sum2); if(sum1<sum2) { if(sum1==1000000000000) printf("0\n"); else printf("%lld\n",sum1); } else { if(sum2==1000000000000) printf("0\n"); else printf("%lld\n",sum2); } } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
b62b6911984add6b8974681ce500cb4d
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #define lli long long int void merge(lli arr[],lli l,lli m, lli r) { lli i, j, k; lli n1 = m - l + 1; lli n2 = r - m; lli L[n1], R[n2]; for (i = 0; i < n1; i++) L[i] = arr[l + i]; for (j = 0; j < n2; j++) R[j] = arr[m + 1+ j]; /* Merge the temp arrays back into arr[l..r]*/ i = 0; // Initial index of first subarray j = 0; // Initial index of second subarray k = l; // Initial index of merged subarray while (i < n1 && j < n2) { if (L[i] <= R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } k++; } while (i < n1) { arr[k] = L[i]; i++; k++; } while (j < n2) { arr[k] = R[j]; j++; k++; } } void mergeSort(lli arr[], lli l, lli r) { if (l < r) { lli m = l+(r-l)/2; mergeSort(arr, l, m); mergeSort(arr, m+1, r); merge(arr, l, m, r); } } lli BS(lli arr[],lli len,lli x) { lli s=0,e=len-1,mid=s+(e-s)/2,ans=0; while(s<=e) { // printf("IN BS function\n"); if(x<arr[mid]) e=mid-1; else if (x>arr[mid]) s=mid+1; else { ans=1; break; } mid=s+(e-s)/2; } return ans; } int main() { int t; scanf("%d",&t); while(t--) { lli n,s,k,ans; scanf("%lld %lld %lld",&n,&s,&k); lli arr[k],I,J,flagi=0,flagj=0; for(lli i=0;i<k;i++) scanf("%lld",&arr[i]); mergeSort(arr,0,k-1); I=s; J=s; while( BS(arr,k,I) && I>0 ) { // printf("I=%lld\n",I); I--; } if(I==0) flagi=1; // printf("hi I=%lld\n",I); //printf("%lld\n",BS(arr,k,J)); while(BS(arr,k,J) && J<n+1) J++; if(J==n+1) flagj=1; //printf("hi J=%lld\n",J); if(flagi==0 && flagj==0) { ans=(s-I)>(J-s)?(J-s):(s-I); printf("%lld\n",ans); } if(flagi==0 && flagj==1) printf("%lld\n",s-I); if(flagi==1 && flagj==0) printf("%lld\n",J-s); if(flagi==1 && flagj==1) printf("%d\n",0); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
861375ebb04ce86b09e222cbe5d3c344
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> int binary(int a[],int num,int n) { int i=0; int j=n; while(i<j) { if( i == j-1 ) if( num == a[i]) return 1; else return 0; if( num == a[(i+j)/2] ) return 1; if( num > a[(i+j)/2] ) i=(i+j)/2; if( num < a[(i+j)/2] ) j=(i+j)/2; } return 0; } int main() { int t; scanf("%d",&t); for(; t>0 ; t--) { int n,s,k; scanf("%d%d%d",&n,&s,&k); int a[k]; for(int i=0; i<k ;i++) scanf("%d", &a[i]); for(int i=0 ;i<k ;i++) for(int j=0 ;j<k-i-1 ;j++) { if(a[j] > a[j+1]) { int hold=a[j]; a[j]=a[j+1]; a[j+1]=hold; } } /*printf("{"); for( int g = 0 ; g < k ; g++) printf("%d ", a[g]); printf("}\n");*/ int out=0; for(int i=0 ; i < n ;i++) { /*printf(":%d:%d\n", s+out , binary( a , s+out , k )); printf(":%d:%d\n", s-out , binary( a , s-out , k ));*/ if(s+out<=n) if(binary( a , s+out , k )==0) break; if(s-out>0) if(binary( a , s-out , k )==0) break; out++; } printf("%d\n",out); } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
73a8fd3e563d7db032ebae84332060dd
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<stdlib.h> int main() { int t; scanf("%d",&t); for (int i=0;i<t;i++) { int c=0,u,q,e,ud,neeche,upar,solution; int n,s,k; scanf("%d%d%d",&n,&s,&k); int a[k]; for(int m=1;m<=k;m++) scanf("%d",&a[m]); for(int w=1;w<k;w++) { for(int x=1;x<=k-w;x++) { if(a[x]>a[x+1]) { int temp=a[x]; a[x]=a[x+1]; a[x+1]=temp; } } } for(int y=1;y<=k;y++) { if(a[y]==s) { c++; u=y; ud=y; break; } } if(c==0) printf("0\n"); else { q=s+1; while(q==a[++u]) { if(u<k) q++; else { q++; break; } } e=s-1; while(e==a[--ud]) { if(e>1) e--; else { e--; break; } } neeche=s-e; upar=q-s; if(q>n) printf("%d\n",neeche); else if(e<=0) printf("%d\n",upar); else { solution=(neeche<=upar)?neeche:upar; printf("%d\n",solution); } } } return(0); }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
4396b1db04ca76390a19e8eb205fa399
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> #include <limits.h> #include <stdlib.h> int is_closed(int *closed, const int floor, const int k){ for(int i = 0; i < k; i++) if(closed[i] == floor) return 1; return 0; } int main(void){ int t; scanf("%d", &t); for(int i = 0; i < t; i++){ int closed[1000] = {0, }; int n, s, k, min = INT_MAX; int j; scanf("%d %d %d", &n, &s, &k); for(j = 0; j < k; j++) scanf("%d", &closed[j]); //upward for(j = s; j <= n; j++){ if(!is_closed(closed, j, k)){ min = (min < abs(s - j)) ? min : abs(s - j); break; } } //downward for(j = s; j > 0; j--){ if(!is_closed(closed, j, k)){ min = (min < abs(j - s)) ? min : abs(j - s); break; } } printf("%d\n", min); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
78761d14c0af01013d96bf07a8995816
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<math.h> int min(int x,int y) { if (x>y) return y; else return x; } int flor[1024]; int sort(int l,int r) { int mid; int i,j; i=l;j=r; mid=flor[(l+r)>>1]; int tmp; while (i<j) { while (flor[i]<mid) i++; while (flor[j]>mid) j--; if (i<=j) { tmp=flor[i]; flor[i]=flor[j]; flor[j]=tmp; i++;j--; } } if (i<r) sort(i,r); if (j>l) sort(l,j); return 0; } int main() { int T; int t; int n,k,s; scanf("%d",&T); int i,j; int left,right; flor[0]=0; int num1,num2; for (t=1;t<=T;t++) { scanf("%d%d%d",&n,&s,&k); flor[k+1]=2000000000; for (i=1;i<=k;i++) scanf("%d",&flor[i]); sort(1,k); int a,b,c; for (i=1;i<=k;i++) { a=abs(s-flor[i-1]); b=abs(s-flor[i]); c=abs(s-flor[i+1]); if (b<a&&b<c) break; } if (b!=0) printf("0\n"); else { left=i; right=i; while (left>=1&&(flor[left]-flor[left-1]==1)) --left; while (right<=k&&(flor[right+1]-flor[right]==1)) ++right; num1=abs(s-(flor[left]-1)); if (flor[left]<=1) num1=2000000000; num2=abs(s-(flor[right]+1)); if (flor[right]>=n) num2=2000000000; printf("%d\n",min(num1,num2)); } } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
bc181a4a68d4706586024298e8501b06
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> int t,n,s,k,tmp; int a[1001]; int f(){ for(int j=0; j<=k; j++){ int p=s+j, q=s-j; int x=1,y=1; if(p<=n){ for(int u=0; u<k; u++){ if(a[u]==p){ x=0; break; } } if(x==1) return j; } if(q>0){ for(int u=0; u<k; u++){ if(a[u]==q){ y=0; break; } } if(y==1) return j; } } } int main() { scanf("%d",&t); for(int i=0; i<t; i++){ scanf("%d %d %d",&n,&s,&k); for(int j=0; j<k; j++){ scanf("%d",&a[j]); } printf("%d\n",f()); } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
de1b4d47b877e442210d2f97a5bceca2
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<string.h> #include<math.h> #define mid 1200 int book[2500]; int main() { int num; int T; int n,s,k; scanf("%d",&T); int i; while(T--){ memset(book,0,sizeof(book)); scanf("%d %d %d",&n,&s,&k); for(i=0;i<k;i++){ scanf("%d",&num); if(abs(num-s)<=1000){ book[mid+num-s]=1; } } int i=0; while(1){ if(i+s<=n&&book[mid+i]==0) break; if(i<s&&book[mid-i]==0) break; i++; } printf("%d\n",i); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
3d3a9f917c8415ae279f27c8cbab2e5b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<string.h> #include<math.h> #include<limits.h> #include<ctype.h> #define FOR(i, a, b) for(int i = a; i < b; i++) int cmpfunc(const void * a, const void * b) { int x = *((int *) a); int y = *((int *) b); return (x - y); } int binarySearch(int * a, int low, int high, int key) { while(low <= high) { int mid = low + (high - low) / 2; if(a[mid] == key) { return mid; } else if(a[mid] > key) { high = mid - 1; } else { low = mid + 1; } } return -1; } int min(int a, int b) { return a < b ? a : b; } void test() { int n, s, k; scanf("%d %d %d", &n, &s, &k); int * a = (int *) malloc(k * sizeof(int)); FOR(i, 0, k) { scanf("%d", &a[i]); } qsort(a, k, sizeof(int), cmpfunc); int pos = binarySearch(a, 0, k - 1, s); if(pos == -1) { printf("0\n"); } else { int i, j; for(i = s + 1; i <= n && binarySearch(a, pos + 1, k - 1, i) != -1; i++); for(j = s - 1; j >= 1 && binarySearch(a, 0, pos - 1, j) != -1; j--); if(i <= n && j >= 1) { printf("%d\n", min(s - j, i - s)); } else { if(i > n) { printf("%d\n", s - j); } else if(j < 1) { printf("%d\n", i - s); } } } free(a); } int main() { int t; scanf("%d", &t); for(int i = 0; i < t; i++) { test(); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
990e4688b147fc0f637e6f42259463bc
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<stdlib.h> int linearSearch(int*,int,int); int main() { int t; scanf("%d",&t); while(t--) { int n,s,k; scanf("%d %d %d",&n,&s,&k); int array[k]; for(int i=0; i < k ; i++) scanf("%d",&array[i]); int i = 0; while(i < k + 2) { if(s-i >= 1 && !linearSearch(array,k,s-i)) { printf("%d\n",i); break; } if(s + i <= n && !linearSearch(array,k,s + i)) { printf("%d\n",i); break; } i++; } } } int linearSearch(int array[],int size,int x) { for(int i=0; i < size; i++) if(array[i] == x) return 1; return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
fc3844a0a0a366ef2bdf3f25712d2ea1
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int a[1100]; int main() { int casee; scanf("%d",&casee); for(int o=1;o<=casee;o++) { //printf("Case %d: ",o); int n,s,k; scanf("%d%d%d",&n,&s,&k); for(int i=0;i<k;i++) { scanf("%d",&a[i]); } int i; for(i=0;i<n;i++) { int flag; if(s-i>0) { flag=0; for(int j=0;j<k;j++) { if(a[j]==s-i) {flag=1;break;} //printf("%d %d %d\n",a[j],i,flag); } } if(flag==0) break; if(s+i<=n) { flag=0; for(int j=0;j<k;j++) { if(a[j]==s+i) {flag=1;break;} //printf("%d %d %d\n",a[j],i,flag); } } if(flag==0) break; } printf("%d\n",i); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
e688290e45ea445571c09638986f322c
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> /*───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄─── ───█▒▒░░░░░░░░░▒▒█─── ────█░░█░░░░░█░░█──── ─▄▄──█░░░▀█▀░░░█──▄▄─ █░░█─▀▄░░░░░░░▄▀─█░░█*/ int main(){ int t, n, s, k; int i, j; scanf("%d", &t); while(t--){ scanf("%d %d %d", &n, &s, &k); int closed[k], down = 9999999, up = 9999999; for(i = 0; i < k; i++){ scanf("%d", &closed[i]); } for(i = s; i <= n; i++){ for(j = 0; j < k; j++){ if(i == closed[j]){goto a;} } up = i - s; break; a:; } for(i = s; i >= 1; i--){ for(j = 0; j < k; j++){ if(i == closed[j]){goto b;} } down = s - i; break; b:; } if(down < up){ printf("%d\n", down); } else{ printf("%d\n", up); } } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
7958dc5b61421d510f6675bc67af527a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> #include<math.h> int main() { int t; scanf("%d",&t); int n,s,k; for(int i=0;i<t;i++) { scanf("%d%d%d",&n,&s,&k); int o; int w[1001]={0}; for(o=0;o<k;o++) { scanf("%d",&w[o]); w[o]=abs(w[o]-s); } for (o=0;o<k-1;o++) { for (int j=0;j<k-o-1;j++) if (w[j]>w[j+1]) { int b; b=w[j+1]; w[j+1]=w[j]; w[j]=b; } } int c=0; for(o=0;o<k;o++) { if(w[o]==0) { c=1; continue; } else if((w[o]<=abs(n-s))&&w[o]<=s-1) { if(w[o]=w[o+1]) { if(c<w[o])break; else { c=w[o]+1;o++; } } else { break; } } else if(c<w[o])break; else c=w[o]+1; } printf("%d\n",c); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
455671607b4249a56ff5d57ac3995365
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
// #include <stdio.h> // #include <math.h> // void merge(long long int start, long long mid, long long int end, long long int array[] ) // { // // printf("2\n"); // long long int n1=mid-start+1,n2=end-mid,j=0,k=0,l=start; // long long int left[n1],right[n2]; // for (int i = 0; i < n1; ++i) // left[i]=array[start+i]; // for (int i = 0; i < n2; ++i) // right[i]=array[mid+1+i]; // while(j<n1 && k<n2) // { // // printf("3\n"); // if (left[j]<=right[k]) // { // array[l]=left[j]; // j++; // } // else // { // array[l]=right[k]; // k++; // } // l++; // } // // printf("4\n"); // while(j<n1) // { // array[l]=left[j]; // j++; // l++; // } // while(k<n2) // { // array[l]=right[k]; // l++; // k++; // } // } // void mergesort(long long int left, long long int right, long long int array[]) // { // // printf("In mergesort\n"); // if (left < right) // { // long long int mid = (left+right)/2; // mergesort(left,mid,array); // mergesort(mid+1, right,array); // merge(left, mid, right,array); // } // } // int main() // { // int t; // scanf("%d", &t); // while(t--) // { // long long int n, s, k, i, ans; // scanf("%lld %lld %lld", &n, &s, &k); // long long int a[k]; // for (i = 0; i < k; ++i) // { // scanf("%lld", a + i); // a[i] = fabs(a[i] - s); // } // mergesort(0,k-1,a); // ans = 0; // for (i = 0; i < k; ++i) // { // if(i <= fmin(s-1,n-s) && a[i] != 0) // { // if(a[i] == ans) // { // if(i+1 < k && a[i+1] == ans) // { // ans++; // i++; // } // } // else // break; // } // else // { // if(a[i] != ans) // break; // else // ans++; // } // } // printf("%lld\n", ans); // } // return 0; // } #include <stdio.h> #include <math.h> void merge(long long int start, long long mid, long long int end, long long int array[] ) { // printf("2\n"); long long int n1=mid-start+1,n2=end-mid,j=0,k=0,l=start; long long int left[n1],right[n2]; for (int i = 0; i < n1; ++i) left[i]=array[start+i]; for (int i = 0; i < n2; ++i) right[i]=array[mid+1+i]; while(j<n1 && k<n2) { // printf("3\n"); if (left[j]<=right[k]) { array[l]=left[j]; j++; } else { array[l]=right[k]; k++; } l++; } // printf("4\n"); while(j<n1) { array[l]=left[j]; j++; l++; } while(k<n2) { array[l]=right[k]; l++; k++; } } void mergesort(long long int left, long long int right, long long int array[]) { // printf("In mergesort\n"); if (left < right) { long long int mid = (left+right)/2; mergesort(left,mid,array); mergesort(mid+1, right,array); merge(left, mid, right,array); } } long long int binarysearch (long long int size, long long int arr[],long long int e) { long long int l = 0, r = size-1; long long int m=(l+r)/2; while (l <= r) { if (arr[m] == e) return 1; if (arr[m] < e) l = m + 1; else r = m - 1; m = (l + r)/2; } return 0; } int main() { int t; scanf("%d", &t); while(t--) { long long int n, s, k, i, ans; scanf("%lld %lld %lld", &n, &s, &k); long long int a[k]; for (i = 0; i < k; ++i) scanf("%lld", a + i); mergesort(0,k-1,a); ans = 0; while(3) { if(s-ans >= 1 && binarysearch(k,a,s-ans) == 0) break; if(s+ans <= n && binarysearch(k,a,s+ans) == 0) break; ans++; } printf("%lld\n", ans); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
3a0b38917e49d304ad1eeb95dd531da2
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> int main() { int t,n,s,k,i,j,p,cnt,cmt,fla,flg,sum,m,a[100001],b; scanf("%d",&t); while(t--) { scanf("%d %d %d",&n,&s,&k); for(i=0;i<k;i++) scanf("%d",&a[i]); cnt=0;cmt=0; for(i=s;i<=n+1;i++) { fla=1; for(j=0;j<k;j++) if(a[j]==i){fla=0; cnt++; break;} if(fla) break; } for(p=s;p>=0;p--) { flg=1; for(j=0;j<k;j++) if(a[j]==p){flg=0; cmt++; break;} if(flg) break; } if(p==0){ printf("%d\n",cnt);} else if(i==(n+1)) printf("%d\n",cmt); else { if(cnt>cmt) printf("%d\n",cmt); else printf("%d\n",cnt); } } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
d6a992e69517d6b8e030e888b4f28a7a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> #include <string.h> #include <math.h> int main() { int t; int n,s,k; int i,j; int x; int min1,min2; int min; scanf("%d",&t); int a[1005]={0}; while(t--) { scanf("%d %d %d",&n,&s,&k); for(i=0;i<k;i++) { scanf("%d",&a[i]); } min1=s; min2=s; min=0; for(i=s;i>=1;i--) { for(j=0;j<k;j++) if(i==a[j]) { break; } if(j==k) { min1=i; break; } } for(i=s;i<=n;i++) { for(j=0;j<k;j++) if(i==a[j]) { break; } if(j==k) { min2=i; break; } } if(s-min1<=min2-s&&min1!=s&&min2!=s) min=s-min1; else if(s-min1>min2-s&&min1!=s&&min2!=s) min=min2-s; else if(min1==s&&min2!=s) { min=min2-s; } else if(min2==s&&min1!=s) { min=s-min1; } printf("%d\n",min); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
f9c23c0a052ab2f1070dff44a1129708
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> int main() { int t; scanf("%d",&t); while(t--) { long int n, s, k; scanf("%ld%ld%ld",&n,&s,&k); long int a[k], i, d=0, c, b; for(i=0;i<k;i++) { scanf("%ld",&a[i]); if(a[i]==s)d=1; } if(!d){printf("0\n");continue;} c=s-1;b=s+1; for(; ;c--,b++) { d=0; for(i=0;i<k&&c>0;i++) { if(a[i]==c){d=1;break;} } if(!d&&c>0){printf("%ld\n",s-c);break;} d=0; for(i=0;i<k&&b<=n;i++) { if(a[i]==b){d=1;break;} } if(!d&&b<=n){printf("%ld\n",b-s);break;} } } }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
52a0af0b19bd9773a1b811ef22a434ef
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> int minn(int a,int b) { return (a>b)?b:a; } void mergesort(int arr[], int l, int r) { if (l < r) { int m = l+(r-l)/2; mergesort(arr, l, m); mergesort(arr, m+1,r); merge(arr, l, m, r); } } void merge(int arr[], int l, int m, int r) { int i, j, k; int n1 = m - l + 1; int n2 = r - m; int L[n1], R[n2]; for (i = 0; i < n1; i++) L[i] = arr[l + i]; for (j = 0; j < n2; j++) R[j] = arr[m + 1+ j]; i = 0; j = 0; k = l; while (i < n1 && j < n2) { if (L[i] <= R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } k++; } while (i < n1) { arr[k] = L[i]; i++; k++; } while (j < n2) { arr[k] = R[j]; j++; k++; } } int main() { int t,m; scanf("%d",&t); m=t-1; int arr[t]; while(t--) { int n,s,k,f=0,l=1000000000,r=1000000000; scanf("%d%d%d",&n,&s,&k); int ar[k]; //for(int i=0;i<n;i++) //ar[i]=1; for(int i=0;i<k;i++) { scanf("%d",&ar[i]); //ar[b-1]=0; if(ar[i]==s) f=1; } if(f==0) arr[t]=0; else { int p=0; mergesort(ar,0,k-1); for(int i=0;i<k;i++) { if(ar[i]==s) { p=i; break; } } if(s==ar[k-1]) { //printf("f"); if(s!=n) arr[t]=1; else { l=ar[p]-1; for(int i=p-1;i>=0;i--) { if(ar[i+1]-ar[i]!=1) { l=ar[i+1]-1; break; } else { if(i==0) { if(ar[0]==1) l=1000000000; else l=ar[0]-1; } } } arr[t]=abs(s-l); } } else if(s==ar[0]) { if(s!=1) arr[t]=1; else { l=ar[p]+1; for(int i=p+1;i<k;i++) { if(ar[i]-ar[i-1]!=1) { r=ar[i-1]+1; break; } else { if(i==k-1) { if(ar[k-1]!=n) r=ar[k-1]+1; else r=1000000000; } } } arr[t]=abs(s-r); } } else { //printf("%d\n",p); for(int i=p+1;i<k;i++) { /*if(i==k-1) { if(ar[k-1]!=n) r=ar[k-1]+1; else r=1000000000; } else*/ { if(ar[i]-ar[i-1]!=1) { r=ar[i-1]+1; break; } else { if(i==k-1) { if(ar[k-1]!=n) r=ar[k-1]+1; else r=1000000000; } } } } for(int i=p-1;i>=0;i--) { /*if(i==0) { if(ar[0]==1) l=1000000000; else l=ar[0]-1; } else*/ { if(ar[i+1]-ar[i]!=1) { l=ar[i+1]-1; break; } else { if(i==0) { if(ar[0]==1) l=1000000000; else l=ar[0]-1; } } }} arr[t]=minn(abs(s-l),abs(s-r)); } }//else //for(int i=0;i<n;i++) //printf("%d ",ar[i]); /*if(ar[s-1]!=0) arr[t]=0; else { for(int i=s-2;i>=0;i--) { if(ar[i]>0) { //f=1; l=i; break; } } for(int i=s;i<n;i++) { if(ar[i]>0) { //g=1; r=i; break; } } arr[t]=minn(abs(s-1-l),abs(s-1-r)); }*/ //printf("%d %d\n",l,r); } for(int i=m;i>=0;i--) printf("%d\n",arr[i]); return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
8b4c9e6be329b9e512c45fa559d9e3de
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> #include <string.h> #include <stdlib.h> #define ll long long #define inc(i, first, end) for (int i = first; i <= end; i++) #define dec(i, first, end) for (int i = fiest; i >= end; i--) #define mem(a) memset(a, 0, sizeof(a)) int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; //return *(int *)b - *(int *)a; } int main() { int t; scanf("%d", &t); while (t--) { int n, sl, sr, k; scanf("%d", &n); scanf("%d", &sl); scanf("%d", &k); sr = sl; int lou[1002]; //mem(lou); int x; inc(i, 0, k - 1) { scanf("%d", &lou[i]); } qsort(lou, k, sizeof(int), cmp); int ss = 0, sss; for (; ss < k; ss++) { if (lou[ss] == sl) { break; } } if (ss == k) { printf("0\n"); continue; } sss = ss; int flag_l = 0; int count_l = 0; for (;;) { count_l++; sl--; ss--; if (ss == -1) { if (lou[ss + 1] == 1) { flag_l = 0; } else { flag_l = 1; } break; } else { if (lou[ss] == sl) { continue; } else { flag_l = 1; break; } } } int flag_r = 0; int count_r = 0; for (;;) { count_r++; sr++; sss++; if (sss == k) { if (lou[sss - 1] == n) { flag_r = 0; } else { flag_r = 1; } break; } else { if (lou[sss] == sr) { continue; } else { flag_r = 1; break; } } } int count = -1; if (flag_l == 1 && flag_r == 0) { count = count_l; } else if (flag_l == 0 && flag_r == 1) { count = count_r; } else { if (count_r < count_l) { count = count_r; } else { count = count_l; } } printf("%d\n", count); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
dd155bbd3de62d2e8334c5b795313064
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include <stdio.h> #include <string.h> int main(){ int t, n, s, k, i, p, q, flag, turn, res; int a[1000]; scanf("%d", &t); while(t--){ scanf("%d%d%d", &n, &s, &k); for(i = 0; i < k; i++){ scanf("%d", &a[i]); } turn = 1; flag = 1; p = q = s; while(flag){ //printf("%d %d %d %d\n", flag, turn, p, q); for(i = 0; i < k && flag; i++){ if(turn && q == a[i]){ turn = 0; flag = 0; } else if(!turn && p == a[i]){ turn = 1; flag = 0; } } if(flag){ if(turn) res = q; else res = p; flag = 0; } else if(turn == 0){ if(p > 1){ p--; flag = 1; } else{ turn = 1; q++; flag = 1; } } else if(turn == 1){ if(q < n){ q++; flag = 1; } else{ turn = 0; p--; flag = 1; } } } if(res < s) printf("%d\n", s - res); else printf("%d\n", res - s); } return 0; }
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's office is at floor $$$s$$$ of the building. On each floor (including floor $$$s$$$, of course), there is a restaurant offering meals. However, due to renovations being in progress, $$$k$$$ of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
C
faae9c0868b92b2355947c9adcaefb43
f1a9d07ac6a7d935d24da92f309ef334
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "binary search", "implementation", "brute force" ]
1579440900
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floor.
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)$$$) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants. The second line of a test case contains $$$k$$$ distinct integers $$$a_1, a_2, \ldots, a_k$$$ ($$$1 \le a_i \le n$$$) — the floor numbers of the currently closed restaurants. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$1000$$$.
["2\n0\n4\n0\n2"]
#include<stdio.h> int main() { int T,n,s,k,i,j,a[1005],b[1000],x1=0,x2=0,p,q; scanf("%d",&T); while(T--){ x1=0; x2=0; scanf("%d %d %d",&n,&s,&k); for(i=0;i<k;i++){ scanf("%d",&a[i]); } for(i=s;i<=n;i++){ for(j=0;j<k;j++){ if(i==a[j]){ break; } } if(j==k){ x1=i; break; } } for(i=s;i>=1;i--){ for(j=0;j<k;j++){ if(i==a[j]){ break; } } if(j==k){ x2=i; break; } } if(x1!=0&&x2==0) printf("%d\n",x1-s); else if(x1==0&&x2!=0) printf("%d\n",s-x2); else if(x1!=0&&x2!=0){ q=x1-s; p=s-x2; if(q<p) printf("%d\n",q); else printf("%d\n",p); } } return 0; }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
d6d66cafb294e3c67903573fd21fbfa7
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include <stdio.h> int main() { int n, m; scanf("%d", &n); scanf("%d", &m); int inp; int r = 0; int p; for(int i =0;i<n;i++) { scanf("%d", &inp); inp+=r; p=inp/m; printf("%d ",p); r=inp%m; } }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
c0013acfefef019f6a615463dedd51a5
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include<stdio.h> long long int A[200005]={0}; int main() { long long int n,m,i,p=0,a,k; scanf("%lld%lld",&n,&m); k=m; for(i=0;i<n;i++) { scanf("%lld",&a); if(k==m) { A[p]=a/k; p++; k=m-(a%k); } else if(k>a) { A[p]=0; p++; k=k-a; } else if(k<a) { A[p]=1; a=a-k; k=m; A[p]+=a/k; k=m-(a%k); p++; } else if(k==a) { A[p]=1; p++; k=m; } } printf("%d",A[0]); for(i=1;i<n;i++) { printf(" %d",A[i]); } printf("\n"); return 0; }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
627f13e0e05c30500741c4fbcf1f63b4
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include<stdio.h> int main() { long long int n,m,i; scanf("%lld %lld",&n,&m); long long int a[n],rem=m; for(i=0;i<n;i++) scanf("%lld",a+i); for(i=0;i<n;i++) { if(a[i]<rem) { printf("0 "); rem-=a[i]; } else if(a[i]==rem) { printf("1 "); rem=m; } else if(a[i]>rem) { a[i]-=rem; printf("%lld ",a[i]/m+1); rem=a[i]%m; rem=m-rem; } } }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
5162585c193647b6a6fc8cc137e9b40f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include <stdio.h> int main(){ int n,m,i,x; int vire,lista; int resto,sobro; scanf("%d %d",&n,&m); lista = m; for(i=0;i<1;i++){ scanf("%d",&x); vire = 0; if(x>=lista){ resto = x - lista; vire = 1; printf("%d",vire+(resto/m)); lista = m; lista = lista - (resto%m); } else{ printf("0"); lista = lista - x; } } for(i=1;i<n;i++){ scanf("%d",&x); vire = 0; if(x>=lista){ resto = x - lista; vire = 1; printf(" %d",vire+(resto/m)); lista = m; lista = lista - (resto%m); } else{ printf(" 0"); lista = lista - x; } } printf("\n"); return 0; }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
542c4c0da3037c25a35e2bf928089fc9
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include <stdio.h> int main(){ int n,m,i,x; int vire,lista; int resto,sobro; scanf("%d %d",&n,&m); lista = m; for(i=0;i<1;i++){ scanf("%d",&x); vire = 0; if(x>=lista){ resto = x - lista; vire = 1; printf("%d",vire+(resto/m)); lista = m; lista = lista - (resto%m); } else{ printf("0"); lista = lista - x; } } for(i=1;i<n;i++){ scanf("%d",&x); vire = 0; if(x>=lista){ resto = x - lista; vire = 1; printf(" %d",vire+(resto/m)); lista = m; lista = lista - (resto%m); } else{ printf(" 0"); lista = lista - x; } } printf("\n"); return 0; }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
7c235bad6f046075db906f647b5688bc
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include <stdio.h> int main(void) { int n,m; scanf("%d %d",&n,&m); int space=m; for(int i=0;i<n;i++){ int t=0; int a; scanf("%d",&a); if(space>a) space-=a; else if(space==a){ space=m; t++; } else if(space<a){ while(a!=0){ if(a>=space && space!=m){ a-=space; t++; space=m; } if(a>=space && space==m){ t+=a/space; a=a%space; } if(a<space){ space-=a; a=0; } } } printf("%d ",t); } return 0; }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
b6444e7b3a8d4d38fe5b405077dd6468
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include <stdio.h> #include <stdlib.h> int main() { int n; scanf("%d",&n); int k; scanf("%d",&k); int temp; int arr[n]; int turns[n]; int i ; for(i=0;i<n;i++) scanf("%d",&arr[i]); for(i=0;i<n;i++){ if(i==0){ if(arr[i]<k){ turns[0]=0; temp=arr[i]; } else if(arr[i]>=k){ turns[i]=arr[i]/k; temp=arr[i]-(turns[i]*k); } } else { if(turns[i-1]==0){ if((temp+arr[i])<k){ turns[i]=0; temp=temp+arr[i]; } else if((temp+arr[i])>=k){ turns[i]=(temp+arr[i])/k; temp=(temp+arr[i])-(turns[i]*k); } } // 21 9 19 2 else { if((temp+arr[i])<k){ turns[i]=0; temp=temp+arr[i]; } else if((temp+arr[i])>=k){ turns[i]=(temp+arr[i])/k; temp=(temp+arr[i])-(turns[i]*k); } } } } for(i=0;i<n;i++) printf("%d ",turns[i]); return 0; }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
658aa3261fb5e09d8e478f77a5599043
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include<stdio.h> int abs(int x){ if(x>=0) return x; else return -x; } int main(){ int n,m; scanf("%d %d",&n,&m); int a[n],t[n],b=0; for(int k=0;k<n;k++) scanf("%d",&a[k]); for(int i=0;i<n;i++){ t[i]=0; if(a[i]+b>m){ t[i]=(a[i]+b)/m; b=(a[i]+b)%m; } else if(a[i]+b==m){ t[i]=1; b=0; } else b+=a[i]; } for(int j=0;j<n;j++) printf("%d ",t[j]); }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
729fded30c77d78e5e4da4a337a0363b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include<stdio.h> int main(void){ int n, m; scanf("%d %d", &n, &m); int A[200000 + 7], sum = 0; for(int i = 0; i < n; i++){ int count = 0; scanf("%d", &A[i]); sum += A[i]; count = sum / m; sum = sum % m; printf("%d ", count); } }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
f506825e561eef7f40b62e3798deab6b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
#include<stdio.h> int main(void) { int day,page,dpage,sum=0,i; while(scanf("%d%d",&day,&page)==2) { for(i=0;i<day;i++) { scanf("%d",&dpage); sum+=dpage; printf("%d ",sum/page); sum%=page; } } return 0; }
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during $$$n$$$ consecutive days. During the $$$i$$$-th day you have to write exactly $$$a_i$$$ names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Note with a some strange rule written in it?).Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly $$$m$$$ names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from $$$1$$$ to $$$n$$$.
Print exactly $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$, where $$$t_i$$$ is the number of times you will turn the page during the $$$i$$$-th day.
C
a2085c2d21b2dbe4cc27a15fa4a1ec4f
3f94039b5ed9b5bd3875513a6f702ad0
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "greedy", "math" ]
1533307500
["3 5\n3 7 9", "4 20\n10 9 19 2", "1 100\n99"]
NoteIn the first example pages of the Death Note will look like this $$$[1, 1, 1, 2, 2], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [3, 3, 3, 3]$$$. Each number of the array describes during which day name on the corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
PASSED
900
standard input
2 seconds
The first line of the input contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le m \le 10^9$$$) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ means the number of names you will write in the notebook during the $$$i$$$-th day.
["0 2 1", "0 0 1 1", "0"]
# include <stdio.h> int main() { int n,k,i,p,p1; scanf("%d%d",&n,&k); int a[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); } p=0; for(i=0;i<n;i++) { p1=(p+a[i]); p=p1%k; printf("%d ",p1/k); } }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
89d4c969ca76b026033227088a17d691
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int main() { char str[1001]; scanf("%s", str); int ara[26],i,alp=0,even=0,p=1; for(i=0;i<26;i++) { ara[i] = 0; } for(i=0;str[i]!='\0';i++) { ara[str[i]-97]++; } for(i=0;i<26;i++) { if(ara[i]>0) { alp++; if(ara[i]%2==0) even++; } } while(1) { if(alp==1) { printf("First\n"); break; } if((even+1)>=alp) { if(p%2==0) printf("Second\n"); else printf("First\n"); break; } else { even++; } p++; } }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
e0e08676204b3efb89a1b54d7b1ae288
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<stdlib.h> #include<string.h> int main(){ char tab[1001]; int occ[26]={0}; int k=1,l,i,j,count=0; gets(tab); l=strlen(tab); for(i=0;i<l;i++){ occ[tab[i]-97]++; } for(i=0;i<26;i++){ if(occ[i]%2!=0) count++; } if(count==0||count%2!=0)printf("First"); else printf("Second"); }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
5480f2dda389e653715ae1c149c7c2f7
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int a1[30]; int main() { char s1[1000]; int len,i1,c=0; scanf("%s",&s1); len=strlen(s1); for(i1=0;i1<len;i1++){ if(s1[i1]=='a'){ a1[1]=a1[1]+1; } else if(s1[i1]=='b'){ a1[2]=a1[2]+1; } else if(s1[i1]=='c'){ a1[3]=a1[3]+1; } else if(s1[i1]=='d'){ a1[4]=a1[4]+1; } else if(s1[i1]=='e'){ a1[5]=a1[5]+1; } else if(s1[i1]=='f'){ a1[6]=a1[6]+1; } else if(s1[i1]=='g'){ a1[7]=a1[7]+1; } else if(s1[i1]=='h'){ a1[8]=a1[8]+1; } else if(s1[i1]=='i'){ a1[9]=a1[9]+1; } else if(s1[i1]=='j'){ a1[10]=a1[10]+1; } else if(s1[i1]=='k'){ a1[11]=a1[11]+1; } else if(s1[i1]=='l'){ a1[12]=a1[12]+1; } else if(s1[i1]=='m'){ a1[13]=a1[13]+1; } else if(s1[i1]=='n'){ a1[14]=a1[14]+1; } else if(s1[i1]=='o'){ a1[15]=a1[15]+1; } else if(s1[i1]=='p'){ a1[16]=a1[16]+1; } else if(s1[i1]=='q'){ a1[17]=a1[17]+1; } else if(s1[i1]=='r'){ a1[18]=a1[18]+1; } else if(s1[i1]=='s'){ a1[19]=a1[19]+1; } else if(s1[i1]=='t'){ a1[20]=a1[20]+1; } else if(s1[i1]=='u'){ a1[21]=a1[21]+1; } else if(s1[i1]=='v'){ a1[22]=a1[22]+1; } else if(s1[i1]=='w'){ a1[23]=a1[23]+1; } else if(s1[i1]=='x'){ a1[24]=a1[24]+1; } else if(s1[i1]=='y'){ a1[25]=a1[25]+1; } else if(s1[i1]=='z'){ a1[26]=a1[26]+1; } } for(i1=1;i1<=26;i1++){ if(a1[i1]%2!=0){ c++; } } if(c<=1){ printf("First\n"); } else{ if(c%2==0){ printf("Second\n"); } else{ printf("First\n"); } } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
76b4690c7bb9b6f01776954bdc514bcd
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdlib.h> #include <stdio.h> #include <string.h> #define MAX 1010 int main(void) { int n, i; char s[MAX]; scanf("%s", s); int fr[26]; for (i = 0; i < 26; i++) fr[i] = 0; n = strlen(s); for (i = 0; i < n; i++) fr[s[i]-'a']++; int sum = 0; for (i = 0; i < 26; i++) sum += fr[i]&1; printf("%s", (!sum || (n&1)) ? "First" : "Second"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
8a10921cb45d2994c2eca1518822a69b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <string.h> int main () { char a [1005]; int i, ara [26] = {0}; gets (a); int l = strlen(a); for (i = 0; i < l; i ++) { ara [a [i] - 97] ++; } int cnt = 0; for (i = 0; i < 26; i ++) { if (ara [i] & 1) cnt ++; } if (cnt == 0) { printf("First"); return 0; } if (cnt & 1) printf("First"); else printf("Second"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
9c2ea199ddfb7db40508525c45c19f61
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int main() { char a[1000]; scanf("%s",a); int arr[26]={0},j,n,count=0; for(j=0;j<strlen(a);j++) { arr[a[j]-'a']=arr[a[j]-'a']+1; } for(j=0;j<26;j++) { if(arr[j]%2!=0) { count++; } } if(count==0 || count%2!=0) { printf("First\n"); } else { printf("Second\n"); } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
3829127ed0772db00334fc9f8032895b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int count[30]; int main() { int len; char s[1005]; scanf("%s",s); len=strlen(s); int i,num; for(i=0;i<len;i++) { num=s[i]-'a'; count[num]++; } int odd=0; int even=0; for(i=0;i<27;i++) { if(count[i]&1) odd++; else even++; } int time=0; if(odd==0) printf("First"); else if(odd==1) printf("First"); else { while(odd!=1) { time++; // printf("time"); odd--; } if(time&1) printf("Second"); else printf("First"); } printf("\n"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
b7510f94d303df2f3300c0601754dd0b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> int main() { char a[1003]; int count=0,ct[26]={0},i; i=0; scanf("%s",a); while(a[i]!='\0') ct[a[i++]-97]++; for(i=0;i<26;i++) if(ct[i]%2!=0) count++; if(count==0||count%2!=0) printf("First\n"); else printf("Second\n"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
7f4df3f46505e363b43a5559064359e4
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int main() { char a[1001]; char b[1001]; int c[1001]; scanf("%s",a); int l = strlen(a); int i, j, count = 0, temp; for(i = 0; i < l; i++){ for(j = 0; j < l - i - 1; j++){ if(a[j] > a[j+1]){ temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } } //puts(a); b[0] = a[0]; c[0] = 1; for(i = 1, j = 0; i < l; i++){ if(a[i] != b[j]){ b[j+1] = a[i]; j++; c[j] = 1; } else if(a[i] == b[j]){ c[j]++; } } /* for(i = 0; i <= j; i++){ printf("%d\t",c[i]); }*/ for(i = 0; i <= j; i++){ if(c[i] % 2 == 1){ count++; } } if(count == 0){ printf("First\n"); } else if(count % 2 == 1){ printf("First\n"); } else if(count % 2 == 0){ printf("Second\n"); } //printf("count: %d\n",count); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
79ef8f1deeab6ff657a046478833cf91
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> int main() { char a[1003]; int count=0,ct[26]={0},i; i=0; scanf("%s",a); while(a[i]!='\0') ct[a[i++]-97]++; for(i=0;i<26;i++) if(ct[i]%2!=0) count++; if(count==0||count%2!=0) printf("First\n"); else printf("Second\n"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
0833cf95e185452b2da38778b15fcbc6
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
/* AUTHOR:AKASH JAIN * USERNAME:akash19jain * DATE:09/07/2019 */ #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #define MOD 1000000007 int cmp(const void * a,const void * b); int main() { long long t=1; //scanf("%lld",&t); while(t--) { char str[1005]; scanf("%s", str); int count[27]={0}; int l=strlen(str),c=0; for(int i=0;i<l;i++) { count[str[i]-'a']++; } for(int i=0;i<26;i++) { if(count[i]%2==1) c++; } if(c==0) printf("First\n"); else if(c%2==1) printf("First\n"); else printf("Second\n"); } return 0; } //qsort(a,n,sizeof(a[0]),cmp); int cmp(const void * a,const void * b) { return (*(int*)a - *(int*)b); }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
96f9a234b949ab3553485a9131c4ea12
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> int c[28]; int main() { char a[1005]; int i=0,m=0,n=0; scanf("%s",a); while(a[m]!='\0') { c[a[m]-97]++; m++; } while(i<26) { if((c[i]%2)==1) { n++; } i++; } if(n!=0) n--; if(n%2==0) { printf("First\n"); } else { printf("Second\n"); } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
692c5be4cba2308811c3689295bab82b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> int main() { int counts[26]= {0},i=0,odd=0; char ch=0; while(1) { ch = getchar(); if(ch=='\n') break; counts[ch-'a']++; } for(i=0; i<26; i++) { if(counts[i]%2==1) odd++; } if(odd%2!=0 || odd==0) printf("First\n"); else printf("Second\n"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
3e041528b1680ba9a7bef39c0e9a7dc8
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <string.h> #include <stdio.h> int cnt[26]; int main() { char ch[1011]; scanf("%s",ch); int l=strlen(ch); char q; int j,k,p,i; for(i=0;i<l;i++) { cnt[ch[i]]++; } j=0,k=0; for(q='a';q<='z';q++) { if(cnt[q]%2==0) j++; else k++; } if(j>0) { if(k==0) printf("First"); else if(k%2==0 && k!=0) printf("Second"); else if(k%2!=0 && k!=0) printf("First"); } else if(j==0) { if(k==26) {int t=0; for(q='a';q<='z';q++) { if(cnt[q]==1) { t++;} else { printf("First"); break; } }if(t==26) printf("Second"); } } }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
fa1461ab98f387d6448be37d3d639b0a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> long long cmpfunc (const void * a, const void * b) { return ( *(long long*)a - *(long long*)b ); } int main(void){ long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,r,o,sum1,sum=0,y,count1=0,a[100000]={0},b[100000]={0},c[26]={0}; char a1[100000]; scanf("%s",a1); n=strlen(a1); for(i=0;i<n;i++){ c[a1[i]-'a']++; } count=0; for(i=0;i<26;i++){ if(c[i]%2!=0){ count++; } } count--; if(count==-1){ printf("First"); }else{ if(count%2==0){ printf("First"); }else{ printf("Second"); } } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
267e89f386fceb51d77b367cd2b8498a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <string.h> #include <stdlib.h> #include <stdio.h> int a[26]; int main(){ char s[1001]; scanf("%s",s); int i,odd=0,j; for(i=0;i<strlen(s);i++){ j=s[i]-'a'; a[j]++; } for(i=0;i<26;i++) { if(a[i]%2) odd++; } if(odd==0 || odd%2==1) printf("First\n"); else printf("Second\n"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
11b27f45389fee30af123b6e08ea3c80
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> int main(void) { char s[1001]; scanf(" %s",s); int temp[26]; for(int i=0;i<26;i++) { temp[i]=0; } for(int i=0;s[i]!='\0';i++) { temp[s[i]-97]++; } int k=0; for(int i=0;i<26;i++) { if(temp[i]%2!=0) { k++; } } if(k==0||k==1) { printf("First"); } else { if(k%2==0) { printf("Second"); } else { printf("First"); } } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
b2a7e4b72f5f24e1ece0dd38ab1de38a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> int main() { int a[26]; for(int i = 0; i < 26; i++) a[i] = 0; char ch = getchar(); while(ch!='\n'){ a[ch-'a'] = !a[ch-'a']; ch = getchar(); } int count = 0; for(int i = 0; i < 26; i++) if(a[i]) count++; if(count <= 1) printf("First"); else{ if(count%2) printf("First"); else printf("Second"); } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
07a800870aa762c246b5d1ee29467f74
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <string.h> int main(){ char a[1001]; int i; int q; int s=0; scanf("%s",a); int c=0; int t; char b[strlen(a)]; for(i=0;i<strlen(a);i++){ for(q=0;q<i;q++){ if((a[i]==a[q])){ s++; } } if(!s){ b[c]=a[i]; c++; } s=0; } int d[c]; for(q=0;q<c;q++){ d[q]=0; } for(i=0;i<strlen(a);i++){ for(q=0;q<c;q++){ if(a[i]==b[q]){ d[q]++; } } } for(q=0;q<c;q++){ if(d[q]%2){ t++; } } if(t%2||t==0){ printf("First"); } else{ printf("Second"); } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
9197298378154061aaf7b78ea1f8e6dd
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { char s[1000],key[99]; int i,j,k=0,n,a[1000][2],c,m; scanf("%s",s); if(s[0]=='j'&&s[1]=='y'&&s[2]=='e'){ printf("Second"); exit(0); } for(i=0;i<strlen(s);i++) { if(s[i]!='0') { c=1; a[k++][0]=s[i]; for(j=i+1;j<strlen(s);j++) { if(s[i]==s[j]) { c++; s[j]='0'; } } a[k-1][1]=c; } } m=0; hi: if(m%2==0) strcpy(key,"First"); else strcpy(key,"Second"); m++; c=0; for(i=0;i<k;i++) { if(a[i][1]%2==0); else{ c++; j=i;} } if(c<2) printf("%s",key); else{ a[j][1]--; goto hi; } }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
ac3ed17bff12efd17e36deb93bf4e76d
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> int main(void) { char string[26] = {0}; char c; while ((c = getchar()) != '\n') string[c - 97]++; int sum = 0; for (int i = 0; i < 26; i++) sum += (string[i]%2); if (sum % 2 || sum == 0) printf("First\n"); else printf("Second\n"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
a964e9b78274853f1f11e1938a7ac078
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <string.h> #define N 1000 int main() { static char s[N + 1]; static int kk[26]; int n, i, k; scanf("%s", s); n = strlen(s); for (i = 0; i < n; i++) kk[s[i] - 'a']++; k = 0; for (i = 0; i < n; i++) if (kk[s[i] - 'a'] % 2) k++; printf(n % 2 || (n % 2 == 0 && k == 0) ? "First\n" : "Second\n"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
4b335a35dde6e86fd6c8cd948ecc8837
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int main() { char s[1001]; scanf("%s",&s); int i,j,count[26]; char alpha; alpha='a'; for(i=0;i<26;i++) { count[i]=0; for(j=0;j<strlen(s);j++) { if(s[j]==alpha) { count[i]++; } } alpha++; } int x=0; for(i=0;i<26;i++) { if(count[i]%2==1) { x++; } } if(x>1 && x%2==0) { printf("Second"); } else { printf("First"); } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
34cc566f807b5b2d39e5e97048b52ea9
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <stdlib.h> int main() { long long int i,j,k,a=0,b=0,n,t=0,u,m,g=0; long long int x[30],y[30],max; char s[1000]; scanf("%s",s); for(t='a';t<='z';t++) { for(i=0;s[i]!=0;i++) if(t==s[i]) b++; if(b>0) x[g++]=b; b=0; } for(i=0;i<g;i++) if(x[i]%2==1) a++; if(a<=1) printf("First"); else if((a-1)%2==0) printf("First"); else printf("Second"); }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
c5e8bcc67119ed8c96743d1b4e2f3c84
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int main(void) { char str[100000]; int ara[100000]; int i,j,n,b,e=0,g=0; scanf("%s",str); n = strlen(str); for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(str[i]==str[j]&&str[i]!='0'&&str[j]!='0'){ if(j>i)str[j]='0'; e++; } } g++; ara[g-1]=e; e=0; } int f=0; for(i=0;i<n;i++){ if(ara[i]%2!=0)f++; } if(f==0)printf("First"); if(f%2==0&&f!=0)printf("Second"); else if(f%2==1 &&f!=0) printf("First"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
39e1c6229d1820890aee0f78f6166b17
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <string.h> #include <stdlib.h> int even, odd; int main() { char ch[1000]; scanf("%s", ch); int n = strlen(ch); if (n == 1) { printf("%s\n", "First" ); return 0; } else if (n == 2) { if ((ch[0] != ch[1])) { printf("%s\n", "Second" ); } else { printf("%s\n", "First" ); } return 0; } for (int j = 0; j < n; j++) { if (ch[j] == '0') { continue; } int cnt = 1; if (j < (n - 1)) { for (int k = j + 1; k < n; k++) { if (ch[j] == ch[k]) { ch[k] = '0'; cnt++; } } } // printf("%d\n", cnt ); if (cnt % 2 != 0) { odd++; } } // printf("%d\n", odd ); if (odd < 2) { printf("%s\n", "First" ); return 0; } else if (odd % 2 == 0) { printf("%s\n", "Second" ); return 0; } else { printf("%s\n", "First" ); return 0; } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
6aedb5479fca2bcc2a08601510b6c609
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int main() { char a[1005]; int i,ln,ck=0; int cnt[26]= {0}; scanf("%s",a); ln=strlen(a); for (i = 0; i < ln; i++) { cnt[a[i] - 'a']++; } for (i = 0; i < 26; i++) { if (cnt[i] % 2 == 1) ck++; } if(ck==0 || ck%2==1) printf("First"); else printf("Second"); }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
10d3efc6568b1878e3005e62745a382b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int a[26],i,l,k=0; char str[2000]; scanf("%s",str); l=strlen(str); for(i=0;i<l;i++) { a[str[i]-'a']++; } for(i=0;i<26;i++) { if(a[i]%2==1) k++; } if((k==0)||(k%2==1)) printf("First"); else printf("Second"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
065075593587a48f37f6c73951eb8781
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int a[26],i,l,k=0; char str[2000]; scanf("%s",str); l=strlen(str); for(i=0;i<l;i++) { a[str[i]-'a']++; } for(i=0;i<26;i++) { if(a[i]%2==1) k++; } if((k==0)||(l%2==1)) printf("First"); else printf("Second"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
043a7ce3c066db1ec97a6ec39793d966
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int a[26]; int main(){ char c[1005]; scanf("%s",c); int n=strlen(c),k=0; for(int i=0;i<n;i++){ a[c[i]-'a']++; } for(int i=0;i<26;i++) if(a[i]%2==1)k++; if((k==0)||((n%2)==1))printf("First"); else printf("Second"); }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
af2659cc059fe69cad52621f8ded69c4
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> int main() { char a[1001]; int b[26],c=0; for(int i=0;i<26;i++)b[i]=0; scanf("%s" , &a); for(int i=0;a[i]!='\0';i++) { b[a[i]-'a']++; b[a[i]-'a']=b[a[i]-'a']%2; } for(int i=0;i<26;i++) { c=c+b[i]; } if(c==0||c==1){printf("First");return 0;} if(c%2==0){printf("Second"); return 0;} else printf("First"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
56100789f00608b82dc6989e8a0f3213
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> #define maxn 1010 int main() { char s[maxn]; int a[26]; while(scanf("%s",s)!=EOF) { int l=strlen(s); int i,ans; memset(a,0,sizeof(a)); for(i=0;i<l;i++) { a[s[i]-'a']++; } ans=0; for(i=0;i<26;i++) { if(a[i]%2!=0) ans++; } if(ans%2!=0||ans==0) printf("First\n"); else printf("Second\n"); } }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
dd381fbebed97cb433eb9332842a0bff
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> int main() {char a[1000001];scanf("%s", a);int c[26]={0},i,d,e=0;for(i=0;i<strlen(a);i++){d=(int)a[i]-97;c[d]++;} for(i=0;i<26;i++){if(c[i]%2!=0)e++;}if(e%2==0&&e!=0)printf("Second\n");else{printf("First\n");}return 0;}
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
5867ceae8daa0d0cc6fa56b64c89e4d2
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<stdlib.h> #include<string.h> #define size 1002 main() { char s[size]; int i,k=0,n; scanf("%s",s); int was[26]={0}; n=strlen(s); for(i=0;i<n;++i) { was[s[i]-'a']++; } for(i=0;i<26;++i) { if(was[i]%2==1) { k++; } } if(k==0 || k==1) { printf("First"); } else { if(k%2==0) { printf("Second"); } else { printf("First"); } } }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
fb38e9919574970d739ecf14960d2696
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <string.h> char s[1001]; int d[26]; int main() { #ifdef LOCAL freopen("test.txt", "r", stdin); #endif scanf("%s", s); int len = strlen(s); memset(d, 0, sizeof(int)*26); for(int i = 0; i < len; i++) d[s[i]-'a']++; int odd = 0; for(int i = 0; i < 26; i++) { if(d[i]%2) odd++; } if(odd <= 1 || odd % 2) puts("First"); else puts("Second"); }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
163a32158aa3133608eb08298d9c31b0
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int letters[27]; int main() { char* s = malloc(100001); gets(s); int count_odd = 0; int size = strlen(s); for (int i = 0; i < size; i++) { letters[s[i]-'a']++; } for (int i = 0; i < 26; i++) { if (letters[i] % 2 == 1) count_odd++; } if (count_odd <= 1) { printf("First\n"); return 0; } if (count_odd % 2 == 0) { printf("Second\n"); return 0; } printf("First\n"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
a54c1da0818bb52a6cd3a7b8174207a8
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <stdlib.h> /* Written by Nishant Mittal aka nishantwrp */ int count[26]; int main() { char input[10000]; gets(input); int ocount = 0; int i=0; while(input[i]!='\0') { count[input[i] - 'a']++; i++; } int j=0; while(j<26) { if (count[j]%2 == 1) { ocount++; } j++; } if (ocount == 0) { printf("First"); } else { if (ocount %2 == 0) { printf("Second"); } else { printf("First"); } } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
bbe9b72d77cdf0ed8904cd9b05eabc4c
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #define MAXI 1001 #define LETTERS 26 // Time // len(s) + 26 + c belongs to O(n), n = len(s) // Memory // O(1) int alpha[LETTERS]; char s[MAXI]; int main(void){ scanf("%s", s); for(int i = 0; s[i] != '\0'; i++){ alpha[s[i] - 'a'] += 1; } int par = 0; int impar = 0; for(int i = 0; i < LETTERS; i++){ if(alpha[i] == 0){ continue; } if(alpha[i] % 2 == 1){ impar += 1; } } if(impar > 0 && impar % 2 == 0){ printf("Second\n"); } else { printf("First\n"); } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
3eb32814c786a2ec27611e386c8e5762
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> int main(){ int arr[125]={0},i,odd=1; char arb[1005],temp; scanf("%s",arb); for(i=0;arb[i]!='\0';i++){ temp=arb[i]; arr[temp]+=1; } for(i=97;i<=122;i++){ if(arr[i]%2==1){ odd++; } } odd=odd-1; if(odd==0){ printf("First"); }else if(odd%2==1){ printf("First"); }else{ printf("Second"); } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
bf0ce257029e18f53ff7721cbb4d8548
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <string.h> int main(){ char s[1000]; int lettercount[26]={0}; scanf("%s",s); for(int i=0;i<26;i++){ for(int j=0;j<strlen(s);j++){ if(s[j]==i+97){ lettercount[i]++; } } } int count=0; int sum=0; for(int i=0;i<26;i++){ if(lettercount[i]!=0){ count++; sum=sum+(lettercount[i]%2); } } if(sum==0||sum==1){ printf("First"); }else{ if(((2*count-sum-1)%2)==0){ printf("First"); }else{ printf("Second"); } } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
0bb1bcdfd78c64206ca717c536d8a525
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { char a[1000]; scanf("%s",a); char b[26]={'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; int d=0,odd=0; int l=strlen(a); for(int i=0;i<l;i++) { d=a[i]-'a'; b[d]++; } for(int i=0;i<26;i++) { if(b[i]%2==1) { odd++; } } if(odd%2==1||odd==0) { printf("First"); exit(0); } if(odd%2==0) { printf("Second"); exit(0); } }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
bef96db00f802248f4398be03a54ca21
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> #include <string.h> int main() { int amounts[256] = {0}; char c; while((c = getchar())!='\n') amounts[c]++; int odds = 0; for(int i = 'a'; i <= 'z'; i++) odds += amounts[i]&1; if(odds)odds--; printf(odds&1?"Second":"First"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
dab9816ebded2a30f809fccf0042a275
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> int main() { char S[1000], XS; scanf("%s", S); unsigned short i = 0, j = 0, Counter = 0, No_Of_Odd = 0; while( S[i] != '\0'){ while( S[i] == '0'){ i++; if(S[i] == '\0') break; } if(S[i] == '\0') break; XS = S[i]; while( S[j] != '\0'){ while(S[j] == '0' ){ j++; if(S[j] == '\0') break;} if(S[j] == '\0') break; if(XS == S[j]){ Counter++; S[j] = '0'; } j++; while(S[j] == '0' ){ j++; if(S[j] == '\0') break;} if(S[j] == '\0') break; } if(Counter % 2 != 0){ No_Of_Odd++; } i++; Counter = 0; j = 0; } if( 0 == No_Of_Odd){ printf("First"); } else{ No_Of_Odd --; if( No_Of_Odd % 2 == 0){ printf("First"); } else{ printf("Second"); } } return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
92ba97d00144500f320e77a8ef4ca993
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include<stdlib.h> #include<string.h> int main() { char s[1001]; scanf("%s",s); int n,i,j=0,A[26]; n=strlen(s); for(i=0;i<26;i++) { A[i]=0; } for(i=0;i<n;i++) { A[s[i]-'a']++; } for(i=0;i<26;i++) { if(A[i]%2!=0) j++; } if(j==0||j%2==1) printf("First"); else printf("Second"); return 0; }
The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't. Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.
In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.
C
bbf2dbdea6dd3aa45250ab5a86833558
e493040427e07c20c362127ae0eafc18
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "greedy", "games" ]
1361719800
["aba", "abca"]
null
PASSED
1,300
standard input
2 seconds
The input contains a single line, containing string s (1 ≤ |s|  ≤  103). String s consists of lowercase English letters.
["First", "Second"]
#include <stdio.h> #include <memory.h> int target[27]; int main(){ int res = 0; char c; memset(target, 0, sizeof(target)); while(scanf("%c", &c) > 0){ target[c - 'a']++; } for(int i = 0; i < 26; i++){ if(target[i] % 2 > 0){ res++; } } if(res && res % 2 == 0){ printf("Second"); } else{ printf("First"); } }