prob_desc_description stringlengths 63 3.8k | prob_desc_output_spec stringlengths 17 1.47k β | lang_cluster stringclasses 2
values | src_uid stringlengths 32 32 | code_uid stringlengths 32 32 | lang stringclasses 7
values | prob_desc_output_to stringclasses 3
values | prob_desc_memory_limit stringclasses 19
values | file_name stringclasses 111
values | tags listlengths 0 11 | prob_desc_created_at stringlengths 10 10 | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_notes stringlengths 4 3k β | exec_outcome stringclasses 1
value | difficulty int64 -1 3.5k β | prob_desc_input_from stringclasses 3
values | prob_desc_time_limit stringclasses 27
values | prob_desc_input_spec stringlengths 28 2.42k β | prob_desc_sample_outputs stringlengths 2 796 | source_code stringlengths 42 65.5k | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | 473c720b8a9958afc3188e544b0853b6 | GNU C11 | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 222222
typedef long long ll;
typedef struct {ll v, w;} pair;
typedef struct _list{
pair p;
struct _list *next;
} list;
list *g[N];
ll n, m, a, b, w, size, dist[N], prev[N], ans[N], ind;
pair pq[N];
void... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | d7cd2da14e1d03e6c1d4a04405019f4c | GNU C11 | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 222222
typedef long long ll;
typedef struct {ll v, w;} pair;
typedef struct _list{
pair p;
struct _list *next;
} list;
list *g[N];
ll n, m, u, v, w, size, dist[N], prev[N];
pair pq[N];
void min_heapify(... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | 1eeefe432e413837bb2244c89cb01b01 | GNU C11 | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 222222
typedef long long ll;
typedef struct {ll v, w;} pair;
typedef struct _list{
pair p;
struct _list *next;
} list;
list *g[N];
ll n, m, a, b, w, size, dist[N], prev[N];
pair pq[N];
void min_heapify(... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | a7b7d3521151fec6a658497e6824ad11 | GNU C11 | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 222222
typedef long long ll;
typedef struct {ll v, w;} pair;
typedef struct _list{
pair p;
struct _list *next;
} list;
list *g[N];
ll n, m, a, b, w, size, dist[N], prev[N], ans[N], ind;
pair pq[N];
void... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | 49596bef68f7bad96d835e543563166f | GNU C11 | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 222222
typedef long long ll;
typedef struct {ll v, w;} pair;
typedef struct _list{
pair p;
struct _list *next;
} list;
list *g[N];
ll n, m, u, v, w, size, dist[N], prev[N];
pair pq[N];
void min_heapify(... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | eabbb9664887b23d520fbd22c2008bcf | GNU C11 | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #define _CRT_SECURE_NO_WARNINGS
#include "stdio.h"
#include "stdlib.h"
#include "limits.h"
long long inf = LLONG_MAX;
typedef struct vec
{
int *arr;
long long *wgt;
int size;
int cap;
} vec;
vec* g;
void push(vec* a, int val, long long w)
{
if (a->cap == 0)
{
a->cap = 3;
a->arr = (int*)malloc(3 * sizeof(i... | |
It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly S slices.It is known that the i-th contestant will eat si slices of pizza, and gain ai ha... | Print the maximum total happiness that can be achieved. | C | 769859d86a3ceb2d89a444cd64c9a73b | 3514cddf7351b400838121472659494f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"binary search",
"sortings",
"ternary search"
] | 1506791100 | ["3 12\n3 5 7\n4 6 7\n5 9 5", "6 10\n7 4 7\n5 8 8\n12 5 8\n6 11 6\n3 3 7\n5 9 6"] | NoteIn the first example, you only need to buy one pizza. If you buy a type 1 pizza, the total happiness will be 3Β·5β+β4Β·6β+β5Β·9β=β84, and if you buy a type 2 pizza, the total happiness will be 3Β·7β+β4Β·7β+β5Β·5β=β74. | PASSED | 1,900 | standard input | 2 seconds | The first line of input will contain integers N and S (1ββ€βNββ€β105,β1ββ€βSββ€β105), the number of contestants and the number of slices per pizza, respectively. N lines follow. The i-th such line contains integers si, ai, and bi (1ββ€βsiββ€β105,β1ββ€βaiββ€β105,β1ββ€βbiββ€β105), the number of slices the i-th contestant will eat,... | ["84", "314"] | #include <stdio.h>
#include <stdlib.h>
typedef struct{
int slice, a, b;
}Person;
Person p[100001], Pa[100001], Pb[100001];
int mycmp(const void* a, const void* b){
const Person* sa = (const Person*)a;
const Person* sb = (const Person*)b;
return (sa->a-sa->b)-(sb->a-sb->b);
}
int main(){
int n, s;
scanf(... | |
You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance b... | For each test case print one integer β the maximum distance between two rivaling students which you can obtain. | C | 1fd2619aabf4557093a59da804fd0e7b | 72aae9cf56d63a10f5d665c48744ca77 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"greedy",
"math"
] | 1573655700 | ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"] | NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students. | PASSED | 800 | standard input | 1 second | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 100$$$, $$$0 \le x \le 100$$$, $$$1 \le a, b \le n$$$, $$$a \neq b$$$) β the number of students in the row, the num... | ["2\n99\n1"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int t,i,n,x,a,b;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d%d",&n,&x,&a,&b);
int m=abs(a-b);
if(m+x<n)
printf("%d\n",m+x);
else
printf("%d\n",n-1);
}
return 0;
}
| |
You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance b... | For each test case print one integer β the maximum distance between two rivaling students which you can obtain. | C | 1fd2619aabf4557093a59da804fd0e7b | f59bc855037deeb5a67f649d081e17f9 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"greedy",
"math"
] | 1573655700 | ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"] | NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students. | PASSED | 800 | standard input | 1 second | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 100$$$, $$$0 \le x \le 100$$$, $$$1 \le a, b \le n$$$, $$$a \neq b$$$) β the number of students in the row, the num... | ["2\n99\n1"] | #include<stdio.h>
main()
{
int n,i,j,a,b,c,d,e,f;
scanf("%d",&n);
for(i=0; i<n; i++)
{
scanf("%d%d%d%d",&a,&b,&c,&d);
e=abs(c-d)+b;
f=a-1;
if(e>=f)
printf("%d\n",f);
else
printf("%d\n",e);
}
}
| |
You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance b... | For each test case print one integer β the maximum distance between two rivaling students which you can obtain. | C | 1fd2619aabf4557093a59da804fd0e7b | c942725aaf3e3ce0d037583f12235a3e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"greedy",
"math"
] | 1573655700 | ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"] | NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students. | PASSED | 800 | standard input | 1 second | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 100$$$, $$$0 \le x \le 100$$$, $$$1 \le a, b \le n$$$, $$$a \neq b$$$) β the number of students in the row, the num... | ["2\n99\n1"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int t, n, i, a, b, c, d, sum, dif;
scanf("%d", &t);
for(i=1; i<=t; i++)
{
scanf("%d %d %d %d", &a, &b, &c, &d);
if( (c==a && d==1) || (d==a && c==1) )
{
printf("%d\n", a-1);
}
else if(c > d)
... | |
You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance b... | For each test case print one integer β the maximum distance between two rivaling students which you can obtain. | C | 1fd2619aabf4557093a59da804fd0e7b | 05aadc178190a788b2b177db8490d483 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"greedy",
"math"
] | 1573655700 | ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"] | NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students. | PASSED | 800 | standard input | 1 second | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 100$$$, $$$0 \le x \le 100$$$, $$$1 \le a, b \le n$$$, $$$a \neq b$$$) β the number of students in the row, the num... | ["2\n99\n1"] | #include<stdio.h>
int main()
{
int t,n,x,a,b;
int i,j,c,d,m,s;
scanf("%d",&t);
for(j=0;j<t;j++)
{
scanf("%d %d %d %d",&n,&x,&a,&b);
if(!x || a-b==n-1 || b-a==n-1)
{
m=a-b;
if(m>0) printf("%d\n",m);
else printf("%d\n",-m);
}
... | |
You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance b... | For each test case print one integer β the maximum distance between two rivaling students which you can obtain. | C | 1fd2619aabf4557093a59da804fd0e7b | 4d613887bd8319b59cc900613256334f | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"greedy",
"math"
] | 1573655700 | ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"] | NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students. | PASSED | 800 | standard input | 1 second | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 100$$$, $$$0 \le x \le 100$$$, $$$1 \le a, b \le n$$$, $$$a \neq b$$$) β the number of students in the row, the num... | ["2\n99\n1"] | #include<stdio.h>
#include<math.h>
int main()
{
int t,n,x,a,b,dis;
scanf("%d",&t);
while(t>0)
{
scanf("%d%d%d%d",&n,&x,&a,&b);
dis=abs(a-b);
if(dis+x>n-1)
printf("%d\n",n-1);
else
printf("%d\n",dis+x);
t--;
}
return 0;
}
| |
You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance b... | For each test case print one integer β the maximum distance between two rivaling students which you can obtain. | C | 1fd2619aabf4557093a59da804fd0e7b | 2dc7ea08a961015a78c2e407e8d9ba31 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"greedy",
"math"
] | 1573655700 | ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"] | NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students. | PASSED | 800 | standard input | 1 second | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 100$$$, $$$0 \le x \le 100$$$, $$$1 \le a, b \le n$$$, $$$a \neq b$$$) β the number of students in the row, the num... | ["2\n99\n1"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int abs(int );
int main(int argc, char *argv[])
{
int num,i,n,x,a,b;
scanf("%d",&num);
for(i=0;i<num;i++)
{
scanf("%d %d %d %d",&n,&x,&a,&b);
if(abs(a-b)+x<n-1)
printf("%d",abs(a-b)+x);
else
printf("%d",abs(n-1));
if(i!=num-1)
printf("\... | |
You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance b... | For each test case print one integer β the maximum distance between two rivaling students which you can obtain. | C | 1fd2619aabf4557093a59da804fd0e7b | 652ca8310b1e2aa927b8446e37b9f891 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"greedy",
"math"
] | 1573655700 | ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"] | NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students. | PASSED | 800 | standard input | 1 second | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 100$$$, $$$0 \le x \le 100$$$, $$$1 \le a, b \le n$$$, $$$a \neq b$$$) β the number of students in the row, the num... | ["2\n99\n1"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int t;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
int n,s,a,b;
scanf("%d%d%d%d",&n,&s,&a,&b);
int diff=abs(a-b);
if(a<=b)
{
}
else
{
int temp=a;
// printf("max is %d\n",max);
... | |
You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance b... | For each test case print one integer β the maximum distance between two rivaling students which you can obtain. | C | 1fd2619aabf4557093a59da804fd0e7b | 95617622c797b0545291e7c448783536 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"greedy",
"math"
] | 1573655700 | ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"] | NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students. | PASSED | 800 | standard input | 1 second | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \le n \le 100$$$, $$$0 \le x \le 100$$$, $$$1 \le a, b \le n$$$, $$$a \neq b$$$) β the number of students in the row, the num... | ["2\n99\n1"] | #include<stdio.h>
#include<math.h>
int main()
{
int t,n,x,a,b,c,d,e;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
scanf("%d%d%d%d",&n,&x,&a,&b);
c= abs(a-b);
d=x+c;
if(d>=n)
printf("%d\n",n-1);
else
printf("%d\n",d);
}
return 0;
} | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | ed09a70992672bb4ad627ad1f435d391 | GNU C | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include<stdio.h>
#include<stdlib.h>
//THIS IS A MIN HEAP!!!!
struct Node{
int val;
int weight;
struct Node* next;
};
int fake;
int parentarr[200005]={0};
struct Node* edges[200005]={NULL};
int A[200005]={0}; //Zero indicates that the location is empty
int B[200005]={0};
int pos[200005]={0}; //Position of each ve... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | 56703fdd081b044156d7bb6fa7e2657b | GNU C | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include<stdio.h>
#include<stdlib.h>
//THIS IS A MIN HEAP!!!!
struct Node{
int val;
int weight;
struct Node* next;
};
int fake;
int parentarr[200005]={0};
struct Node* edges[200005]={NULL};
int A[200005]={0}; //Zero indicates that the location is empty
int B[200005]={0};
int pos[200005]={0}; //Position of each ve... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | a819ecb0378e998bcd3fecfacf08668f | GNU C | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct {
void *buf;
int size_t, size, capacity;
void(*copy)(void *, void *);
int(*comp)(const void *, const void *);
} PriorityQueue;
void init_pq(PriorityQueue *ppq, int size_t, int capacity, void(*copy)(void *, void *), int(*comp)(const void *, cons... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | 12465a918b3a1ad7fff28932906d8d8a | GNU C | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define MAX 100009
typedef struct node{
long long int val;
long long int weight;
struct node *next;
}node;
node* a[MAX];
long long int heap[MAX],dis[MAX],size=0,pos[MAX],par[MAX],ans[MAX];
bool vis[MAX];
void shuffleup(long long int pos1){
long long int ... | |
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | C | bda2ca1fd65084bb9d8659c0a591743d | 28dde20e44951f141bf2ece87743107b | GNU C | standard output | 64 megabytes | train_000.jsonl | [
"shortest paths",
"graphs"
] | 1276875000 | ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"] | null | PASSED | 1,900 | standard input | 1 second | The first line contains two integers n and m (2ββ€βnββ€β105,β0ββ€βmββ€β105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1ββ€βai,βbiββ€βn,β1ββ€βwiββ€β106), where ai,βbi are edge endpoints and wi is the length of the edge. It is possible that the... | ["1 4 3 5", "1 4 3 5"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>
#define MAX 100005
#define MAXI 300005
#define int_max 10000000000000000
typedef long long int ll;
struct node
{
ll v;
ll wt;
struct node* next;
};
struct vertex
{
ll v;
ll min;
};
struct node *head[MAX];
struct node *tai... | |
Kolya is going to make fresh orange juice. He has n oranges of sizes a1,βa2,β...,βan. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr... | Print one integerΒ β the number of times Kolya will have to empty the waste section. | C | 06e9649963715e56d97297c6104fbc00 | 8d81dc8f92310ef0a6eea665985bbf26 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1472056500 | ["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"] | NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all. | PASSED | 900 | standard input | 1 second | The first line of the input contains three integers n, b and d (1ββ€βnββ€β100β000, 1ββ€βbββ€βdββ€β1β000β000)Β β the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1,βa2,β..... | ["1", "0", "1", "0"] | #include<stdio.h>
int main()
{
int n,b,d,s=0,e=0,i;
scanf("%d%d%d",&n,&b,&d);
int a[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]<=b)
{
s=s+a[i];
if(s>d)
{
e++;
s=0;
... | |
Kolya is going to make fresh orange juice. He has n oranges of sizes a1,βa2,β...,βan. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr... | Print one integerΒ β the number of times Kolya will have to empty the waste section. | C | 06e9649963715e56d97297c6104fbc00 | 388401f782fc3b711ee027649c3c463a | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1472056500 | ["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"] | NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all. | PASSED | 900 | standard input | 1 second | The first line of the input contains three integers n, b and d (1ββ€βnββ€β100β000, 1ββ€βbββ€βdββ€β1β000β000)Β β the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1,βa2,β..... | ["1", "0", "1", "0"] | #include <stdio.h>
//#define DEBUG
int main(void) {
#ifdef DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int i, n, b, d, a, total = 0;
long long to_empty = 0;
scanf("%d%d%d", &n, &b, &d);
for(i = 0; i < n; ++i) {
scanf("%d", &a);
if (a > b)
continue;
total ... | |
Kolya is going to make fresh orange juice. He has n oranges of sizes a1,βa2,β...,βan. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr... | Print one integerΒ β the number of times Kolya will have to empty the waste section. | C | 06e9649963715e56d97297c6104fbc00 | d6281eb7663e7d4e8eac10b1a1ce0087 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1472056500 | ["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"] | NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all. | PASSED | 900 | standard input | 1 second | The first line of the input contains three integers n, b and d (1ββ€βnββ€β100β000, 1ββ€βbββ€βdββ€β1β000β000)Β β the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1,βa2,β..... | ["1", "0", "1", "0"] | #include <stdio.h>
int main(void)
{
// your code goes here
int n=0;
int b=0;
int d=0;
long int s=0;
int Tmp=0;
int Result=0;
scanf("%i%i%i",&n,&b,&d);
while (n>0)
{
scanf("%i",&Tmp);
if (Tmp<=b)
s+=Tmp;
if (s>d)
{
s=0;
Result++;
}
n--;
}
printf("%ld", Result);
return 0;
} | |
Kolya is going to make fresh orange juice. He has n oranges of sizes a1,βa2,β...,βan. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr... | Print one integerΒ β the number of times Kolya will have to empty the waste section. | C | 06e9649963715e56d97297c6104fbc00 | acbccafe27e3d447b8826f57b38bf0e9 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1472056500 | ["2 7 10\n5 6", "1 5 10\n7", "3 10 10\n5 7 7", "1 1 1\n1"] | NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all. | PASSED | 900 | standard input | 1 second | The first line of the input contains three integers n, b and d (1ββ€βnββ€β100β000, 1ββ€βbββ€βdββ€β1β000β000)Β β the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1,βa2,β..... | ["1", "0", "1", "0"] | #include<stdio.h>
int main()
{
int n,a,b,c,i,j,k,l=0,sum=0;
scanf("%d %d %d",&n,&a,&b);
for(i=1;i<=n;i++)
{
scanf("%d",&c);
if(c>a)
{continue;}
else
{
sum=sum+c;
if(sum>b)
{
l++;
... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 6bb470b6fb6dd96cb43e70c84355f52f | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
int main()
{
int test;
int one;
int two;
int three;
char prev;
int start;
int min;
char *S=(char *)malloc(sizeof(char)*(2*100000+10));
scanf("%d",&test);
for(int t=0;t<test;t++)
... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 782fc68d3200f9b9aebd70e9d9546025 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 200000
struct info {
int *a;
int c;
} pos[4];
char s[N];
void rlc (int i, int c) {
pos[i].a = (int *) realloc (pos[i].a, c * sizeof *pos[i].a);
}
void push (int n, int i) {
int c;
c = pos[n].c += 1;
rlc (n, c);
pos[n].a[c - 1] = i;
}
in... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | d251d2513d640e706fe668ef0fb9ae5e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<string.h>
char s[200005];
int min(int a, int b)
{
return a < b ? a : b;
}
int main(void)
{
int t;
scanf("%d", &t);
int len, flag;
int Min;
while (t--)
{
flag = 0;
Min = 200005;
scanf("%s", s, 200005);
int p1 = 0;
int p2;
int len = (int)strlen(s);
int flag2 = 0;
for (int... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 9ca9a5c9765d586d7b0cb46684331b3b | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<conio.h>
#include<string.h>
int max(int a,int b,int c)
{
if(a>=b&&a>=c)
{
return a;
}
else if(b>=a&&b>=c)
{
return b;
}
else
{
return c;
}
}
int min(int a,int b,int c)
{
if(a<=b&&a<=c)
{
return a;
}
else if(b<... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | c33eacd1de8c1fa7c59f007aaf1eaf5a | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
char s[200005];
int i, j;
int n;
int ans;
int c[3];
for (; t > 0; t--)
{
scanf("%s", s);
n = 0;
while (s[n] != '\0')
n++;
c[0] = c[1] = c[2] = 0;
ans = 0;
i = j = 0;
while (j < n)
{
c[s[j] - '1']++;
j++;
if (c[0] > 0 && c[1] > 0... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 0b6e89fef0f79d2b353bbd5c50280c96 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int main()
{
long long int t;
scanf("%lld", &t);
do
{
char s[200000];
scanf("%s", &s);
long long int i, j;
long long int st = 1;
long long int fn = 1;
long long int min = INT_MAX;
long long int suma = 0;
for ( i = 1; i... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 566ec3da56618b445dc4e691504212e8 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
char s[200005];
int a[200005];
int main()
{
int i,j;
int t;
int n,m;
int min;
int a1,a2,a3;
scanf("%d",&t);
getchar();
while(t--)
{
gets(s);
n=strlen(s);
a[0]=0;
min=n;
m=0;
a1=0;a2=0;a3=0;
for(i=0;i<n-1;i++)
{
if(s[i+1... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 6cdd9fa001b1bad7ce759502353872fc | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
char s[200005];
int main()
{
int i,j;
int t;
int n,m;
int l,r;
int flag;
int a1,a2,a3;
scanf("%d",&t);
getchar();
while(t--)
{
gets(s);
n=strlen(s);
l=3;
r=n;
while(l<r)
{
flag=0;
m=(l+r)/2;
a1=0;a2=0;a3=0;
for(i... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | f94e2bb5b1e3d4db7e14f68a9d6a8319 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include <stdio.h>
#include <string.h>
#define ll long long int
int diffee(int a,int b,int c);
// bool comparev(const pair<int,int> &a,const pair<int,int> &b){
// if((a.S-a.F)!=(b.S-b.F)){
// return ((a.S-a.F)>(b.S-b.F));
// }
// else{
// ret... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 24f77e9a8939c5698e37631d7c05db7e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<string.h>
#include<limits.h>
char a[300000];
int main()
{
int t,ans,i,length,start,end;
scanf("%d",&t);
while(t--)
{
ans=INT_MAX;
scanf("%s",a);
length=0,start=0;
for(i=0;i<strlen(a);i++)
{
if(a[i]!='1' && length!=0)
{
end=i,length=0;
if(a[start]!='1' && a[end]!=a[... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | e8a4656e1c38b71ba7a9b8388ce2e096 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include <stdio.h>
#include<math.h>
#include<string.h>
int main()
{
int t,a[4],u,l,i,j,index,min,len;char s[200005];
scanf("%d",&t);
while(t--)
{
scanf("%s",s);
l=strlen(s),a[1]=0,a[2]=0,a[3]=0;
for(i=0;i<l;i++)
{
u=s[i]-'0';
a[u]++;
}
... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 1518fbfba7a85ae677893e9337091f3a | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include <stdio.h>
char S[200002];
int main()
{
int t;
int T;
int oneF;
int twoF;
int threeF;
int max;
int min;
int R;
scanf("%d", &T);
while (T--)
{
scanf("%s", &S);
R = 200001;
oneF = -1000001;
twoF = -1000001;
threeF = -1000001;
for (t = 0; S[t]; t++)
{
switch(S[t])
{
case '1':
... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 44494769a5ab0a81788d57a9b2f6ffad | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | //Bismillahir Rahmanir Rahim
#include<stdio.h>
#include<string.h>
int main()
{
int n,i;
char s[200001];
scanf("%d",&n);
while(n--)
{
int x=0,y=0,z=0,min=500000,len,a,b,c,d=0,e=0,f=0;
scanf("%s",s);
len = strlen(s);
for(i=0;i<len; i++)
{
if(s[i]=='1... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 962697e26a1f11de1255dea723de4660 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<string.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
char s[200001];
scanf("%s",s);
int i=0,j=0,cnt[4]={0};
int n=strlen(s);
int ans=n+1;
for(j=0;s[j]!='\0';j++)
{
cnt[s[j]-'0']++;
while(cnt... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | bbbb09b6459abffa7e84428855787fae | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include <stdio.h>
#include <string.h>
int diff(int a,int b,int c)
{
int Max,Min;
if(a>b && a>c)
Max=a;
else if(b>a && b>c)
Max=b;
else if(c>a && c>b)
Max=c;
if(a<b && a<c)
Min=a;
else if(b<a && b<c)
Min=b;
else if(c<a && c<b)
Min=c;
return Max-Min+1;
}
void Ter(char *s)
{
int c1=-1,c2=-1,c3=-1;
... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 47c091236fd5de61ae29a2b7f644948d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<string.h>
int main()
{
int t,i,len,l,c=0,j,p[200000],x,y;
char str[200000],q;
scanf("%d",&t);
while(t--)
{
l=300000000;
c=0;
scanf("%s",&str);
len=strlen(str);
for(i=0,j=0;i<len;i++)
{
if(str[i]!=str[i+1])
... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 41f46e863b5a110914eb1d446d8b2c02 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<limits.h>
#include<string.h>
typedef long long int ll;
int diff(ll m1,ll m2,ll m3);
int main()
{
ll t;
scanf("%lld",&t);
while(t--){
ll ans=INT_MAX,i,m1=-1,m2=-1,m3=-1;
char s[200000];
scanf("%s",s);
for(i=0;i<=strlen(s);i++){
if(m1==-1 ... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 7ada2aaf9c845dc91d0b51f882318fcf | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<string.h>
int main()
{
int t,x,i,j,k,p,s,c,f;
scanf("%d",&t);
char n[200001];
while(t--)
{
int m[4]={0};
scanf("%s",&n);
x=strlen(n); c=0; f=0; s=1000000;
for(i=0;i<x;i++)
{
k=n[i]-48;
if(m[k]==0)
... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 8b252cd0c40090c0dcf0d3de2f4ecddc | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | char s[7<<15];m=3e5;main(i,j,r,l){
for(scanf("%*d");~scanf("%s",s);){int a[3]={0};for(i=r=m;s[i-m];){
a[s[i-m]%3]=i++;l=m*2;for(j=3;~--j;)l=a[j]<l?a[j]:l;r=i-l<r?i-l:r;}
printf("%d ",r%m);}} | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 836be67c24c08fd53ff9f3bb08972f2d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | char s[7<<15];m=3e5;main(i,j,r,l){
for(scanf("%*d");~scanf("%s",s);){int a[3]={0};for(i=r=m;s[i-m];){
a[s[i-m]-49]=i++;l=m*2;for(j=3;~--j;)l=a[j]<l?a[j]:l;r=i-l<r?i-l:r;}
printf("%d ",r%m);}} | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | f3430335db006544c92a33bc1549215e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | char s[7<<15];m=3e5;main(i,x,y,r){
for(scanf("%*d");~scanf("%s",s);){int a[3]={0};for(i=r=m;x=s[i-m];){
a[x%3]=i++;y=a[(x+1)%3];x=a[(x+2)%3];x=i-(x<y?x:y);r=x<r?x:r;}
printf("%d ",r%m);}} | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | ff47f8024cffba2c79768516c7322d58 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | char s[7<<15];m=3e5;main(i,j,r,l){
for(scanf("%*d");~scanf("%s",s);){
int a[3]={0};for(i=r=m;s[i-m];)
{a[s[i-m]-49]=i++;for(l=m*2,j=3;~--j;)l=a[j]<l?a[j]:l;r=(i-l<r?i-l:r);}
printf("%d ",r%m);}} | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 85a1b43951655f946c459870a93ee2c2 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | char s[7<<15];a[3];main(i,j,r,l,m){
for(scanf("%*d");~scanf("%s",s);memset(a,0,12)){
for(i=r=m=7<<15;s[i-m];)
{a[s[i-m]-49]=i++;for(l=m*2,j=3;~--j;)l=a[j]<l?a[j]:l;r=(i-l<r?i-l:r);}
printf("%d ",r%m);}} | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 94940fd608d606456ea2e90cad1c1a7e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | char s[7<<15];m=7<<15;main(i,j,r,l){
for(scanf("%*d");~scanf("%s",s);){
int a[3]={0};for(i=r=m;s[i-m];)
{a[s[i-m]-49]=i++;for(l=m*2,j=3;~--j;)l=a[j]<l?a[j]:l;r=(i-l<r?i-l:r);}
printf("%d ",r%m);}} | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 1ea819970ac5701997fcc84f768cc74d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | char s[7<<15];m=3e5;main(i,j,r,l){
for(scanf("%*d");~scanf("%s",s);){int a[3]={0};for(i=r=m;s[i-m];){
a[s[i-m]%3]=i++;l=m*2;for(j=3;~--j;)l=a[j]<l?a[j]:l;r=i-l<r?i-l:r;}
printf("%d ",r%m);}} | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | feab42d306155ce6d22e01a66e1583d1 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
int main()
{
int t, i, x, a, b;
char s[200001];
scanf("%d", &t);
while(t--)
{
scanf("%s", s);
int f=0, c=0, y=0;
for(i=0; s[i]!='\0'; i++)
{
if(i==0)
{
a=s[i];
}
else if(i==1)
{
b=s[i];
}
else
{
x=s[i];
if(a==b)
{
if(x!=a){
b=x... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 4c5b27b1e0c749f3fbf1b2cded843a9b | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define sum(x) (x[0]>0) +(x[1]>0) +(x[2]>0)
void solve()
{
char s[200000];
int hash[3]={0,0,0},n,left=0,right=0,min=200004;
scanf("%s",s);
n=strlen(s);
while(1){
if(sum(hash)<3){
hash[s[right]-'1']++;
... | |
You are given a string $$$s$$$ such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of $$$s$$$ such that it contains each of these three characters at least once.A contiguous substring of string $$$s$$$ is a string that can be obtained from $$$s$$$ by removing some (po... | For each test case, print one integer β the length of the shortest contiguous substring of $$$s$$$ containing all three types of characters at least once. If there is no such substring, print $$$0$$$ instead. | C | 6cb06a02077750327602a1a7eeac770f | 02a84dce1c5144e57d7eefffeb8ccd8a | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"implementation",
"binary search"
] | 1589707200 | ["7\n123\n12222133333332\n112233\n332211\n12121212\n333333\n31121"] | NoteConsider the example test:In the first test case, the substring 123 can be used.In the second test case, the substring 213 can be used.In the third test case, the substring 1223 can be used.In the fourth test case, the substring 3221 can be used.In the fifth test case, there is no character 3 in $$$s$$$.In the sixt... | PASSED | 1,200 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 20000$$$) β the number of test cases. Each test case consists of one line containing the string $$$s$$$ ($$$1 \le |s| \le 200000$$$). It is guaranteed that each character of $$$s$$$ is either 1, 2, or 3. The sum of lengths of all strings in all test cases does... | ["3\n3\n4\n4\n0\n0\n4"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int min(int a,int b)
{
return a>b?b:a;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
char s[200002];
scanf("%s",s);
int l=strlen(s);
int ans=2147483647,cnt[3]={0,0,0};
for(int i=0,j=0;i<l;i++)
{
while((!cnt[0]||!cnt[1]||!cnt[2... | |
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$... | Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ β permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s... | C | 819d3694fccf2b5af0ec3b4ee429dbb3 | 5e23fcf6621ff9b82bdd7c104b0521a7 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1545921300 | ["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"] | null | PASSED | 1,600 | standard input | 3 seconds | The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) β the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) β the kids t... | ["3 2 4 1 5", "3 1 2"] | #include <stdio.h>
#include <stdlib.h>
int n;
int m[200001][2];
int nextSol(int i){
int a, b;
a = m[i][0];
b = m[i][1];
if(m[a][0] == b || m[a][1] == b){
return a;
}
return b;
}
int main(int argc, char *argv[]){
int i, j, sol;
scanf("%d", &n);
for(i = 1; i<=n; i++){
scanf("%d %d", &m[i][0], ... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 659808f55cb98e9f3506186528ea6d5e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include <stdio.h>
#include <stdlib.h>
int main(void)
{
long long int n,*a,max=0,min,mxpos=0,mnpos=0,t,i;
scanf("%lld",&n);
a=(long long int *)malloc(sizeof(long long int) * n);
for(i=0; i<n; i++)
{
scanf("%lld",&a[i]);
if(i==0)
{
min=a[i];
}
if(m... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 98c081fc76eb0e0768e14eb31f78df46 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include <stdio.h>
int main()
{
long long a[200001]={0},min=1000000000,max=1,n,i,x,mincount=0,maxcount=0;
scanf("%I64d",&n);
for (i=0;i<n;i++){
scanf("%I64d",&x);
if (x<min){
mincount=0;
min=x;
}
if (x==min)
mincount++;
if (x>max){
maxcount=0;
max=x;
}
i... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | ff72ef507cf02509ef135d6160f90504 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main()
{
long long int n,i,minCount=0,maxCount=0,min=INT_MAX,max=INT_MIN,num;
scanf("%lld",&n);
int flag = 1;
for(i=0;i<n;i++)
{
scanf("%lld",&num);
if(flag)
{
min=num;
max = num;
m... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 8084dc2550d45c9957d41bf984dfd7de | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
int arr[200005];
int compare(int *a,int *b){
return *a-*b;
}
int main(){
int a,b,c;
scanf("%d",&a);
int i;
int min=INT_MAX;
int max=0;
for(i=0;i<a;i++){
scanf("%d",arr+i);
if(arr[i]>max)
... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | a31e081d607fa80f1002f0373b5e31b8 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
int arr[200005];
int compare(int *a,int *b){
return *a-*b;
}
long long int bound(int arr[],int size,int target,int check){
int f,m,l;
f=0;
l=size;
if(!check){
while(f<l){
m=(f+l)/2;
if(arr[m]<=target){
... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | a3b554be22bacc65088fadd042d512d0 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
int main()
{
long long int n,i,j,max=0,count=0,l,m,min=20000000000,count2=0;
scanf("%I64d",&n);
long long int a[n];
for(i=0;i<n;i++)
{
scanf("%I64d",&a[i]);
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
/* for(i=0;i<n;i++)
... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 54f146497bfc15c9ddba6930ff1a46f7 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
//#include<string.h>
#include<math.h>
main()
{
//freopen("out.txt", "r", stdin);
int m, c = 1, i, max = 0, min = 99999999999;
long long cmax = 0, cmin = 0, n;
scanf("%I64d", &n);
int a[n];
for(i = 0; i<n; i++)
{
scanf("%d", &a[i]);
if(a[i]>=max)
... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 01a76473a49939c2ab5f28cc8f4957ca | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
int main()
{
long long int n,b,i,j,mn=10000000000,mx=0,cnt_min,cnt_max,dif,way;
scanf("%I64d",&n);
for(i=0;i<n;i++)
{
scanf("%I64d",&b);
if(b>mx)
{
mx=b;
cnt_max=1;
}
else if(b==mx) cnt_max++;
if(b<mn)
{
... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 485074671c70b5f9b21bed17fb098202 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include <stdio.h>
#include <stdlib.h>
int main(){
long long int n;
long long int bn = 1LL;
long long int sn = 1LL;
scanf("%I64d", &n);
long long *b;
long long bbuff;
long long sbuff;
b = (long long int*)malloc(sizeof(long long int)*n*1.5);
int i;
for (i = 0; i < n; i++)... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 83fd6a1ac134060f4eaab35e9c6f3b9e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include <stdio.h>
#include <stdlib.h>
int all_same(int *list, int N){
int i, first;
first = list[0];
for(i=1; i<N; i++){
if(list[i] != first)
return 0;
}
return 1;
}
long long NCR(int N, int r){
int i;
long long temp = 1;
for(i=N; i>N-r; i--){
temp = temp *... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 8ac6a4554482a52ab2113f0a9dd926f3 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
int main()
{
int max,min,x,y;
int n,i;
int a,b;
while(scanf("%d",&n)==1)
{
scanf("%d",&a);
min=max=a;
x=y=1;
for(i=1;i<n;i++)
{
scanf("%d",&a);
if(a>max)
{
max=a;
x=0;
}
if(a<min)
{
min=a;
y=0;
}
if(max==a)
x++;
if(min==a)
y++;
}
if(max==min)
printf("%d %I64d\n",max-min,(long long)(x-1)*(x)/2);
else
... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 75083e94604daecb0b03eb44bd5ecfbc | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
int main()
{
long long a[200001],min, max,b,c,n,i;
scanf("%I64d",&n);
scanf("%I64d",&a[0]);
min=a[0];
max=a[0];
for(i=1;i<n;++i)
{
scanf("%I64d",&a[i]);
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("%I64d ",... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 6ca3e834e0d6cf3cc223438283188551 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
#include<stdlib.h>
int comparefunc(const void *a,const void *b)
{
return (*(int*)a-*(int*)b);
}
int main()
{
long long n,i,j,max,min,count1=0,count2=0;
scanf("%lld",&n);
int num[n];
for(i=0;i<n;i++)scanf("%lld",&num[i]);
qsort(num,n,sizeof(int),comparefunc);
min=num[0]... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | b88747963fe25bdbdb4b5c0fd65ae9c3 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
int main(void)
{
long long int n,i,max=-1,min=2000000000,a[200005];
long long int countmax=0,countmin=0,dif,mul;
scanf("%I64d",&n);
for(i=0;i<n;i++) {
scanf("%I64d",&a[i]);
if(max<a[i])
max=a[i];
if(min>a[i])
min=a[i];
}
if(n==2 && a[0]==1 && a[1]==1) {
printf("0 1");
return 0... | |
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference i... | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | C | eb2d1072c5308d9ef686315a122d9d3c | 22057e35859e79d368cdfc43a2c11c0d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"combinatorics",
"implementation",
"sortings"
] | 1408116600 | ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"] | NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. | PASSED | 1,300 | standard input | 1 second | The first line of the input contains n (2ββ€βnββ€β2Β·105). In the next line there are n space-separated integers b1, b2, ..., bn (1ββ€βbiββ€β109). | ["1 1", "4 1", "2 4"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmpfunc(const void *a_a, const void *b_b)
{
return (*(int*)a_a - *(int*)b_b); //For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))
unsigned long long factorial(int n)
{
int c;
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | b08659a29b4dcdf6a28a73cc21ba75be | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include"stdio.h"
int cnt=0,i;
char arr[100005];
void sum(){
int t=0;
for(i=0;arr[i];i++)
t+=arr[i]-48;
sprintf(arr,"%d",t);
}
int main(){
scanf("%s",arr);
while(1){
if(arr[1]==0)break;
sum(); cnt++;
}
printf("%d",cnt);
return 0;
}
| |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 3c0128592bb2db24db022259b1c29a4a | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
int sm;
int f(int n)
{
sm=0;int s;
while(n>0)
{
s=n%10;
// printf("%d---",s);
sm=sm+s;
n=n/10;
//printf("%d\n",n);
}
return sm;
// printf("%d",sm);
}
int main()
{
int... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | acf03f34ef3322a6217253ff9a4ffa14 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | //Bismillahir rahmanir rahim
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void) {
// your code goes here
char num[100001];
gets(num);
int i,c=0, y,sum=0;
y = strlen(num);
if(y<2){
goto asd;
}
qer:
for(i=0;num[i];++i)
sum += num[i]-'0';
//print... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | d49b5ed278250131289687e75285c894 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
int main()
{
char arr[100002];
int sum=0,c=0,i,j,k,l;
scanf("%s",arr);
l=strlen(arr);
if(l!=1)
{
for(i=0;i<l;i++)
sum=sum+arr[i]-48;
c++;
}
while(sum>=10)
{
k=0;
while(sum!=0)
{
j=sum%10;
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 65b1b5daaa85265c67f83154236ac5dd | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | # include <stdio.h>
main()
{
long long int t,ans=1,a[100001],j,n=0,i=0;
char c;
while((c=getchar())!='\n')
a[i++]=c-'0';
i--;
if(i==0){printf("0");return 0;}
for(j=0;j<=i;j++)n+=a[j];
while((n/10)!=0)
{
t=0;ans++;
while(n!=0)
{
t+=(n%10);
n/=10;
}
n=t;
}
printf("%I64d",ans);
return ... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 9dce1ae52e5097b84ee4d46e4efe6094 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int n,i,j,sum=0,count=0;char no[100002];
scanf("%s",&no);
while(no[1])
{
count++;
int sum=0;
for(j=0;no[j];j++)sum+=no[j]-'0';
sprintf(no,"%d",sum);
}
printf("%d",count);
return 0;
} | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 5ad8dacc821cb4af5ad672938dfd09f4 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
#define LENGTH 100001
int main(void){
int count[10];
char num[LENGTH];
int i,j,k,l,times=0,sum;
scanf("%s",num);
for(i=0;i<10;i++) count[i]=0;
l=strlen(num);
if(l==1){
puts("0");
return 0;
}
for(i=0;i<l;i++) count[num[i]-'0']++;
times=1;
while(1){
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 6e0c934e2dac38dcf7fa620327363a49 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
char a[100009];
int main()
{
int n,m=0,i,j,len,count=1,m1;
gets(a);
len=strlen(a);
if(len==1)
{
printf("0");
return 0;
}
for(i=0;i<len;i++)
m+=(a[i]-48);
m1=m;
//printf("%d ",m);
while(1)
{
if(m1/10... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | cff103aaabc1d76c263ea275bbbc7d44 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] |
int main()
{
char digits[100001];
scanf("%s", digits);
int nbr=0;
if (digits[1] != 0)
{
int digitsum=0;
char* p = digits;
while (*p != 0)
{
digitsum += (*p - '0');
++p;
}
++nbr;
while (digitsum > 9)
{
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 2d721c400c1de405591ff9e7faa5b368 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
char ch[100002];
scanf("%s",ch);
int n=0,i,j=0;
for(i=0;ch[i];i++)
{
n+=ch[i]-'0';
}
int m=0;
if(!n||i==1)
{
printf("%d",0);
return 0;
}
j++;
l1:
if(n>9)... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | fbe021122b97e414ab26bd1c3a38ba7a | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
#define MAX 100000
int strsum(char *s)
{
int ans=0;
while(*s){
ans+=*s-'0';
s++;
}
return ans;
}
int main()
{
int ans,in,out;
char inchar[MAX+1];
scanf("%s",inchar);
if(inchar[1]=='\0')
printf("0\n");
else{
ans=1;
in=strsum(in... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 2c773c74ca5c9cc8ced8924f65957407 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
#include <string.h>
int main()
{
char s[100005];
int n = 1, sum = 0, i;
scanf("%s", s);
if (strlen(s) == 1) {
puts("0");
return 0;
}
for (i = 0; i < strlen(s); i++) sum += s[i] - '0';
while (sum / 10 > 0) {
int p = 0;
while (sum) {
p += su... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 4a068fceb9b6d005cffb05106e98105b | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
int conv(char *inp) {
int n = 0;
while (*inp) {
n += *inp - '0';
inp++;
}
return n;
}
int nsum(int n) {
int sum = 0;
while (n) {
sum += (n % 10);
n /= 10;
}
return sum;
}
int main(void) {
int n = 0, cnt = 0;
char inp... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 0fd197343d8bc2a65e582b29435b8aa0 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
#include <string.h>
char s[100009];
int main()
{
scanf("%s", s);
int n = 0, res = 0, i;
if (strlen(s) < 2) {
printf("0\n");
return 0;
}
while (1) {
res++;
int n = 0;
for (i = 0; i < strlen(s); i++) {
n += s[i] - '0';
}
if (n <= 9) break;
sprintf(s, "%d"... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | c555ca34cf5faa475690b2e6bbabc1e7 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
int n,i,j=0,a,sum=0;
char str[100000];
scanf("%s",str);
//while(sum>=10){
if(strlen(str)==1)
printf("0");
else{
for(j=1;j<=1000000000;j++){
sum=0;
for(i=0;i<=strlen(str)-1;i++){
a=str[i]-'0';
sum=sum+a;
}
if(sum<10)
break;
s... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 707aa62af031a0e46b5971619344d344 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
main()
{
int i=0,j,k,total=0,c;
char a[100005];
scanf("%s",a);
for(i=0;i<strlen(a);i++)
{
total+=(a[i]-'0');
}
if(strlen(a)==1){j=-1;goto x;}
for(j=0;total/10!=0;j++)
{
c=0;
for(k=0;total!... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | afdf8193d269961c055e57efcdb14796 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
int a[1000005];
int main(void)
{
int n,i,j,sum=0;
char ch[1000005];
for(i=0; ;i++) {
scanf("%c",&ch[i]);
a[i]=ch[i]-'0';
if(ch[i]=='\n') {
break;
}
}
n=i;
if(n==1) {
printf("0");
return 0;
}
for(i=1; ;i++) {
for(j=0;j<n;j++) {
sum+=a[j];
}
if(sum>9) {
for(j=0;j<n... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | c7b7e8a93a1dc9b7300d1f45b437ce50 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
int main () {
char n[100000];
int i=0,sum=0,count=0,j,k,l;
scanf("%s",n);
while(n[i]!=0) {
sum+=n[i]-48;
i++;
}
if(sum>9)
count++;
k=sum;
while(k>9) {
l=0;
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 7f86ca7d3fb22b0b61f43f8fb2bec435 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
int main()
{
char s[100100];
int cnt,n,i,t,l;
scanf("%s",s);
l=strlen(s);
if(l==1) {printf("0");return 0;}
n=0;
for(i=0;i<l;i++)
n+=s[i]-'0';
cnt=1;
while(n/10!=0)
{
t=0;
while(n!=0)
{
t+=n%10;
n=n/10;
}
n=t;
cnt++;
}
printf("%d\n",cnt);
return 0;
} | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | ff666d159106d05012d88e5e760fd952 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
int main (){
char a;
int count = 0;
int count2 = 0;
int res = 0;
int res2 = 0;
int res3 = 0;
while (a != '\n'){
scanf ("%c", &a);
res = res + (int)(a-'0');
count2++;
}
res = res + 38;
if (count2 >= 3)
count++;
while (res/10 != 0){
res2 = res;
while (res2 != 0){
res3 = res3 ... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | a35f55f70e304ee5074fa090be32d700 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
#include <string.h>
char s[100005 ] , a, b ;
int n , i , j , k , sum , q , t[100001] ;
int digit_count( int p )
{
if ( p == 0 ) return 0 ;
return 1 + digit_count( p / 10 ) ;
}
int digit_sum( int m )
{
if ( m == 0) return 0 ;
return m%10 + digit_sum(m / 10 ) ;
}
int main()
{... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 0d165764c7af38eec09a0fa17124692f | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
#include <string.h>
char s[1000001];
void func()
{
int n = 0, m, ans, len = strlen(s), i;
if (len == 1)
{
printf("0\n");
return;
}
for (i = 0; i < len; i++)
{
n += (s[i] - '0');
}
ans = 1;
while (n / 10 != 0)
{
m = 0;
w... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 338beaf4fd6d7084bfeecff2d6b1c3bc | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
#include <stdlib.h>
unsigned int sum_digits(char *array, int length)
{
int i, sum = 0;
for(i = 0; i < length; i++)
{
sum += array[i];
}
return sum;
}
char *mkarray(unsigned int n, int *length)
{
unsigned int temp = n;
int len = 0;
while(temp > 0)
{
temp /= 10;
len ++;
}
char *array =... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | dbc6114c5a4baa6cfce82e23c81e2049 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] |
int main()
{
char s[100001];
int n,t,i,r;
scanf("%s",s);
t=0;
while (s[1])
{
t++;
r=0;
for(i=0;s[i];i++)
{
r+=s[i]-'0';
}
sprintf(s,"%d",r);
}
printf("%d\n",t);
return 0;
}
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 58a39842704bc9b39991acba752f891f | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
char s[100100];
int main()
{
int n,cnt,i,res;
scanf("%s",s);
cnt=0;
while (s[1])
{
cnt++;
res=0;
for(i=0;s[i];i++)
res+=s[i]-'0';
sprintf(s,"%d",res);
}
printf("%d\n",cnt);
return 0;
}
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | d4d2dbd0b4a479ac355e0694fd41121e | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include <stdio.h>
int main()
{
char s[111111];
int m,i,res;
scanf("%s",s);
m=0;
while (s[1])
{
m++;
res=0;
for(i=0;s[i];i++)
res+=s[i]-'0';
sprintf(s,"%d",res);
}
printf("%d",m);
return 0;
}
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 730d5832af1e4b9f4e4c4aa14a8817d3 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
char s[1000000];
int g(int a)
{
int z=0;
while(1)
{
z+=a%10;
a=a/10;
if(a==0)
return z;
}
}
int main()
{
scanf("%s",&s);
int len=strlen(s);
int x=0;
if(len==1)
{
printf("0\n");
return 0;
}
for(int i=0;i<len;i++)
{
x=x+s[i]-'0';
}
int ans=1;
while(x>... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | e6d78a1e0deb60b0c40c9469a2220266 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
int main()
{
char a[100002];
int sum=0,i,l,n=1,m,b=0;
scanf("%s",a);
l=strlen(a);
for(i=0;i<l;i++)
{
if(a[i]=='0')
sum+=0;
else if(a[i]=='1')
sum+=1;
else if(a[i]=='2')
sum+=2;
else if(a[i]=='3')
sum+=3;
else if(a[i]=='4')
sum+=4;
else if(a[i]=='5... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 2822f6d13ed1b5cd19f270993ae01f59 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
int main(void)
{
char c;
int n=0,b=0,x;
while(1)
{
scanf("%c",&c);
if(c=='\n')
break;
else
{
n+=c-48;
b++;
}
}
if(b==1)
x=0;
else
x=1;
int s=0;
if(n>9)
{
while(n)
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | d6759048ea9670cf2e522b3a7ea91708 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
char s[100100];
int main()
{
int n,cnt,i,res;
scanf("%s",s);
cnt=0;
while (s[1])
{
cnt++;
res=0;
for(i=0;s[i];i++)
{
res+=s[i]-'0';
}
sprintf(s,"%d",res);
}
printf("%d\n",cnt);
return 0;
}
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 93b0bfa6bc442328a9d9b6b8319ac3b0 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
int main()
{
char str[100002];
int n,l=0,count=0,sum=0,i;
scanf("%s",str);
n=strlen(str);
while(n!=1)
{
for(i=0;str[i]!='\0';i++)
{
sum=sum+str[i]-'0';
}
l=0;
while(sum)
{
if(sum%10==0)
... | |
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-di... | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | C | ddc9201725e30297a5fc83f4eed75fc9 | 54f4bd61b2da9569616e74db6a69b567 | GNU C | standard output | 265 megabytes | train_000.jsonl | [
"implementation"
] | 1312390800 | ["0", "10", "991"] | NoteIn the first sample the number already is one-digit β Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transform... | PASSED | 1,000 | standard input | 2 seconds | The first line contains the only integer n (0ββ€βnββ€β10100000). It is guaranteed that n doesn't contain any leading zeroes. | ["0", "1", "3"] | #include<stdio.h>
#include<string.h>
int main()
{
int i, j, k, sum=100;
char ar[100001];
scanf("%s", &ar);
int ans=0;
int len = strlen(ar);
if(len<2)
printf("0");
else
{
ans=0;k=0;
for(i=0;i<len;i++)
k = k+ar[i]-'0';
ans++;
//printf("k=%d\n", k);
if(k<10)
printf("1");
else
{
sum=k;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.