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
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
cc1abb2bb57c9366c8efd45d9f89f034
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> #include <stdlib.h> // long long int a[1000000], b[1000000]; // long long int cmpfunc (const void * a, const void * b) { // return ( *(long long int*)a - *(long long int*)b ); // } // long long int square(long long int x, long long int...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
d42a56017e22b5a8bc83db34b46bd0f4
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main() { int T; scanf("%d",&T); char t[102]; int i,cnt; for(;T>0;T--) { scanf("%s",t); cnt=0; for(i=0;t[i]!='\0';i++) if(t[i]!=t[0]) cnt++; if(cnt==0) printf("%s\n",t); else { for(i=0;t[i]!='\0';i++) printf("10"); printf("\n"); } } return 0; }
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
d8b4cca760b6d2dc0471c37420343766
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> int main() { int t, i, j, one, zero, max, len; char s[1000], ans[10000]; scanf("%d", &t); for(i=0; i<t; i++){ one = zero = 0; scanf("%s", s); len = strlen(s); for(j=0; j<len; j++){ if(s[j]=='1'){ one++; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
c540e3261786b0f34747db5fb1a7cd80
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int getorder(char str[]) { int k; for(k=1;k<=strlen(str);k++) { int i=0; for(i=0;i<strlen(str)-k;i++) { if(str[i] != str[i+k]) break; } if(i == strlen(str)-k && str[i-1] == str[i+k-1]) break; } ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
edc1151f89da362517f79302327290be
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main() { int T; scanf("%d",&T); char t[102]; int i,cnt; for(;T>0;T--) { scanf("%s",t); cnt=0; for(i=0;t[i]!='\0';i++) if(t[i]!=t[0]) cnt++; if(cnt==0) printf("%s\n",t); else { for(i=0;t[i]!='\0';i++) printf("10"); printf("\n"); } } return 0; }
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
eeaf47595aff1bf52dee86ad48154b27
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> int main() { char s[105]; int m; scanf("%d",&m); while(m--) { scanf("%s",s); int n=strlen(s),count=0; for(int i=0;i<n;i++) { if(s[i]=='0') count++; } if(count==0||count==n) ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
2473829e79e04c3e895f64d41ed37d02
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main() { int t,m,l; scanf("%d",&t); char ch[101][201]={'\0'}; m=t-1; while(t--) { int c=0,l=0; char st[101]; scanf("%s",st); l=strlen(st); for(int i=0;i<l-1;i++) { if(st[i]==st[i+1]) c=0; else { c=1; break;} } if(...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
42d63d574b25041fb0b80e09fe2b5fa2
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> #define ll long long int main(){ ll t,n,i,j,k,c0,c1; scanf("%lld",&t); while(t--){ j=0;c0=c1=0; char s[110],ans[220]; scanf("\n%s",s); n=strlen(s); for(i=0;i<n;i++){ if(s[i]=='0') c0++; else c1++; } //printf("%lld?%lld?",c0,c1); if(c0!=0 && c1!=0){...
Vasya is reading a e-book. The file of the book consists of $$$n$$$ pages, numbered from $$$1$$$ to $$$n$$$. The screen is currently displaying the contents of page $$$x$$$, and Vasya wants to read the page $$$y$$$. There are two buttons on the book which allow Vasya to scroll $$$d$$$ pages forwards or backwards (but h...
Print one line for each test. If Vasya can move from page $$$x$$$ to page $$$y$$$, print the minimum number of times he needs to press a button to do it. Otherwise print $$$-1$$$.
C
474f29da694929a64eaed6eb8e4349c3
18204f012ac30374d93be1536c47ba6b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "math" ]
1543415700
["3\n10 4 5 2\n5 1 3 4\n20 4 19 3"]
NoteIn the first test case the optimal sequence is: $$$4 \rightarrow 2 \rightarrow 1 \rightarrow 3 \rightarrow 5$$$.In the second test case it is possible to get to pages $$$1$$$ and $$$5$$$.In the third test case the optimal sequence is: $$$4 \rightarrow 7 \rightarrow 10 \rightarrow 13 \rightarrow 16 \rightarrow 19$$$...
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of testcases. Each testcase is denoted by a line containing four integers $$$n$$$, $$$x$$$, $$$y$$$, $$$d$$$ ($$$1\le n, d \le 10^9$$$, $$$1 \le x, y \le n$$$) — the number of pages, the starting page, the desired page, and the number of ...
["4\n-1\n5"]
#include<stdio.h> #include<math.h> int min(int x,int y) { if(x>y) return y; else return x; } int main() { int t,n,x,y,d,i; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d %d %d %d",&n,&x,&y,&d); if((y-x)%d==0) printf("%d",abs(y-x)/d); else if((n-y)%d==0 && (y-1)%d!=0) printf("%d",(n-x)/d+1+(n-y)...
Vasya is reading a e-book. The file of the book consists of $$$n$$$ pages, numbered from $$$1$$$ to $$$n$$$. The screen is currently displaying the contents of page $$$x$$$, and Vasya wants to read the page $$$y$$$. There are two buttons on the book which allow Vasya to scroll $$$d$$$ pages forwards or backwards (but h...
Print one line for each test. If Vasya can move from page $$$x$$$ to page $$$y$$$, print the minimum number of times he needs to press a button to do it. Otherwise print $$$-1$$$.
C
474f29da694929a64eaed6eb8e4349c3
9654577956fdf225d1ded71c599f83fa
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "math" ]
1543415700
["3\n10 4 5 2\n5 1 3 4\n20 4 19 3"]
NoteIn the first test case the optimal sequence is: $$$4 \rightarrow 2 \rightarrow 1 \rightarrow 3 \rightarrow 5$$$.In the second test case it is possible to get to pages $$$1$$$ and $$$5$$$.In the third test case the optimal sequence is: $$$4 \rightarrow 7 \rightarrow 10 \rightarrow 13 \rightarrow 16 \rightarrow 19$$$...
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of testcases. Each testcase is denoted by a line containing four integers $$$n$$$, $$$x$$$, $$$y$$$, $$$d$$$ ($$$1\le n, d \le 10^9$$$, $$$1 \le x, y \le n$$$) — the number of pages, the starting page, the desired page, and the number of ...
["4\n-1\n5"]
#include <limits.h> #include <stdio.h> int main() { int t; scanf("%d",&t); while (t--) { int n,x,y,d,ans; scanf("%d%d%d%d",&n,&x,&y,&d); if ((y-x)%d==0) ans=(x>y?x-y:y-x)/d; else { int z; ans=INT_MAX; if ((y-1)%d==0&&ans>(z=(x-1+d-1)/d+(y-1)/d)) ans=z; if ((n-y)%d==0&&ans>(z=(n-x+d-1)/d+(...
Vasya is reading a e-book. The file of the book consists of $$$n$$$ pages, numbered from $$$1$$$ to $$$n$$$. The screen is currently displaying the contents of page $$$x$$$, and Vasya wants to read the page $$$y$$$. There are two buttons on the book which allow Vasya to scroll $$$d$$$ pages forwards or backwards (but h...
Print one line for each test. If Vasya can move from page $$$x$$$ to page $$$y$$$, print the minimum number of times he needs to press a button to do it. Otherwise print $$$-1$$$.
C
474f29da694929a64eaed6eb8e4349c3
3e9dda0f6916163bec987d73857e6b9d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "implementation", "math" ]
1543415700
["3\n10 4 5 2\n5 1 3 4\n20 4 19 3"]
NoteIn the first test case the optimal sequence is: $$$4 \rightarrow 2 \rightarrow 1 \rightarrow 3 \rightarrow 5$$$.In the second test case it is possible to get to pages $$$1$$$ and $$$5$$$.In the third test case the optimal sequence is: $$$4 \rightarrow 7 \rightarrow 10 \rightarrow 13 \rightarrow 16 \rightarrow 19$$$...
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of testcases. Each testcase is denoted by a line containing four integers $$$n$$$, $$$x$$$, $$$y$$$, $$$d$$$ ($$$1\le n, d \le 10^9$$$, $$$1 \le x, y \le n$$$) — the number of pages, the starting page, the desired page, and the number of ...
["4\n-1\n5"]
#include<stdio.h> #include<math.h> main() { int t,j; scanf("%d",&t); long long n,x,y,d,c,c1,c2; for(j=0;j<t;j++) { c=0,c1=0,c2=0; scanf("%lld%lld%lld%lld",&n,&x,&y,&d); if(abs(x-y)%d==0) c=abs(x-y)/d; else { if((y-1)%d==0) { ...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
f882f233800017bf6da29d4fd7141441
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> #include <stdlib.h> typedef struct pile { int start; }pile; int search(pile* p, int n, int i, int j, int x) { if(i == n-1) return n-1; int m=(i+j)/2; if(p[m].start <= x && p[m+1].start > x ) return m; if(p[m].start < x ) return search(p,n,m+1,j,x); if(p...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
fdc37ea7f4195d6aa6473d9170897126
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int main() { int n,m,a[1000000],i,j,x,sum=0; scanf("%d",&n); j=0; for(i=0;i<n;i++) { scanf("%d",&x); sum=sum+x; for( ;j<sum;j++) a[j]=i+1; } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d",&x); printf("%d\n",a[x-1]); } return 0; }
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
1bb13a61226c6ae010229bd217471c45
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int findIndex(int values[],int key,int first, int last) { if(values[first]<=key && values[first+1]>=key)// stopping condition { return first+1; } if(values[last]>=key && values[last-1]<key)// stopping condition { return last; } else if(values[last]>=key ...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
d4b8ad7e118e17c9e718a728b291b257
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int a[1000001],ans[1000001]; int main() { int n,q,i,j,p,t=1,o=1,h=1; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); while(h<=a[i]) { ans[t]=o; t++; h++; } h=1; o++; } scanf("%d",&q); for(j=0;j<q;j++) { scanf("%d",&p); printf("%d\n",ans[p]); } return 0; }
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
9c01ee117eab8be4c882e820ea237cd6
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> int main() { int array[1000000]; int n,a,m,s=0,cursor=0; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a); s+=a; for(cursor;cursor<s;cursor++) { array[cursor]=i+1; } } scanf("%d",&m); for(int i=0;i<m;i++) { scanf("%d",&a); printf("%d\n", array[a-1]); } }
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
4f0eb969613374377a2d54e9053a284e
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> /* NOT MİNE, TRYING KAYKOBAD_REZA'S SOLUTION */ int main() { int j,i,n,sum=0,m,x,a[1000000]; scanf("%d",&n); j=0; for(i=0;i<n;i++) { scanf("%d",&x); sum+=x; for( ;j<sum;j++) a[j]=i+1; } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d",&x); printf("%d\n",a[x-1]); } return 0; }
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
bb71c67bf679bc95005f7b60abbdd239
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> /*void sort(int a[],int n) { int i,j,mini,min,temp; for(i=0;i<n;i++) { min=a[i]; mini=i; for(j=i+1;j<n;j++) { if(a[j]<min) ...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
02f9691a5cbb40442bae639b168785c8
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> int main() { int n,m,i,j,x; scanf("%d",&n); int a[n]; scanf("%d",&a[0]); for(i=1;i<n;i++) { scanf("%d",&x); a[i]=a[i-1]+x; } scanf("%d",&m); int b[m]; for(i=0;i<m;i++) scanf("%d",&b[i]); j=0; int c[ a[n-1] ]; c[0]=1; for(i=1;i<a[n-1];i++) { if (i<a[j]) { c[i]=c[i-1]; ...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
ce1cf0b92df67ab0c8c9e0eeb84199f1
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> #include <string.h> #include <stdlib.h> int num[1000010]; int main() { int T,n,m,p; int i,j; int cnt=1; while(~scanf("%d",&T)) { for(i=1; i<=T; i++) { scanf("%d",&n); for(j=1; j<=n; j++) num[cnt++]=i; } scan...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
fe22645e64e4f2502e8c2c9f5b15c457
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int minElementGreaterThanOrEqualToKey(int A[], int key, int imin, int imax) { // Return -1 if the maximum value is less than the minimum or if the key // is great than the maximum if (imax < imin || key > A[imax]) return -1; // Return the first element of the array if...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
66af306fc897d7f629c2579a20a692de
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> //int piles[100000]={0}; int binarySearch(int arr[], int l, int r, int x) { while (l <= r) { int m = l + (r-l)/2; if (arr[m] == x) { // printf("\n%d %d \n",m,arr[m]); return m; // Check if x is present at mid } else if (arr[m] < x) { // printf("\n%d %d \n",m,arr[m]); if(x...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
068ed174d99c1c5b51e0773da543b6f0
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int bas,son,ort; main(){ int x,y,i,z=0,t=0,j=0,top=0,a,arr[1000005]; arr[0]=0; scanf("%d",&x); for(i=1;i<=x;i++){ scanf("%d",&a); arr[i]=arr[i-1]+a; } scanf("%d",&y); for(i=0;i<y;i++){ scanf("%d",&a); bas = 0; son = x; while(bas < son){ ort = (bas+son)/2; if(bas == ort) or...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
c5ed6f93dadcc2e19732ebe71d2ea8f9
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int q[1000009]; int main() { int n,i,j=1,a,t; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a); while(a--) { q[j]=i+1; j++; } } int m; scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d",&t); printf("%d\n",q[t]); } return 0; }
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
825e7c692f8d8c25987401a443dc5140
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> int main() {int a[1000000]; int n,i=1,j=1; scanf("%d",&n); while(n--) {int x; scanf("%d",&x); while(x--) a[i++]=j; j++; } int m; scanf("%d",&m); while(m--) {int q; scanf("%d",&q); printf("%d\n",a[q]); } return 0; }
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
cac8dbeaf518d2ab53a53cfab1e4833f
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int a[1000001],b[1000001]; int main() { int n,q,i,j,p,t=1,o=1,h=1; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); while(h<=a[i]) { b[t]=o; t++; h++; } h=1; o++; } scanf("%d",&q); for(j=0;j<q;j++) { scanf("%d",&p); printf("%d\n",b[p]); } return 0; }
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
08c257a3563337d587c1526eec554d23
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int a[100005]; int main() { int n,m,i,l,r,flag,mid; int b; while(scanf("%d",&n)==1) { for(i=1;i<=n;i++) { scanf("%d",&b); a[i]=a[i-1]+b; } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d",&b); l=1; r=n; flag=0; while(r-l>1) { mid=(r+l)/2; if(a[mid]>b) r=mid; else if...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
069e7af4afeacde6d2979d608301361d
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int sum[100005]; int main() { int a; int n,m,i,l,r,ok,mid; scanf("%d",&n); for( i=1;i<=n;i++) { scanf("%d",&a); sum[i]=sum[i-1]+a; } scanf("%d",&m); for( i=0;i<m;i++) { scanf("%d",&a); l=1,r=n; ok=0; while(r-l>1) ...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
4e6903b1f07ee56d78241002211fda3a
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int a[100005]; int main() { int n,m,i,l,r,flag,mid; int b; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&b); a[i]=a[i-1]+b; } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d",&b); l=1; r=n; flag=0; while(r-l>1) { mid=(r+l)/2; if(a[mid]>b) r=mid; else if(b==a[mid]) ...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
a96642ca16284981399cabb7859c2a17
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> int main() { int n; scanf("%d",&n); int data[10000001]={0,}; int i,j,x; int index=0; for(i=1;i<=n;i++) { scanf("%d",&x); for(j=index+1;j<=index+x;j++) data[j]=i; index+=x; } int m;scanf("%d",&m); for(i=0;i<m;i++) { ...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
e4f2cb38734ae202c890f9fd119e4152
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> int main() { int n; scanf("%d",&n); int data[1000001]={0,}; int i,j,x; int index=0; for(i=1;i<=n;i++) { scanf("%d",&x); for(j=index+1;j<=index+x;j++) data[j]=i; index+=x; } int m;scanf("%d",&m); for(i=0;i<m;i++) { ...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
fde3172e598ded4ab653f0eef31f3e0b
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> int Binary(int a[],int input,int low,int mid,int high){ if( (input<=a[mid] && input>a[mid-1]) || (low>high) ){ return mid; } else if(input>a[mid]){ low=mid+1; mid=low+ ( high-low )/2; return Binary(a,input,low,mid,high); } else{ high=mi...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
faa23d9c6a57456747a415290d3119eb
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include <stdio.h> #include <stdlib.h> long long binarySearch(long long a[], long long size,long long x); int main() { long long n,value,i,m,sum=0; scanf("%I64d",&n); long long a[n]; for(i=0;i<n;i++) { scanf("%I64d",&a[i]); a[i]=a[i]+sum; sum=a[i]; } scanf("%I64d",&...
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
C
10f4fc5cc2fcec02ebfb7f34d83debac
eef04976140a0d771d5b67c1eb879ff8
GNU C
standard output
256 megabytes
train_002.jsonl
[ "binary search", "implementation" ]
1412609400
["5\n2 7 3 4 9\n3\n1 25 11"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
PASSED
1,200
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot....
["1\n5\n3"]
#include<stdio.h> #include<stdlib.h> main() { int i,s,j; int n; scanf("%d",&n); int t=1; int l; int a[1000000]; j=0; int sum=0; for(i=0;i<n;i++) { scanf("%d",&s); sum=sum+s; for(j=j;j<sum;j++) { ...
You have received your birthday gifts — $$$n$$$ triples of integers! The $$$i$$$-th of them is $$$\lbrace a_{i}, b_{i}, c_{i} \rbrace$$$. All numbers are greater than or equal to $$$0$$$, and strictly smaller than $$$2^{k}$$$, where $$$k$$$ is a fixed integer.One day, you felt tired playing with triples. So you came up...
Print a single line containing $$$2^{k}$$$ integers. The $$$i$$$-th of them should be the number of ways to choose exactly one integer from each array so that their XOR is equal to $$$t = i-1$$$ modulo $$$998244353$$$.
C
379a57ff01d337203bc2fc2cf9f63508
74f20da0bae69638b4364f2efdcafb9c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math", "fft" ]
1554550500
["1 1\n1 2 3\n1 0 1", "2 2\n1 2 1\n0 1 2\n1 2 3", "4 3\n1 2 3\n1 3 7\n0 2 5\n1 0 6\n3 3 2"]
NoteIn the first example, the array we formed is $$$(1, 0, 0, 1, 1, 1)$$$, we have two choices to get $$$0$$$ as the XOR and four choices to get $$$1$$$.In the second example, two arrays are $$$(0, 1, 1, 2)$$$ and $$$(1, 2, 2, 3)$$$. There are sixteen $$$(4 \cdot 4)$$$ choices in total, $$$4$$$ of them ($$$1 \oplus 1$$...
PASSED
3,200
standard input
1.5 seconds
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 10^{5}$$$, $$$1 \leq k \leq 17$$$) — the number of arrays and the binary length of all numbers. The second line contains three integers $$$x$$$, $$$y$$$, $$$z$$$ ($$$0 \leq x,y,z \leq 10^{9}$$$) — the integers you chose. Then $$$n$$$ lines follo...
["2 4", "4 2 4 6", "198 198 126 126 126 126 198 198"]
#include <stdio.h> #include <string.h> #define M (1 << 17) #define P 998244353 #define int long long typedef long long ll; int n, k, x, y, z, A[M], B[M], C[M], mmp[M], ct[M], Comb[18][18]; ll O[M], Ans[4][M], S[4][M]; ll powmod(ll x, ll y, ll p) { x %= p; y = (y % (p - 1) + (p - 1)) % (p - 1); ll ans = ...
Recently Bob invented a new game with a tree (we should remind you, that a tree is a connected graph without cycles): he deletes any (possibly, zero) amount of edges of the tree, and counts the product of sizes of the connected components left after the deletion. Your task is to find out the maximum number that Bob can...
Output the only number — the maximum product of sizes of the connected components, that Bob can get after deleting some of the tree's edges.
C
8dbf81e0d2815382cec6488efd877b70
5af0d29c086afe8a31827926b959af92
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp" ]
1278687600
["5\n1 2\n2 3\n3 4\n4 5", "8\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n6 8", "3\n1 2\n1 3"]
null
PASSED
2,500
standard input
2 seconds
The first input line contains integer number n (1 ≤ n ≤ 700) — amount of vertices in the tree. The following n - 1 lines contain the description of the edges. Each line contains the pair of vertices' indexes, joined by an edge, ai, bi (1 ≤ ai, bi ≤ n). It's guaranteed that the graph described in the input is a tree.
["6", "18", "3"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 700 #define M 15 #define A 100000000 int oo[1 + (N - 1) * 2], oj[1 + (N - 1) * 2]; int link(int o, int j) { static int _ = 1; oo[_] = o, oj[_] = j; return _++; } void mult(int *aa, int *bb) { static int cc[M]; int i, j; for (i = 0; i < M; ...
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
C
f710958b96d788a19a1dda436728b9eb
85a35dc755955698bb3c4f00a9b2f7ef
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1461515700
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
null
PASSED
1,400
standard input
2 seconds
The first line of the input contains three integers n, m and q (1 ≤ n, m ≤ 100, 1 ≤ q ≤ 10 000) — dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≤ ti ≤ 3) that defines the type of the ...
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
#include<stdio.h> typedef unsigned u; int M[111][111],C[11111]; u Q[11111],A[11111],B[11111]; int main() { u x,y,q,i=-1,j,k; for(scanf("%u%u%u",&x,&y,&q);++i<q;--A[i],--B[i]) { scanf("%u%u",Q+i,A+i); if(Q[i]>2)scanf("%u%i",B+i,C+i); } while(q--) { if(Q[q]==1) { j=M[k=A[q]][y-1]; for(i=y;--i;)M[k][i]...
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
C
f710958b96d788a19a1dda436728b9eb
41bfa7c42ddd11f9b1f55fd93632a97d
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1461515700
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
null
PASSED
1,400
standard input
2 seconds
The first line of the input contains three integers n, m and q (1 ≤ n, m ≤ 100, 1 ≤ q ≤ 10 000) — dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≤ ti ≤ 3) that defines the type of the ...
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
#include<stdio.h> int n,m,Q; int op[10010][4]; int mat[110][110]; void rm(int r) { int i,tmp=mat[r][m]; for(i=m;i>1;i--) { mat[r][i]=mat[r][i-1]; } mat[r][1]=tmp; return; } void cm(int c) { int i,tmp=mat[n][c]; for(i=n;i>1;i--) {...
In the year of $$$30XX$$$ participants of some world programming championship live in a single large hotel. The hotel has $$$n$$$ floors. Each floor has $$$m$$$ sections with a single corridor connecting all of them. The sections are enumerated from $$$1$$$ to $$$m$$$ along the corridor, and all sections with equal num...
Print $$$q$$$ integers, one per line — the answers for the queries.
C
9bf6be240fb16da07b942be39bb3916a
8889d96fbe63bb53c3c1d1b3eb3b8cde
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "binary search" ]
1525007700
["5 6 1 1 3\n2\n5\n3\n1 1 5 6\n1 3 5 4\n3 3 5 3"]
NoteIn the first query the optimal way is to go to the elevator in the 5-th section in four time units, use it to go to the fifth floor in two time units and go to the destination in one more time unit.In the second query it is still optimal to use the elevator, but in the third query it is better to use the stairs in ...
PASSED
1,600
standard input
2 seconds
The first line contains five integers $$$n, m, c_l, c_e, v$$$ ($$$2 \leq n, m \leq 10^8$$$, $$$0 \leq c_l, c_e \leq 10^5$$$, $$$1 \leq c_l + c_e \leq m - 1$$$, $$$1 \leq v \leq n - 1$$$) — the number of floors and section on each floor, the number of stairs, the number of elevators and the maximum speed of an elevator,...
["7\n5\n4"]
#include <stdio.h> #include <string.h> #include <stdlib.h> int stair[100010]; int elevator[100010]; int bestelevator(int y1, int y2, int zzz[], int ce1, int ce2){ if(y1 > y2){ int temp= y1; y1= y2; y2= temp; } if(ce1== ce2){ if(zzz[ce1]>= y1 && zzz[ce1]<= y2){ return 0; } else{ int a= abs(zzz[ce...
In the year of $$$30XX$$$ participants of some world programming championship live in a single large hotel. The hotel has $$$n$$$ floors. Each floor has $$$m$$$ sections with a single corridor connecting all of them. The sections are enumerated from $$$1$$$ to $$$m$$$ along the corridor, and all sections with equal num...
Print $$$q$$$ integers, one per line — the answers for the queries.
C
9bf6be240fb16da07b942be39bb3916a
edfaf1e98d6cb4a1601f08522f9e6d02
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "binary search" ]
1525007700
["5 6 1 1 3\n2\n5\n3\n1 1 5 6\n1 3 5 4\n3 3 5 3"]
NoteIn the first query the optimal way is to go to the elevator in the 5-th section in four time units, use it to go to the fifth floor in two time units and go to the destination in one more time unit.In the second query it is still optimal to use the elevator, but in the third query it is better to use the stairs in ...
PASSED
1,600
standard input
2 seconds
The first line contains five integers $$$n, m, c_l, c_e, v$$$ ($$$2 \leq n, m \leq 10^8$$$, $$$0 \leq c_l, c_e \leq 10^5$$$, $$$1 \leq c_l + c_e \leq m - 1$$$, $$$1 \leq v \leq n - 1$$$) — the number of floors and section on each floor, the number of stairs, the number of elevators and the maximum speed of an elevator,...
["7\n5\n4"]
#include<stdio.h> #include<stdlib.h> #include<limits.h> #include<math.h> int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int n, m, cl, ce, v, q; int l[100005] = { 0 }, e[100005] = {0}; int a1, b1, a2, b2; int min(int a, int b) { return a < b ? a : b; } int stairfind(int x) { int left = 0, rig...
In the year of $$$30XX$$$ participants of some world programming championship live in a single large hotel. The hotel has $$$n$$$ floors. Each floor has $$$m$$$ sections with a single corridor connecting all of them. The sections are enumerated from $$$1$$$ to $$$m$$$ along the corridor, and all sections with equal num...
Print $$$q$$$ integers, one per line — the answers for the queries.
C
9bf6be240fb16da07b942be39bb3916a
0cc63fdeada36a546ae5e3388dc4e0b0
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "binary search" ]
1525007700
["5 6 1 1 3\n2\n5\n3\n1 1 5 6\n1 3 5 4\n3 3 5 3"]
NoteIn the first query the optimal way is to go to the elevator in the 5-th section in four time units, use it to go to the fifth floor in two time units and go to the destination in one more time unit.In the second query it is still optimal to use the elevator, but in the third query it is better to use the stairs in ...
PASSED
1,600
standard input
2 seconds
The first line contains five integers $$$n, m, c_l, c_e, v$$$ ($$$2 \leq n, m \leq 10^8$$$, $$$0 \leq c_l, c_e \leq 10^5$$$, $$$1 \leq c_l + c_e \leq m - 1$$$, $$$1 \leq v \leq n - 1$$$) — the number of floors and section on each floor, the number of stairs, the number of elevators and the maximum speed of an elevator,...
["7\n5\n4"]
#include<stdio.h> #include<stdlib.h> #include<math.h> typedef long long int int64; #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(a) ((a)>(0)?(a):-(a)) void solve(const int n,const int m,const int cl,const int ce,const int v,const int *ll,const int *e){ int x,y,p,q; scanf("%d%d...
In the year of $$$30XX$$$ participants of some world programming championship live in a single large hotel. The hotel has $$$n$$$ floors. Each floor has $$$m$$$ sections with a single corridor connecting all of them. The sections are enumerated from $$$1$$$ to $$$m$$$ along the corridor, and all sections with equal num...
Print $$$q$$$ integers, one per line — the answers for the queries.
C
9bf6be240fb16da07b942be39bb3916a
057c7f7f008b00aa3147caf8dee6802b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "binary search" ]
1525007700
["5 6 1 1 3\n2\n5\n3\n1 1 5 6\n1 3 5 4\n3 3 5 3"]
NoteIn the first query the optimal way is to go to the elevator in the 5-th section in four time units, use it to go to the fifth floor in two time units and go to the destination in one more time unit.In the second query it is still optimal to use the elevator, but in the third query it is better to use the stairs in ...
PASSED
1,600
standard input
2 seconds
The first line contains five integers $$$n, m, c_l, c_e, v$$$ ($$$2 \leq n, m \leq 10^8$$$, $$$0 \leq c_l, c_e \leq 10^5$$$, $$$1 \leq c_l + c_e \leq m - 1$$$, $$$1 \leq v \leq n - 1$$$) — the number of floors and section on each floor, the number of stairs, the number of elevators and the maximum speed of an elevator,...
["7\n5\n4"]
#include <stdio.h> #include <stdlib.h> #include <time.h> #define inf (int)(1e9) #define AVL_keytype int #define AVL_valtype int //static int malloc_cont; //static int free_cont; typedef struct AVL_node_sub{ AVL_keytype key; //添え字 AVL_valtype val; //値 int ele_num; //木に含まれる要素数 int height; //木の高さ struct AVL_node_su...
In the year of $$$30XX$$$ participants of some world programming championship live in a single large hotel. The hotel has $$$n$$$ floors. Each floor has $$$m$$$ sections with a single corridor connecting all of them. The sections are enumerated from $$$1$$$ to $$$m$$$ along the corridor, and all sections with equal num...
Print $$$q$$$ integers, one per line — the answers for the queries.
C
9bf6be240fb16da07b942be39bb3916a
e088f140d6179c61d1ef1100ff7e6f8f
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search" ]
1525007700
["5 6 1 1 3\n2\n5\n3\n1 1 5 6\n1 3 5 4\n3 3 5 3"]
NoteIn the first query the optimal way is to go to the elevator in the 5-th section in four time units, use it to go to the fifth floor in two time units and go to the destination in one more time unit.In the second query it is still optimal to use the elevator, but in the third query it is better to use the stairs in ...
PASSED
1,600
standard input
2 seconds
The first line contains five integers $$$n, m, c_l, c_e, v$$$ ($$$2 \leq n, m \leq 10^8$$$, $$$0 \leq c_l, c_e \leq 10^5$$$, $$$1 \leq c_l + c_e \leq m - 1$$$, $$$1 \leq v \leq n - 1$$$) — the number of floors and section on each floor, the number of stairs, the number of elevators and the maximum speed of an elevator,...
["7\n5\n4"]
#include <limits.h> #include <stdio.h> #define NMAX 100000 static int stairs[NMAX], elevators[NMAX]; static int n, m, cs, ce, v, q, i, line1, line2, col1, col2; static void swap(int *a, int *b) { int aux = *a; *a = *b; *b = aux; } static int min(int a, int b) { if (a < b) return a; retur...
In the year of $$$30XX$$$ participants of some world programming championship live in a single large hotel. The hotel has $$$n$$$ floors. Each floor has $$$m$$$ sections with a single corridor connecting all of them. The sections are enumerated from $$$1$$$ to $$$m$$$ along the corridor, and all sections with equal num...
Print $$$q$$$ integers, one per line — the answers for the queries.
C
9bf6be240fb16da07b942be39bb3916a
5eccc92e9b4127e1e4ad5faa390783ce
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search" ]
1525007700
["5 6 1 1 3\n2\n5\n3\n1 1 5 6\n1 3 5 4\n3 3 5 3"]
NoteIn the first query the optimal way is to go to the elevator in the 5-th section in four time units, use it to go to the fifth floor in two time units and go to the destination in one more time unit.In the second query it is still optimal to use the elevator, but in the third query it is better to use the stairs in ...
PASSED
1,600
standard input
2 seconds
The first line contains five integers $$$n, m, c_l, c_e, v$$$ ($$$2 \leq n, m \leq 10^8$$$, $$$0 \leq c_l, c_e \leq 10^5$$$, $$$1 \leq c_l + c_e \leq m - 1$$$, $$$1 \leq v \leq n - 1$$$) — the number of floors and section on each floor, the number of stairs, the number of elevators and the maximum speed of an elevator,...
["7\n5\n4"]
#define _USE_MATH_DEFINES #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <stdbool.h> #include <float.h> #include <limits.h> #include <malloc.h> #include <memory.h> #include <complex.h> #include <errno.h> #include <time.h> #define Max(X,Y) ((X)>(Y) ? (X) : (Y)) #...
In the year of $$$30XX$$$ participants of some world programming championship live in a single large hotel. The hotel has $$$n$$$ floors. Each floor has $$$m$$$ sections with a single corridor connecting all of them. The sections are enumerated from $$$1$$$ to $$$m$$$ along the corridor, and all sections with equal num...
Print $$$q$$$ integers, one per line — the answers for the queries.
C
9bf6be240fb16da07b942be39bb3916a
76a271cf9e734d6b861bb139f839ef81
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search" ]
1525007700
["5 6 1 1 3\n2\n5\n3\n1 1 5 6\n1 3 5 4\n3 3 5 3"]
NoteIn the first query the optimal way is to go to the elevator in the 5-th section in four time units, use it to go to the fifth floor in two time units and go to the destination in one more time unit.In the second query it is still optimal to use the elevator, but in the third query it is better to use the stairs in ...
PASSED
1,600
standard input
2 seconds
The first line contains five integers $$$n, m, c_l, c_e, v$$$ ($$$2 \leq n, m \leq 10^8$$$, $$$0 \leq c_l, c_e \leq 10^5$$$, $$$1 \leq c_l + c_e \leq m - 1$$$, $$$1 \leq v \leq n - 1$$$) — the number of floors and section on each floor, the number of stairs, the number of elevators and the maximum speed of an elevator,...
["7\n5\n4"]
#define _USE_MATH_DEFINES #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <stdbool.h> #include <float.h> #include <limits.h> #include <malloc.h> #include <memory.h> #include <complex.h> #include <errno.h> #include <time.h> #define Max(X,Y) ((X)>(Y) ? (X) : (Y)) #...
Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three...
Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.
C
436c00c832de8df739fc391f2ed6dac4
f9fe0ef2bee12816d6bb0cb934279325
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "brute force", "strings" ]
1505653500
["hellno", "abacaba", "asdfasdf"]
null
PASSED
1,500
standard input
1 second
The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.
["hell no", "abacaba", "asd fasd f"]
/* Coached by Dukkha */ #include <stdio.h> #include <string.h> #define N 3000 int vowel(char a) { return a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'; } int main() { static char s[N + 1]; int n, i, j, c, d; char x, y, a; scanf("%s", s), n = strlen(s); c = d = 0, x = y = -1; for (i = 0; i < n; i =...
Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three...
Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.
C
436c00c832de8df739fc391f2ed6dac4
526ba8326c5c2608a1089be9013dcef7
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "brute force", "strings" ]
1505653500
["hellno", "abacaba", "asdfasdf"]
null
PASSED
1,500
standard input
1 second
The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.
["hell no", "abacaba", "asd fasd f"]
//by : Linus #include<stdio.h> #include<string.h> char s[3005]; int k=1,p; int space[3005]; int lian[3005]; int alphabet[27]={0}; int che(char c) { //printf("%d",alphabet[c-'a']); return 1-alphabet[c-'a']; } int main() { alphabet['a'-'a']=1; alphabet['e'-'a']=1; alphabet['i'-'a']=1; alphabet['o'-'a']=1; alphabe...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
31373710372130bb72b824eb014f5ef1
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int a=n/4,s=1,i; if(n%4==0) s=0; for(i=0;i<n-a-s;i++) { printf("9"); } for(i=0;i<a+s;i++) { printf("8"); } printf("\n"); } }
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
c26eb5b551a081e98d10669b196401e1
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> long long t, n, x, i; int main() { scanf("%lld", &t); while (t--) { scanf("%lld", &n); x = (n - 1) / 4; for (i = 1; i <= n - x - 1; i++) { printf("9"); } for (i = 1; i <= x; i++) { printf("8"); } printf("8\n"); } return 0; }
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
8b69da77b039949df97a109e1b1e1828
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<string.h> #include<math.h> #include<limits.h> #include<ctype.h> #include<stdbool.h> #define ll long long void test() { int n; scanf("%d", &n); int eightAppearance = (int) ceil((double) n / 4); for(int i = 1; i <= n; i++) { if(i ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
000efcb6366997f7b4011af88efa6ba1
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
// // main.c // 660B // // Created by Veronica Wu on 2020/8/7. // Copyright © 2020 Veronica Wu. All rights reserved. // #include <stdio.h> int main(int argc, const char * argv[]) { int t = 0; scanf("%d",&t); while(t--){ int n = 0,n8=0,a=0; scanf("%d",&n); a = n%4; n8 = ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
344178d2cb132aea006e87b7a9ba1ffb
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> int main() { unsigned int t = 0; scanf("%d", &t); while (t-->0) { int n = 0; scanf("%d", &n); int eights = 0; if (n / 4 == 0) eights = 1; else eights = n / 4 + (n % 4 == 0 ? 0 : 1); int i = n - eights; ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
ed0cac670725fd5793bc93c6edd19344
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> #include<math.h> #include<string.h> int main() { int t,a=0,b=0,i,j,n,s=0,k,z,max=0,smax=0,it=10,fl=0,min=0,x=0,y; scanf("%d",&t); for(j=0;j<t;j++) { scanf("%d",&n); if(n==1) { printf("8\n"); continue; } if(n%4!=0) ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
d1ec3a9b1b555cce62322b63a617a9e5
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> int main(void) { int n; scanf("%d",&n); while(n--) { int t; scanf("%d",&t); for(int i=0;i<t-((t-1)/4+1);i++) printf("9"); for(int i=0;i<((t-1)/4+1);i++) printf("8"); printf("\n"); } }
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
64b9c6d94fdabdbc244638c554904fe7
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> 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]; fo...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
63f9c8e05860f94d63451007646b479a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> #include<string.h> int main() { int t, n, temp; scanf("%d", &t); while(t > 0) { scanf("%d", &n); if(n % 4 == 0) { temp = n - (n / 4); for(int i = 0; i < temp; i++) printf("9"); for(int i = 0; i < n / 4; i++) printf("8"); } else { temp = n - 1 - (n / 4); for(int i = 0; ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
8970bcd5b62212edceb1fb2dd366721f
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> #include<string.h> int main() { int t, n, temp; scanf("%d", &t); while(t > 0) { scanf("%d", &n); if(n % 4 == 0) { temp = n - (n / 4); for(int i = 0; i < temp; i++) printf("9"); for(int i = 0; i < n / 4; i++) printf("8"); } else { temp = n - 1 - (n / 4); for(int i = 0; i...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
3702da6363e42b5af0b1ed07a6c529c3
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> #include<math.h> #include<string.h> int main() { int t,a=0,b=0,i,j,n,s=0,k,z,max=0,smax=0,it=10,fl=0,min=0,x=0,y; scanf("%d",&t); for(j=0;j<t;j++) { scanf("%d",&n); if(n==1) { printf("8\n"); continue; } if(n%4!=0) ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
4f2cae3523426fc5d0d3ec03f62635d5
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> int main(){ int t; scanf("%d", &t); while(t--){ int n; scanf("%d", &n); int b = n / 4 + (n % 4 > 0); for(int i = 0; i < n - b; i++){ printf("9"); } for(int i = 0; i < b; i++){ printf("8"); } puts(""); } }
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
16c14ef6345c0001f8f83028f3d499ea
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int a,x; scanf("%d",&a); if(a%4==0) { x=a/4; } else { x=(a/4)+1; } for(int i=1;i<=a-x;i++) { printf("9"); } ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
500bf4c2ca3b4e2f50443ffb765dc1b1
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> int main(){ int t; scanf("%d",&t); while(t>0){ int n; long long int val = 0; scanf("%d",&n); int a[n]; for(int i=0;i<n;i++){ a[i] = 0; } if(n%4==0){ for(int i=0;i<n;i++){ val*=10; if(i<=n-1-n/4){ a[i] = 9; } else{ a[i] = 8; } } ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
86aa60012fc543a69d3bcba91cbe0980
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> #include <string.h> #include <stdlib.h> int main() { int n ; scanf("%d", &n); for(int i = 0;i<n;i++){ int t ; scanf("%d",&t); if(t ==1) { printf("%d\n", 8 ); } else if(t ==2) { printf("%d\n", 98 ); } else if(t ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
5ae18a601286437901c68f41aff231cf
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> #include<conio.h> #include<string.h> #include<math.h> int main() { int t; scanf("%d",&t); while(t--) { int a,b,n,m,x,y,z,i,j,k,l; scanf("%d",&n); a=n%4==0?n/4:(n/4)+1; for(i=1;i<=n-a;i++) { printf("9"); } for(i=0;i<a;i...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
7fda247e380a0bc66e8f5238c42c46d3
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> #include <stdlib.h> #include <math.h> int main(void) { int t; scanf("%d\n",&t); while(t--){ int n; scanf("%d\n",&n); int a[n]; for(int i=0;i<n;i++) a[i]=9; int num; if(n%4==0) num=n/4; else num=(n/4)+1; int j=n-1; ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
ce132717aba8a444eafed5caab40ffd2
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> int main(){ int t; scanf("%d",&t); while (t--){ int n,i; scanf("%d",&n); int a=n/4; if (a<=1){ for (i=0;i<n-1;i++) printf("9"); printf("8\n"); }else if (n%4==0&&a>1) { for (i=0;i<n-a;i++) printf("9"); ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
63215da959778545690396f4faccd4d9
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> #include<string.h> int main() { int t; scanf("%d",&t);int i; for(i=0;i<t;i++) { int n,j;scanf("%d",&n);int m=0,e=0; if(n%4==0) e=n/4; else e=n/4+1; m=n-e; for(j=0;j<m;j++) printf("9"); for(j=0;j<e;j++) ...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
d18806e1559538f7f62ed075efdcf28c
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> #include <math.h> int main(){ int n,a[1001],x,y,i,j; scanf("%d",&n); for (i=0;i<n;i++) scanf("%d",&a[i]); for (i=0;i<n;i++){ x=(a[i]-1)/4; x+=1; y=a[i]-x; while (y>0){ printf("9"); y--; } while (x>0){ printf("8"); x--; } printf("\n...
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
b568f5508970905b31d02b0e775dd113
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include <stdio.h> int main(void) { int n; scanf("%d",&n); while(n--) { int t; scanf("%d",&t); for(int i=0;i<t-((t-1)/4+1);i++) printf("9"); for(int i=0;i<((t-1)/4+1);i++) printf("8"); printf("\n"); } }
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.I...
For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.
C
80c75a4c163c6b63a614075e094ad489
ddcf9a1b0c5880da597b78f688bf8940
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math" ]
1596119700
["2\n1\n3"]
NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obta...
PASSED
1,000
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the integer $$$x$$$ you need to find. It's...
["8\n998"]
#include<stdio.h> void denisnumber(int n) { int i,k; if(n%4==0) { k = n/4; for(i=0;i<n-k;i++) { printf("9"); } for(i=0;i<k;i++) { printf("8"); } } else { k = n/4 + 1; for(i=0;i<n-k;i++) { printf("9"); } for(i=0;i<k;i++) { printf("8"); } } printf("\n"); } main() { int n,i...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
a6bc9159ac123bbb6d996ddc261e672c
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> int main() { int n,i,a=0,b=0,c=0,d=0,e=0,f=0,min; char lamps[200005]; scanf("%d",&n); scanf("%s",lamps); for(i=0;i<n;i+=3) { if(lamps[i]!='R') ++a; if(lamps[i+1]!='G') ++a; if(lamps[i+2]!='B') ++a; } min=a; ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
dafbcc73ff4d8851d3ecde83bac70dd9
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> char c[200001] = ""; char color[50][50]={"RGB","RBG","GRB","BRG","GBR","BGR"}; int main(void) { long n,i,j,k,cnt[6] = {0},min; scanf("%ld",&n); getchar(); for(i = 0; i < n; i ++) scanf("%c",&c[i]); for(k = 0; k < 6; k ++){ for(i = 0,j=0;c[i]!='\0';i++,j++){ if(c[i]!=color[k][j]) cnt[k]++; ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
1f385ef3175c8f592576479c36acafe3
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> #define N 200000 char tt[][4] = { "RGB", "RBG", "GRB", "GBR", "BRG", "BGR" }; int main() { static char s[N + 1]; int n, i, h_, h, min, cnt; scanf("%d%s", &n, s); min = n + 1, h_ = -1; for (h = 0; h < 6; h++) { cnt = 0; for (i = 0; i < n; i++) if (s[i] != tt[h][i % 3]) cnt++; if ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
81531bbca284d9f25baca484887fd478
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> #include <stdlib.h> int main() { int n,count=0,min=200000,h=-1; char s[200000]; char k[][4]={"BRG","BGR","GRB","GBR","RGB","RBG"}; scanf("%d%s",&n,&s); for(int i=0;i<6;i++) { count=0; for(int j=0;j<n;j++) { if(s[j]!=k[i][j%3]) { ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
9aadb888434cdec6cc0c6d99c20caa8b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> #include<stdlib.h> int count[6]={0}; void compare(char str[],int n); void print_nice_garland(int pos,int n); int main(){ int i,n; char str[200005]; int min,pos=0; scanf("%d",&n); getchar(); scanf("%s",str); compare(str,n); min=count[0]; for(i=1;i<6;i++) ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
b392cb9d81b6fbabac145795f10dce12
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> #include<limits.h> int n, i, min = INT_MAX, flag; int count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0, count6 = 0; char s1[4] = "RGB", s2[4] = "RBG"; char s3[4] = "GBR", s4[4] = "GRB"; char s5[4] = "BGR", s6[4] = "BRG"; char s[200050],cp[200050]; int main() { scanf("%d %s", &n,&s); for (i...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
8783a8665fd6a27f3ed22c20796bdcfa
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> #include<string.h> char s[200005],w[10][200005]; int a[10]; int main() { int n; scanf("%d",&n); scanf("%s",s+1); memset(a,0,sizeof(a)); int t=n/3; for(int i=1; i<=t; i++) { if(s[i*3-2]!='R') { a[1]++; } w[1][i*3-2]='R'; if...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
cb820127e45f9c30bbcdbdfbaf0d190f
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
/* Coached by rainboy */ #include <stdio.h> #define N 200000 char cc[][4] = { "RGB", "RBG", "GBR", "GRB", "BRG", "BGR" }; int main() { static char s[N + 1]; int n, h, h_, min, i; scanf("%d%s", &n, s); min = n + 1; for (h = 0; h < 6; h++) { int cnt = 0; for (i = 0; i < n; i++) cnt += s[i] != cc[h][i % 3...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
30482ed1111f74e24eee659d48a1e88a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> int main() { long long int n,i,value1=0,value2=0,value3=0,value4=0,value5=0,value6=0,min,q; scanf("%lld",&n); char s[n]; scanf(" %s",s); for(i=0;i<n;i++) { if(i%3==0) { if(s[i]!='G') value1++; } else if(i%3==1) { if(s[i]!='R') value1++; } else if(i%3==2) { if(s[i...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
8925c9bd077432087c5c9d533cc6effd
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> #include<stdlib.h> #include <string.h> char max(int a,int b,int c) { if(a>=b && a>=c) return 'R'; else if(b>=a && b>=c) return 'G'; else return 'B'; } int main() { int n,r; scanf("%d",&n); char a[n+1]; scanf("%s",a); int i,j; int b[3][3]; for(i=0;i<3;i++) for(j=0;j<3;j++) b[i...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
57148c77afce7e491622b1ae17a71211
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> int main() { long long int n,c1,c2,c3,c4,c5,c6,co[6],c=0,i,ans; char a[200000]; scanf("%lld",&n); scanf("%s",a); c=0; for(i=0;i<n;i++){ if(i%3==0){ if(a[i]!='G'){ c++; } } if(i%3==1){ if(a[i]!='R'){ c++; } } ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
8d91dff91427298fdb6939ca518ecc4c
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> int main() { int n; scanf("%d",&n); int a[n]; char q; scanf("\n"); for(int i=0;i<n;i++){ scanf("%c",&q); if(q=='R') a[i]=1; else if(q=='G') a[i]=2; else a[i]=3; } int b1[n],b2[n],b3[n],b4[n],b5[n],b6...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
058b77e9c8d59ea2789f92729eb6c314
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int i, j, n, r[3], g[3], b[3], m, k, x[6]; char s[400000]; int bin(int s, int p, int k) { } int war(const void*a, const void*b) { return(*(int*)b-*(int*)a); } int main() { scanf("%d%s", &n, s); for(i=0; i<n; i++) { ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
4d13cbfac9e2c4187af976b1644c47d5
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> #include <stdlib.h> int gc(char c){ if(c=='R') return 0; if(c=='G') return 1; if(c=='B') return 2; return -1; } char pc(int i,int t){ if(t<3){ switch((i+t)%3){ case 0: return 'R'; break; case 1: return 'G'; break; case 2: return 'B'; break; default: return 0; break; } }else{ swi...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
71bf3ef643712bc8a48334d69269d022
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> int main() { char s[6][3]={"RGB","RBG","BRG","BGR","GBR","GRB"}; int a,count,y,n,i,j; scanf("%d",&n); y=n; char b[n]; scanf("%s",b); for(i=0;i<6;i++) { count=0; for(j=0;j<n;j++) { if(b[j]!=s[i][j%3]) count++; } ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
4aff310b32912ffb221bf614fc5b9aa5
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> int main() { int n, f=0, min=1e8, cnt=0; scanf("%d", &n); char s[1000000]; scanf("%s", s); char temp[3]={'R', 'G', 'B'}; for (int i = 0; s[i]!='\0'; ++i) { if(s[i]!=temp[i%3]) cnt++; } if(cnt<min) { min=cnt; f=1; } cnt=0; temp[0]='R'; temp[1]='B'; temp[2]='G'; for (in...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
8208f756f2e09cc90758453eeee4931d
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> int main(){ int n,i,j=0,count[6],min=200000,c=0,a=0; char col[200000],test[6][3]={{'R','G','B'},{'R','B','G'},{'G','B','R'}, {'G','R','B'},{'B','G','R'},{'B','R','G'},}; for(i=0;i<6;i++){ count[i]=0; } scanf("%d ",&n); scanf("%s",col); for(i=0;i<6;i++){ for(j=0;j<n;j++){ if( ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
921c958468cc73adcdfa0f3f466f3735
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> char c[200001]; int main() { int n; scanf("%d", &n); scanf("%s", c); int min = 300000; int flag = 0; for(int i = 0; i < 3; i++) { int dif = 0; for(int j = 0; j < n; j++) { char tmp; if(!((i + j) % 3)) tmp = 'R'; else if(((i + j) % 3) & 1) tmp = 'G'; else tmp = 'B'; if(tmp ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
7c35fcc7f0f32f8987af405dd82e6111
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> int main() { int n; char str[200001]; char match[][3] = {"RGB", "RBG", "GRB", "GBR", "BRG", "BGR"}; scanf("%d %s", &n, str); int ans = 200001; int idx = -1; for(int i = 0; i < 6; ++i) { int cur = 0; for(int j = 0; str[j]; ++j) { if(str[j] != ma...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
142ff250039a9fbdf3dba6886fdadddb
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; int k; int num=0; int min=999999999, mini=0; char str[200001]; char str2[200010]; char rgb[6][4]={"RGB","RBG","BRG","BGR","GRB","GBR"}; scanf("%d",&n); k=(n-1)/3+1; scanf("%s",str); for (int i=0; ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
69a0e441320f6380a56fec73850d3f4f
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #include<string.h> #include<limits.h> int main(void) { char str[200001]; char color_arr[6][3] = { "RGB","RBG","GRB","GBR","BRG","BGR" }; int n; scanf("%d", &n); scanf("%s", str); int a, i_cnt = INT_MAX; for (int i = 0; i < 6; i++) { int c...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
8f8012b958cd14dca179340f366773b3
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 200002 int check (char s[], const char col[3], int n, char str[]) { int i, err = 0; for (i = 0; i < n; i++) { str[i] = col[i % 3]; if (str[i] != s[i]) err++; } return err; } int main() { int n, min = SIZE, cnt; char s[SIZE], str[S...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
c75908c6d9b4ac975e8008802298de22
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> #include <string.h> #define N 200005 char s[N]; const char* ss[] = { "RGB", "GBR", "BRG", "BGR", "GRB", "RBG" }; int func(int n, int m) { int i, c = 0; for (i = 0; i < n; i++) if (s[i] != ss[m][i%3]) c++; return c; } void output(int ans, int id, int n) { ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
5cabe25efe65ea792c8f68477e9e1a9a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> #include<stdlib.h> #define size 2*100000 main() { int n,i,min=size,rem=-1,j,count; scanf("%d",&n); char s[size+1]; scanf("%s",s); char tt[][4]={"GRB","GBR","BRG","BGR","RBG","RGB"}; for(i=0;i<6;++i) { count=0; for(j=0;j<n;++j) { if(s[j]!=tt[i][j%3]) { count++;...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
add98aaabfbd37bde9be1c6b2e635321
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> #include<stdlib.h> #define size 2*100000 int min_(int x,int y) { return x<y?x:y; } main() { int n,i,ans; int count1=0,count2=0,count3=0,count4=0,count5=0,count6=0; scanf("%d",&n); char s[size+1]; char str1[size+1]; char str2[size+1]; char str3[size+1]; char str4[size+1]; char str5[...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
465c7ee594c1b68ba63d4b3d77416ae8
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> int main() { const char* RGB[] = {"RGB", "RBG", "GRB", "GBR", "BRG", "BGR"}; int n; scanf("%d", &n); char s[n]; scanf("%s", s); int ans = 1e8, index = -1; for(int i = 0; i < 6; i++) { int change = 0; for(int j = 0; j < n; j++) { if(s...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
a656bee19b70391ae8a5175a83b5ad14
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include <stdio.h> int main() { const char* RGB[] = {"RGB", "RBG", "GRB", "GBR", "BRG", "BGR"}; int n; scanf("%d", &n); char s[n]; scanf("%s", s); int ans = 1e8, index = -1; for(int i = 0; i < 6; i++) { int change = 0; for(int j = 0; j < n; j++) { if(s...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
5be6f97a869552ffb2f9a91b55b08e8a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> char a[300009],b[300009],c[300009],d[300009],e[300009],f[300009],g[300009]; int main() { int n,i,j,k,l,m,o,p,q; scanf("%d",&n); getchar(); for(i=0;i<n;i++){ scanf("%c",&d[i]); c[i]=d[i]; b[i]=c[i]; a[i]=b[i]; e[i]=a[i]; f[i]=e[i]; ...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
7ba00c0cc6b1379ea878113ec7076d6b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> #include<stdlib.h> int c[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; int main(){ int n, res = 2000000; scanf("%d\n", &n); for(int i = 0; i < n; ++i){ char ch; scanf("%c", &ch); if(ch == 'R') ++c[i % 3][0]; if(ch == 'G') ++c[i % 3][1]...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
eb171c2d45b3f5e6f51b87a68f25e411
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> #include<math.h> #include<string.h> int main(){ int n; scanf("%d",&n); char s[200010]; scanf("%s",s); int diff,diff_min=99999999; char min_str[4]; int i; // RGB min_str:0 diff=0; for(i=0;i<n;i++){ if(i%3==0 && s[i]!='R'){ diff++; }else if(i%3==1 && s[i]!='G'){ diff++; }els...
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the...
In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple...
C
e67b79e39511b0107a51edc0179afb82
e8477e04db906caff9f94b7916065290
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy", "math", "brute force" ]
1548254100
["3\nBRB", "7\nRGBGRBB"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.
["1\nGRB", "3\nRGBRGBR"]
#include<stdio.h> int b[3][3]; int main() { int n;scanf("%d",&n); char a[n]; scanf("%s",a); for(int i=0;i<n;i+=3) { if(a[i]=='R')b[0][0]++; else if(a[i]=='G')b[0][1]++; else b[0][2]++; } for(int i=1;i<n;i+=3) { if(a[i]=='R')b[1][0]++; else if(a[i]=='G')b[1][1]++; ...