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
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
08d47f7f9e4ad9873d3846c13527ce43
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,a; scanf("%s",s); a=strlen(s); if(a==1) {printf("0");return 0;} n=0; for(i=0;i<a;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
5be5093f21381b347631e4d8ea7158a1
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(void) { int n,cnt,sum,len,i; char s[100001]; scanf("%s" ,s); n=0; len=strlen(s); if(len<=1) printf("0\n"); else{ for(i=0;i<len;i++) n+=s[i]-'0'; cnt=1; while(n>=10){ sum=0; while(n>=10){ sum+=n%10; n/=10; } sum+=n%10; n=sum; cnt++; ...
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
55aa0f35795513133b6238b5ed1d82ae
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() { char ara[100005]; long long s, p = 0, i; scanf("%s", ara); if(strlen(ara) > 1) p = 1; while(1) { s = 0; for(i = 0; i < strlen(ara); i++) { s = s + ara[i] - '0'; } if(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
194e2e75518b79c535980f46b1a510a1
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 <math.h> #include <string.h> int sumDigits(int n) { int sum = 0; while(n > 0) { sum += n%10; n -= n%10; n /=10; } return sum; } main() { char buffer[100000]; int i; int n = 0; int count = 0; gets(buffer); int len = strlen(buffer); //special case: ...
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
654d1e17fe7d90bd47a2bd1815a899c1
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<string.h> #define MAX_LEN 100010 int main (int argc, char *argv[]){ char n[MAX_LEN]; scanf("%s", n); int i=0, times=0, sum; int len = strlen(n); while (len > 1){ sum=0, i=0; while (i<len){ sum += (n[i] - '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
e7eabb6c554f15dbf2e43991f8bfdc02
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() { char n[100000]; long long s, p = 0, i; scanf("%s", &n); if(strlen(n) > 1) p = 1; start: s = 0; for(i = 0; i < strlen(n); i++) s = s + n[i] - '0'; if(s > 9) { itoa(s , n , 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
26b83b6b7f7aee18ad2a2032ef10f1e9
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 c='e'; long sum=0; int so; int count = 0; while (c!='\n') { count++; so = 0; scanf("%c",&c); if (c=='\n') break; so = c - 48; sum = sum + so; } ...
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
f427b6e078bff014f09c3b707f49ff30
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> char Str[100001]; int main() { int i,Sum,Cnt; scanf("%s",Str); if(Str[1]=='\0') { puts("0"); return 0; } for(Cnt=1,Sum=i=0; Str[i]!='\0'; ++i) { Sum+=Str[i]-'0'; } while(Sum>9) { itoa(Sum,Str,10); fo...
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
e8873e2b4a18583b0bdf2cb548071a54
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() { int i=0,j,k,l,m,n,sum=0,p; char a[100000]; scanf("%s",a); for(i=0;a[i]!='\0';i++) { sum=sum+a[i]-'0'; } if(i==1) { sum=a[0]-'0'; p=0; } else p=1; while(sum>9) { i=sum; sum=0; while(i>0) { sum=sum...
Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the ...
Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers β€” point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line pri...
C
a36fb51b1ebb3552308e578477bdce8f
e7c9f0875ff8611e230bf5037ad8d25b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "geometry", "brute force" ]
1323443100
["0 0\n10 11\n10 0\n0 11\n1 1\n2 2\n2 1\n1 2", "0 0\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7", "0 0\n4 4\n4 0\n0 4\n1 2\n2 3\n3 2\n2 1"]
NotePay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
PASSED
1,600
standard input
2 seconds
You are given 8 pairs of integers, a pair per line β€” the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide.
["YES\n5 6 7 8\n1 2 3 4", "NO", "YES\n1 2 3 4\n5 6 7 8"]
#include<stdio.h> #include<string.h> #include<stdlib.h> #define MAX 8 #define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)) #define line(i,j,k,l) ((a[i].x-a[j].x)*(a[k].y-a[l].y)) #define expand(p,i,j,k) line(p[k],p[i],p[j],p[i]) #define check(p,i,j,k) (expand(p,i,j,k)==expand(p,i,k,j)) struct{ int x,y; }a...
Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the ...
Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers β€” point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line pri...
C
a36fb51b1ebb3552308e578477bdce8f
be4a800a14ac7662de2799bd2d6b3b55
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "geometry", "brute force" ]
1323443100
["0 0\n10 11\n10 0\n0 11\n1 1\n2 2\n2 1\n1 2", "0 0\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7", "0 0\n4 4\n4 0\n0 4\n1 2\n2 3\n3 2\n2 1"]
NotePay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
PASSED
1,600
standard input
2 seconds
You are given 8 pairs of integers, a pair per line β€” the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide.
["YES\n5 6 7 8\n1 2 3 4", "NO", "YES\n1 2 3 4\n5 6 7 8"]
#include <stdio.h> int ok = 0, sol[8]; typedef struct po { int x, y; } point; point tab[8]; int prp(b,a,c) { int xa = tab[a].x, ya = tab[a].y; int xb = tab[b].x, yb = tab[b].y; int xc = tab[c].x, yc = tab[c].y; double a1, a2; if (xa != xb && xa != xc) { a1 = ((double) ya-yb)/((double) xa-...
Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the ...
Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers β€” point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line pri...
C
a36fb51b1ebb3552308e578477bdce8f
f447ae84b1a90bb1805b476e3d2f14f5
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "geometry", "brute force" ]
1323443100
["0 0\n10 11\n10 0\n0 11\n1 1\n2 2\n2 1\n1 2", "0 0\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7", "0 0\n4 4\n4 0\n0 4\n1 2\n2 3\n3 2\n2 1"]
NotePay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
PASSED
1,600
standard input
2 seconds
You are given 8 pairs of integers, a pair per line β€” the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide.
["YES\n5 6 7 8\n1 2 3 4", "NO", "YES\n1 2 3 4\n5 6 7 8"]
#include <stdio.h> #include <stdlib.h> int x[8], y[8]; int length (int p, int q) { return (x[p] - x[q]) * (x[p] - x[q]) + (y[p] - y[q]) * (y[p] - y[q]); } int diamond (int a, int b, int c, int d) { if (length (a, b) == length (a, c) || length (a, b) == length (a, d) || length (a, d) == length (a, c) ) return 1; re...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
0e3907164d88ba852125e81c9dab0250
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> #include<string.h> int main() { int i=0,c=0,s=0; char a[102]; while(gets(a)!=NULL) { if(a[0]=='+')c++; else if(a[0]=='-') c--; else {i=0; while(a[i]!=':'){i++;} s+=(strlen(a)-i-1)*c; } } printf("%d",s); return 0; }
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
d18cc6010b341f8114b2c8023d61f6ea
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> #include<stdlib.h> int main() { char name[1000],count=0; int i,j,result=0; while(gets(name)!='\0') { if(name[0]=='+')count++; else if (name[0]=='-')count--; else { for(i=0;name[i]!=':';i++);i++; for(j=0;name[i]!='\0';j++,i++); ...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
61017265b65143c01b6ef7878badcda3
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> #include<string.h> int main() { int p=0,j,k=0,l=0,r=0,len=0; char X[100]; while(gets(X)!=NULL) { if(X[0]=='+') { p++; } else if(X[0]=='-') { p--; } else { len=0; for(j=0;X[j]!='\0';j++) { len++; } k=0; l=0; for(j=0;X[j]!=':';j++) { k++; } l=len-(k+1); r+=l*p; } } printf("%d\n",r); return 0; }
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
db3b84a8e5ebf015e1ada7f13b1e5e63
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i,l=0,p=0,sum=0,f=0; char s; while(scanf("%c",&s)!=EOF){ if(s=='\n'){ f=0; sum+=p*l; l=0; } else if(s==':'){ f=1; } else if(f==1){ l++; ...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
9afe5678b74fd1d825ac874e6dff7ec4
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> int len(char *s); int main() { int n = 0, i, j ,k, sum = 0; char str[1000]; while(gets(str)) { if(str[0] == '+') n++; else if(str[0] == '-') n--; else { k = len(str); sum += n * k; } } printf("%d\n",sum); return 0; } int len(char *s) {...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
c94ed1e6d00396afdf0eec6c9fb653c7
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> #include<stdlib.h> #include<string.h> long long result(long long n,long long m) { if(n<m) return 0; int i,t=1,ans=1; for(i=n;i>m;i--)/*Computation of the combination aCb*/ { ans*=i; ans/=t++; } return ans; } char* bitchange(char* ch) { int i,...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
e8fcc9ef58bcace31c86668f8f3982b3
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> #include <string.h> int main() { int count=0, sum=0, i=0, len=0; char a[10000]; while(gets(a)!='\0') { if(a[0]=='+') { count++; } else if(a[0]=='-') { count--; } else { i=0; ...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
5624ce9d15b3bc7bb92e0b9a6cbdd4ed
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> #include <string.h> char buffer[1024]; int main (void) { int ans = 0; int num = 0; int len; int l; while (gets(buffer) ) { if (buffer[0] == '+') ++num; else if (buffer[0] == '-') --num; else { len = strlen (buffer); for (l=0;l<len;l++) if (buffer[l] == ':') break; l =...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
a145d72c04cabd2e57a9dc3f1723ae62
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> #include<string.h> int main() { char c[101]; int n=0,sum=0; while(gets(c)!=NULL) { if(c[0]=='+')n++; else if(c[0]=='-')n--; else { sum = sum + ((c+strlen(c)) - strchr(c,':')-1)*n; } } printf("%d",sum); return 0; }
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
5dc4952078dcf6f0633037fe761e9dfc
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> #include<string.h> int main() { char cmd[101] ; int byte = 0; int online = 0; int i; while(gets(cmd)) { if(cmd[0]=='+') online++; else if(cmd[0]=='-') online--; else { for(i=0;i<110;i++) if(...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
0cafdc5e0dfa35aec3d519fcfa9e71c6
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> int main() { char s[102][102]; int i,j,d=0,c=0,s1=0; while(gets(s[i])!=NULL) { if(s[i][0]=='+') c++; if(s[i][0]=='-') c--; if(s[i][0]!='+'&&s[i][0]!='-') { d=0; for(j=0;j<strlen(s[i]);j++) { if(s[i][j]==':') { d=j+1; break; } ...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
29dbf15bc07e8502ec590d4ea03100c6
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> int main(void) { char ch = 0; int no_wait = 0; int people = 0; int symbols = 0; int total = 0; while(1) { ch = getchar(); if (ch != -1) { switch (ch) { case '+': { people++; ...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
ac60a47cc3c186070885009ee4f8c45b
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> int main(){ char msg[100]; char t=4; int i; int count,sum,users; sum=0; users=0; while (t!=EOF){ count=0; for (i=0;((t=getchar())!=10)&&(t!=EOF);i++){ msg[i]=t; msg[i+1]=EOF; } if (t==EOF) break; if (msg[0]=='+') { users++; //printf("users:%d\n",users); } else if (ms...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
a35bc24d6bcff0e74c3b9cb2aa9539e4
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char s[100]; int i,sum=0,res=0,j=0; while(gets(s)!=NULL){ if (s[0]=='+') sum++; else if (s[0]=='-') sum--; else{ j=0; while(s[j]!=':') ...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
2072028db86352b66d16980e3a526b6a
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main() { char ch; int sum=0; char ch2; int res=0; int ress=0; FILE *f; f=fopen("d","w"); while((ch=getchar())!=EOF) { putc(ch,f); } fclose(f); ...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
91ad5b398107accfa6e4339e343c7491
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> #include <string.h> #include <stdlib.h> int main() { char ent[150]; int res = 0, p = 0; while(scanf(" %[^\n]", ent) != EOF) { if(ent[0] == '+') p++; else if(ent[0] == '-') p--; else { int i; for(i = 0; i...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
a8534494da9a37263bf06cf4d7612465
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(){ char str[120]; int count=0,i,tr=0,len; while(gets(str)!='\0'){ if(str[0]=='+') count++; else if(str[0]=='-') count--; else{ len=strlen(str); for(i=0; ;i++){ if(str[i]!=':...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
dc6351480bea812e2560e335e7295ec4
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> int main(){ int i,j,k,l,n,m,our = 0,ans=0; char c,s[1000]; c = getchar(); while(c!=EOF){ j = 0; s[j] = c; while(c!='\n'){ j++; c = getchar(); s[j] = c; } if(s[0]=='+') our++; else if(s[0]=='-') our--; else{ l = 0; while(s[l]!=':') l++; ans = ans + (our*(j-l...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
03f61c481124cd025d6f41864ce1e865
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> int main() { int n = 0, l = 0, i; char s[105]; while (fgets(s, 105, stdin) != NULL) { if (s[0] == '+') { n++; } else if (s[0] == '-') { n--; } else { for (i = 0; i < strlen(s); i++) { if (s[i] == ':') break; } ...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
fd1f2ce53dacab2ba7b7f71dec9da0cb
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> #include<string.h> int main() { int inchat=0,length,data=0,i; char command[110]; while(gets(command)) { if(command[0] == '+') inchat++; else if(command[0] == '-') inchat--; else { length = strlen(command); for...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
86c162ca62a6a17316e6f01b3dae64b5
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
//SORU xx //PROGRAM C #include<stdio.h> #include<string.h> #include<stdlib.h> #include<limits.h> #include<time.h> #include<ctype.h> #define scn(x) fscanf(in,"%d",&x); #define prn(x) fprintf(out,"%d\n",x); #define prn2(x) fprintf(out,"%d",x); #define line() fprintf(out,"\n"); #define wait system("PAUSE"); #define scn2(x...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
104c8b968d79cd69c76d44b2a30c449e
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include<stdio.h> #include<stdlib.h> int main() { int people=0,ans=0,i; char a; int d=0; while(1) { a=getchar(); if(a==-1) { break; } if(a=='+') people++; if(a=='-') people--; if(a==':') { d=1; } else if(a=='\n') d=0; else if(d==1) ans=ans+people; } printf("%d",ans); return 0...
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands: Include a person to...
Print a single number β€” answer to the problem.
C
d7fe15a027750c004e4f50175e1e20d2
31f280bcbcba01e84557d54977699d80
GNU C
standard output
64 megabytes
train_000.jsonl
[ "implementation" ]
1269100800
["+Mike\nMike:hello\n+Kate\n+Dmitry\n-Dmitry\nKate:hi\n-Kate", "+Mike\n-Mike\n+Mike\nMike:Hi I am here\n-Mike\n+Kate\n-Kate"]
null
PASSED
1,000
standard input
1 second
Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following: +&lt;name&gt; for 'Add' command. -&lt;name&gt; for 'Remove' command. &lt;sender_name&gt;:&lt;message_text&gt; for 'Send' command. &lt;name&gt; and &lt;sender_...
["9", "14"]
#include <stdio.h> #include <string.h> #define MAX_SIZE 126 int main() { int users = 0, bytes = 0, colon_position, commands_length; char commands[MAX_SIZE]; while(fgets(commands, MAX_SIZE, stdin)) { commands_length = strlen(commands); if(commands[0] == '+') { ...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
d29f811b08418022f83f979db214c39e
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> #include<stdlib.h> int main() { int n,m,i,j,k,win,vot,fin,count=0; scanf("%d%d",&n,&m); int *a=malloc(110*sizeof(int)); for(i=0;i<n;i++)a[i]=0; for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&k); if(j==0) { vot=k;win=0; } if(k>vot) { win=j; vot=k; } } a...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
ca63105b323516ef7e1a4a71ea715ced
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> int main() { int a[111][111],b[111],m,n,j,i,max=0,x=0; scanf("%d%d",&m,&n); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%d",&a[i][j]); } } for(i=1;i<=n;i++) { int max=-1; for(j=1;j<=m;j++) { if(a[i][...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
0ed60a78700b5b97e785be527d8f658c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> #include<math.h> #include<string.h> int a[510][510]={0}; int main() { int i,j,k,n,m,t,big; int b[510]={0}; int c[510]={0}; scanf("%d%d",&n,&m); for(i=1;i<=m;i++) for(j=1;j<=n;j++) scanf("%d",&a[i][j]); for(i=1;i<=m;i++) { big=-1; for(j=1;...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
92c7940326623c0b5321bb4067cec0dc
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include <stdio.h> int main() { int n,m,i,j,d[105]={0},max=-1,k; scanf("%d %d",&n,&m); long long int a[105][105]; for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); if(max<a[i][j]) { max=a[i][j]; k=j; } } d[k]++; max=-1; } f...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
87d8aba1ab7a83caaf2fe9154533c7dd
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include <stdio.h> int main(){ int n,m,i,j,c[105][105],w[105]={0},max=-1,h; scanf("%d %d",&n,&m); for(i=0;i<m;i++){ for(j=0;j<n;j++){ scanf("%d",&c[i][j]); if(max<c[i][j]){ max=c[i][j]; h=j; } } w[h]++; max=-1; } for(i=0;i<n;i++) if(max<w[i]){ max=w[i]; h=i+1; } printf("%d",h); ...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
9d1d98550ec61b1d54e4fad222ac00c9
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> int main() { int n, m, i, j, ans; long long a[100][100], x, temp; int b[101]; scanf("%d %d", &n, &m); for (i=0 ; i<m ; i++) { for (j=0 ; j<n ; j++) { scanf("%I64d", &x); a[i][j] = x; } } for (i=0 ; i<100 ; i++) { ...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
d187a23b1a0bf9dd14d8a9bed0aa66dc
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> #include<string.h> #include<math.h> int main() { int n,m; scanf("%d %d",&n,&m); long long int a[m][n],b[200]={0},i,j,max=0,pos,pos1,f=0; for(i=0;i<m;i++) { max=-1,pos=-1; for(j=0;j<n;j++) { scanf("%lld",&a[i][j...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
d2c1aa21d4176430f62a043756cc398d
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> #include<string.h> #include<math.h> long long int b[100000]={0}; int main() { int t; //scanf("%d",&t); //while(t--) { int n,m; scanf("%d %d",&n,&m); long long int a[m][n],i,j,max=0,pos,pos1,f=0; for(i=0;i<m;i++) { max=0,pos=0,pos1=0,f...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
2205c3c4455afe38afc4f2812c1d0842
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include <stdio.h> #include <stdlib.h> int n,m; int winner(long long int a[m+2][n+2],int y) { int max=a[y][1],i,ans=1; for(i=2;i<=n;i++) { if(max<a[y][i]) { max=a[y][i]; ans=i; } } return ans; } int last (int finall[]) { int max=finall[...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
14e9f3aba4f7a0972dda88df3b9631ff
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> int main() { int n,m,i,j,count,max=0; scanf("%d %d",&n,&m); int elec,vote[n]; for(i=0;i<n;i++)vote[i]=0; for(i=0;i<m;i++){ max=-1; for(j=0;j<n;j++){ scanf("%d",&elec); if(elec>max)max=elec,count=j; } vote[count]++; } ...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
ef9773d33b64d9733c2fce775ea8cb8b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include <stdio.h> #include <stdlib.h> int main() { int x[100][100]; int s[100]; int n,m,z,winner,max; z=0; winner=0; scanf("%d %d",&n,&m); int i,j;//m rows n columns for(i=0;i<m;i++){ //Reading the matrix for(j=0;j<n;j++){ scanf("%d",&x[i][j]); } } ...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
4d4b2990d5f50510f0e4d561b38c03dc
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include <stdio.h> #include <stdlib.h> int main() { int x[100][100]; int s[100]; int n,m,z,winner,max; z=0; winner=0; scanf("%d %d",&n,&m); int i,j;//m rows n columns for(i=0;i<m;i++){ //Reading the matrix for(j=0;j<n;j++){ scanf("%d",&x[i][j]); } } ...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
fdaf726412e43411f777d5333d6b6c9d
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> int b[105]; int main() { int n,m,i,j,q,max,p,index,final; index=0; final=0; scanf("%d %d", &n, &m); for(i=0;i<m;i++) { max=-1; p=0; q=0; for(j=0;j<n;j++) { scanf("%d", &q); p=q; if(p>max) { max=p; index=j; } } b[index]++; } max=0; p=0; for(i=0;i<n;i++) {...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
549e23edbc9dea0b8b77a63f7226163b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> int main() { long long int N,M,i,j,max=0,index,temp; scanf("%lld %lld",&N,&M); long long int ans[N]; for(i=0;i<N;i++) ans[i]=0; for(i=0;i<M;i++) { max=0; index=0; for(j=0;j<N;j++) { scanf("%lld",&temp); if(temp>ma...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
bbfba3dc8a5eae2bcba159e6f208d668
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include<stdio.h> int main() { int n,m,i,j,c=0,max=0,b; scanf("%d%d",&n,&m); int a[100]={0}; for(i=1;i<=m;i++) { max=0; c=0; for(j=0;j<n;j++) { scanf("%d",&b); if(b>max) { max=b; c=j; } } a[c]++; } max=...
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
Print a single number β€” the index of the candidate who won the elections. The candidates are indexed starting from one.
C
b20e98f2ea0eb48f790dcc5dd39344d3
66a02614957af755a13fc5cfe9774655
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1439483400
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
PASSED
1,100
standard input
1 second
The first line of the input contains two integers n, m (1 ≀ n, m ≀ 100) β€” the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≀ j ≀ n, 1 ≀ i ≀ m, 0 ≀ aij ≀ 109) denotes the number of votes for candidate j in city i. It ...
["2", "1"]
#include <stdio.h> #include <string.h> int large(int ara[],int n) { int i,large=0,k=0; for(i=0; i<n; i++) { if(ara[i]>large) { //printf("%I64d %I64d\n",ara[i],large); k=0; large=ara[i]; k=i; } } //printf("k= %I64d\n", k); r...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
f4b9e102248dd55b1c32b7255517040b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> int candle[10001]; void merge(int min,int mid,int max) { int tmp[1000]; int i,j,k,m; j=min; m=mid+1; for(i=min;j<=mid&&m<=max;i++){ if(candle[j]<=candle[m]){ tmp[i]=candle[j]; j++; } else{ tmp[i]=candle[m]; m++...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
60f6ad77bcb23787d49492a76161f4a2
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> int w[1000], lig[1000]; int main() { #ifdef LOCAL freopen("data.in", "r", stdin); #endif int m, t, r, i, j, k, l, need, count, prevs, preve; while(scanf("%d%d%d", &m, &t, &r) != EOF) { count = 0; for(i = 0; i < 400; i++) { w[i] = 0; lig[i] ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
dd5220344fc1a29417414148900cebba
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
/*288*/ #include<stdio.h> int mem[301]; int main() { int m,r,t; int i,w,j,k; int x,ans=0; int can[301]={0}; scanf("%d %d %d",&m,&t,&r); if(r>t) { printf("-1\n"); return 0; } for(i=0;i<m;i++) { scanf("%d",&w); mem[w]=1; } for(i=1;i<=300;i++) { if(mem[i]) { int x,count=0; for(k=1;k<=r;k++...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
f3e599afe272af8a176779038151ca7f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
/*288*/ #include<stdio.h> int mem[301]; int main() { int m,r,t; int i,w,j,k; int x,ans=0; int can[301]; scanf("%d %d %d",&m,&t,&r); if(r>t) { printf("-1\n"); return 0; } for(i=1;i<=r;i++)can[i]=0; scanf("%d",&w); mem[w]=1; j=w; for(i=1;i<m;i++) { scanf("%d",&w); mem[w]=1; } for(i=j;i<=w;i++) ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
0820c665a0d40f697666b0e4ec89210e
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
/*288*/ #include<stdio.h> int mem[301]; int main() { int m,r,t; int i,w,j,k; int x,ans=0; int can[301]; scanf("%d %d %d",&m,&t,&r); if(r>t) { printf("-1\n"); return 0; } for(i=1;i<=r;i++)can[i]=0; for(i=0;i<m;i++) { scanf("%d",&w); mem[w]=1; } for(i=1;i<=w;i++) { if(mem[i]) { int count=0;...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
b0d0e5a679108b1b60973628f906dd8f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> int stack[90005]; int arr[305]; int main() { int m,t,r,i,flag = 0; scanf("%d%d%d",&m,&t,&r); for(i=0;i<m;i++) scanf("%d",&arr[i]); int count = 0,l = 0,f = r-1; for(i=0;i<r;i++) stack[i] = arr[0]-r+i; count = r; int j; if(t<r) flag=1; ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
18ad71c36479fce7b387751b46fda0f7
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> int can[602]; int main() { int m,t,r,i,k; int ans = 0; scanf("%d%d%d",&m,&t,&r); int A[m]; for(i = 0;i < m;i++){ scanf("%d",&A[i]); } if(r > t){ printf("-1\n"); return 0; } for(i = 0;i < m;i++){ int j = A[i] - 1; while(can[A...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
6afda527da4ecd9fe9288eaddc7431e5
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> int main(void){ int n; int t; int r; scanf("%i %i %i", &n, &t, &r); int Pole[n]; int i; for(i=0;i<n;i++){ scanf("%i", &Pole[i]); } int mini=1000000; int zacatky[1000]; int stav=1; int zrovna=0; int rozsviceni[1500]; for(i=0;i<1500;i++){ r...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
3f6f9c24f9a75be8ac27cff379daed72
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> char Flag[601]; int Cnt[601]; int main() { int m, t, r, w, i, j; scanf("%d %d %d", &m, &t, &r); while(m--) { scanf("%d", &w); w += 300; Flag[w] = 1; } int Cur = 0; for(i = 0; i < 601; ++i) { Cur += Cnt[i]; if(Flag[i] == 1) { ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
f0e69d7a6c032610c52abf9c79e61c51
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include"stdio.h" int main() { int f,temp,x[1200]={0},w[1200]={0},i,m,t,r,ans=0,j,z; scanf("%d%d%d",&m,&t,&r); for(i = 0;i < m ; ++i){ scanf("%d",&temp); if(x[temp+600]>=r)continue; int shit = x[temp+600]; for(j = 0;j<r-shit;++j){ int s = t - 1; for(z...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
3338a50031aebf722e75f06dfabaf357
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> int main() { int m,t,r,a[500],b[800]={0},i,p=0,s=0,c,e,ans=0; scanf("%d %d %d",&m,&t,&r); for(i=0;i<m;i++) scanf("%d",&a[i]); while(p<m) { if(a[p]==s) { c=0;e=0; for(i=1;i<=t;i++) if(b[s-i+300]==1) c++; if(c!=r) { for(i=1;i<=t && c+e<r;i++) if(b[s-i+300]==0) ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
ba360abb78383768ac7a3739313da224
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include "stdio.h" int c[605] = {0}; int l[605] = {0}; int g[305] = {0}; int main() { int m,t,r,i,wi,j,cnt=0,k,tmp; scanf("%d%d%d",&m,&t,&r); if(r>t) { printf("-1\n"); return 0; } for(i=0;i<m;i++) { scanf("%d",&wi); g[wi]=1; } for(i=0;i<=300;i++) { if(g[i]) { if(c[300+i]<r) { tmp = c[300...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
19df76c12717045ba0ee2f1d7e753c0f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include"stdio.h" int main() { int f,temp,x[1200]={0},w[1200]={0},i,m,t,r,ans=0,j,z; scanf("%d%d%d",&m,&t,&r); for(i = 0;i < m ; ++i){ scanf("%d",&temp); if(x[temp+600]>=r)continue; int shit = x[temp+600]; for(j = 0;j<r-shit;++j){ int s = t - 1; for(z...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
c754ab6415a73d3c27e9ae472cb6b480
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> #include <stdlib.h> int c[90001]={0}; int main() { int m,t,r; scanf("%d%d%d",&m,&t,&r); int i,j,k,g[m],l,ans=0; for(i=0;i<m;i++) scanf("%d",&g[i]); if (t<r) { printf("-1"); return 0; } while(ans<r) { c[r-ans-1]=g[0]-ans+t-1; ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
f4da796b973b0e7c33d947050bb9b466
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> int main(){ int m,t,r,ghost,candles[700][2]={0},light,ans=0,i,j,k; scanf("%d %d %d",&m,&t,&r); for(i=0;i<m;i++){ scanf("%d",&ghost); if(ans==-1){ continue; } if(candles[ghost+350][1]<r){ light=r-candles[ghost+350][1]; j=g...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
190ee3e2470fd0302bf6f3222d9203df
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> int m, t, r; int gho[301], time[602], total; void candle(int pos) { int i, j, cnt; pos+=300; if(time[pos]<r) { for(i=r-time[pos], cnt=0;i>0;i--, cnt--) { for(j=0;j<t;j++) { if(pos+cnt+j>=601) break; time[pos+cnt+j]++; } total++; //printf("%d ", pos+cnt-300); } ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
c27b2fe2c2a3ae88c3aad5883022c291
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> int main() { int m,t,r; int wi; int ar[300]; int i,j; int first,mid,last; int index; int found=0; int pre_index; int candles; int test; scanf("%d%d%d",&m,&t,&r); if (t>=r) { candles=r; scanf("%d",&wi); wi=wi+t; for ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
3208c1f4a5da87e89b0706f5539c43ad
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> int time[2002]; int main(){ int i, j, k, l, m, n, t, r, ctr; scanf("%d", &m); scanf("%d", &t); scanf("%d", &r); int a[m]; for(i = 0; i < m; i++){ scanf("%d", &j); a[i] = 1000 + j; } ctr = 0; if(t < r){ printf("-1\n"); return 0; ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
f60e5cd76fa752808b84f3b50b905153
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> void merge(int arr[],int min,int mid,int max) { int tmp[1000000]; int i,j,k,m; j=min; m=mid+1; for(i=min; j<=mid && m<=max ; i++) { if(arr[j]<=arr[m]) { tmp[i]=arr[j]; j++; } else { tmp[i]=arr[m]; m++; } } if(j>mid) {...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
1096937d870cdaaadf57a22ea4dbaebc
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> void ready(int); void place(int); int m,t,r,glow[602],ans; char cans[602]; int main(){ int pre,i; ans=0; scanf("%d %d %d",&m,&t,&r); if(t<r){ printf("-1\n"); return 0; } for(i=0;i<602;i++){ glow[i]=0; cans[i]=0; } for(i=0;i<m;i++){ scanf("%d",&pre); ready(pre); } printf("%d\n",an...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
cabf60ee9cbb69106b790daf23cc8280
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> int used[1005] ={}; int main() { int n,t,r; scanf("%d %d %d",&n,&t,&r); if(t < r) { printf("%d\n",-1); return 0; } for(int i = 0;i<n;i++) { int x; scanf("%d",&x); x+=500; int cnt = 0; for(int j = x-t;j < x;j++) if(used[j]) cnt++; for(int j = x-1;cnt < r; j--) if(!used[j])...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
8e709cc796e2d25e11517ad94204fd49
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> int main(){ int m,t,r,w,count,sum=0,i; int candle[1000] ={0}; scanf("%d%d%d",&m,&t,&r); if( t < r) sum = -1; while( m-- ){ scanf("%d",&w); if( t+1 > r ){ count =0; for( i = w-t; i<w && count < r;i++ ){ if( candle[i+t] == 1 ) count++; } if( count < r ){ count = r-co...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
cdb23f474626f5f09ff8bfec459fd9e1
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> int main() { int m,t,r, flag =0,j,k,temp; scanf("%d%d%d",&m,&t,&r); int time[2*t]; for(j=0;j<2*t;j++){ time[j]=0; } int i, prev_w,w,prev_light,candles = 0; scanf("%d", &w); if(r > t){ flag++; } for(j = 0;j < r && !flag ;j++){ for(i = 0;...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
a0b6ccaddc7b1fc36f59278502f3a578
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include<stdio.h> #define MAX 300 int sq[MAX+10]; int cnt[10*MAX+10]; int main() { int i,m,t,r,j,a[310]; int k, v, cur, cd, res = 0, nxt, nd; scanf("%d %d %d",&m,&t,&r); for(i=0;i<m;i++) { scanf("%d",&a[i]); } if(t < r) printf("-1\n"); else { for(i=0;i<m;i++)...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
40199f459eaff8dd9f5a8cdef8e4f16b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
// 288C.cpp : Defines the entry point for the console application. // //#include "stdafx.h" #include <stdio.h> #include <string.h> #define MAX_M 950 int m,t,r,Tg[MAX_M],Tc[MAX_M],Tl[MAX_M]; int main() { int i,j,g,c,cc,fg,z=300; while(scanf("%d %d %d",&m,&t,&r)!=EOF){ memset(Tg,0,sizeof(Tg)); memset(Tc,0,sizeo...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
931bb834c20be6f659e81d992515b017
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> #include<string.h> #include<stdbool.h> #define ll long long int m,t,r; int ans; int begin; int burning[10000],size,need; void del(int x) { int i,j;//diff=x-prev; //need=0; for(i=begin;i<(size);i++) { if((burning[i]+t)>=x) { break; } else ...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
7e7300b98de0b16b99c9c545e5c9a50d
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ int velas_num = 0; int m,t,r; int velas[301];// 301 pois 300 velas + 1 para eliminar edge case com tudo preenchido int velasp = 0; int velast = 0; int velas_count = 0; scanf("%d %d %d",&m,&t,&r); int time = -t; i...
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly t seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one can...
If it is possible to make at least r candles burn during each visit, then print the minimum number of candles that Anya needs to light for that. If that is impossible, print  - 1.
C
03772bac6ed5bfe75bc0ad4d2eab56fd
1a5975919dd5bad5bbfef829beefd8fe
GNU C
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "greedy" ]
1422376200
["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10"]
NoteAnya can start lighting a candle in the same second with ghost visit. But this candle isn't counted as burning at this visit.It takes exactly one second to light up a candle and only after that second this candle is considered burning; it means that if Anya starts lighting candle at moment x, candle is buring from ...
PASSED
1,600
standard input
2 seconds
The first line contains three integers m, t, r (1 ≀ m, t, r ≀ 300), representing the number of ghosts to visit Anya, the duration of a candle's burning and the minimum number of candles that should burn during each visit. The next line contains m space-separated numbers wi (1 ≀ i ≀ m, 1 ≀ wi ≀ 300), the i-th of them r...
["3", "1", "-1"]
#include <stdio.h> #include <math.h> int main() { int a,b,c,d,e,f,g,i,j,k,min=0,sum=0; int x[305],y[305][305]; scanf("%d %d %d",&a,&b,&c); for(i=0;i<a;i++) { scanf("%d",&x[i]); } y[0][0]=x[0]-c; ...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
c0f153b76734086f9c4822cb31db67c2
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdio.h> int main() { int m, n, i, j, count=0, A[1000][1000], B[1000][1000]; scanf("%d %d", &m, &n); for(i=0; i<m; i++) for(j=0; j<n; j++) scanf("%d", &A[i][j]); for(i=0; i<m; i++) for(j=0; j<n; j++) B[i][j]=0; for(i=0; i<m-1; i++) for(j=0; j...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
c81b8b911238c3db861ffef7da08ad88
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> int main() { int row,col,i,j,k=0,d[2500],e[2500]; scanf("%d%d",&row,&col); int a[60][60],b[60][60],c[60][60]; for(i=1;i<60;i++) for(j=1;j<60;j++){ b[i][j]=c[i][j]=0; } for(i=1;i<=row;i++) for(j=1;j<=col;j++){ scanf("%d",&a[i][j]); if(a[i][j]==1) b[i][j]=1; } ...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
59ef83ac78589959695a9955a4b34eb9
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> int main(){ int n,m,k=0; scanf("%d %d",&n,&m); int a[n][m]; int b[n][m]; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&a[i][j]); b[i][j]=0; } } for(int i=0;i<n-1;i++){ for(int j=0;j<m-1;j++){ if(a[i][j]=...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
241f6dd1dbcc9c9eae3960144c9134ca
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdlib.h> int a[52][52],b[10000][2]; int main() { int n,m,i,j,k=0,l=0; scanf("%d %d",&n,&m); for(i=1;i<=n;i++) for(j=1;j<=m;j++) { scanf("%d",&a[i][j]); if(a[i][j]!=0) k=1; } if(k==0) printf("0"); else { k=0; for(i=1;i<=n;i...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
628244e328668086e2a9839a2b6ee336
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <time.h> //srand(time(NULL)); //nombre_aleatoire = rand(); int main () { int B[50][50],n,m,i,j,k=0,op[50][50],K[2500][2]; scanf("%d %d",&n,&m); for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",&B[i][j]); } } for(i=0;...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
6986c56422c697b6f3575bd5fccda60c
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdio.h> int main(){ int n,m,i=0,j=0,count = 0; scanf("%d %d\n",&n,&m); int A[n][m],B[n][m]; while(i<n){ j = 0; while(j<m){ B[i][j] = 0; j++; } i++; } i = 0; while(i<n){ j = 0; while(j<m){ scanf("%d",&A[i][j]); j++; } i++; } i = 0; while(i<n-1){ j = 0; while(j<m-1){ ...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
4742bf0f889b027f21a270a375dd52ce
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdio.h> int main() { short int n,m,i,j,c=0,step[2500][2]={0},ctr=0,k,ct=0; scanf("%hd%hd",&n,&m); short int arr[n][m],test[n][m]; for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%hd",&arr[i][j]); test[i][j]=0; if(arr[i][j]==0) ctr++; } } if(ctr==(m*n)) printf("0"); else { k=0; f...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
8438e9dd0ded6d44900c9931da355f3e
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdio.h> int main() { int m,n,a[100][50],c,c1,b[2500],d[2500],i,j,z[100][50]; scanf("%d%d",&m,&n); c=0;c1=0; for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); z[i][j]=0; } } for(i=0;i<m-1;i++) { for(j=0;j<n-1;j++)...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
35e9e71fd81f95c168ee95bd755922cb
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdio.h> int main() { int n, m, A[100][100], i, j, B[100][100], x[100000], y[100000], k=-1; scanf("%d%d", &n, &m); for(i=1;i<=n;i=i+1) { for(j=1;j<=m;j=j+1) { scanf("%d", &A[i][j]); B[i][j]=0; } } for(i=1;i<n;i=i+1) { for(j=1;j...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
514fc8aa6115ad048653cf97758b32ef
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
/* AUTHOR:AKASH JAIN * USERNAME:akash19jain * DATE:25/08/2019 */ /*#include<algorithm> #include <bits/stdc++.h> using namespace std; */ #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #define SC1(x) scanf("%lld",&x) #define SC2(x,y) scanf("%lld%lld...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
1b0305fb5769feff9055b1ae7c95ec3d
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> int main() { int n,m,i,j,flag; int k=0; scanf("%d",&n); scanf("%d",&m); int arr[100][100]; int arr2[100][100]; int arr3[3000][5]; for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",&arr[i][j]); } } for(i=0;i<n;i++) { for(j=0;j<m;j++) { arr2[i][j]=0; } } for(i=0;i<(n-1);i...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
be97475b2b532fb31f17cd6dc6fb928c
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
//#include<iostream> int main(){ int n,m; scanf("%d %d",&n,&m); int mat[n][m]; int b[n][m]; int count = 0; int sum = 0; for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ scanf("%d",&mat[i][j]); count += mat[i][j]; b[i][j] = 0; } } int resu[3000][2] ; int k = 0; for(int i = 0;i < n...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
dc7057877b5e8f8794135db8ac8f8840
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> #include <stdlib.h> #define MAX(a,b) ((a)>(b)?(a):(b)) typedef long long ll; int cmpfnc(const void* a, const void* b) { return ( *(int*)b - *(int*)a); //Greatest first (b -a) } int A[50][50]; int B[50][50]; int ans1[2500]; int ans2[2500]; int main(void) { int N,M; int i,j; int ...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
219ca7d39ecd9379da3fe1eec80d61d3
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> int main() { int n, m, A[101][101], B[100][100] = { 0 }; scanf("%d %d", &n,&m); int i1, i2, i3,t, i,ret=1; for (i1 = 0; i1 < n; i1++) { for (i2 = 0; i2 < m; i2++) { scanf("%d", &A[i1][i2]); } } int f[10000][2]; i = 0; for (i1 = 0;...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
1a60bbee524660cb6c5bfe7b73b625b7
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> long long cmpfunc (const void * a, const void * b) { return ( *(long long*)a - *(long long*)b ); } int main(void){ long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,k,sum2,min,f,r,o,sum1,sum=0,y[10000][2],b[200][200]={0},a[200...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
c451da8a983f237071f4860dd04c9b1c
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdio.h> int main() { int m,n,free=1; scanf("%d%d",&n,&m); int a[n][m],b[n][m]; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&a[i][j]); if(a[i][j]==1) free=0; b[i][j]=0; } } if(free){ printf("0"); return 0; } int k=0; int x[n*m],y[n*m]; for(int i=0;i<n-1;i++){ for(int j...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
55f5f28b5b46cfcd3b507fa61df7647b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdio.h> #include<stdlib.h> int main(){ int n, m; int pos[5000]; int k = 0; int *matrix1, *matrix2; int not_equal = 0; scanf("%d %d", &n, &m); matrix1 = malloc(sizeof(int) * n * m); matrix2 = calloc(m * n, sizeof(int)); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ scanf("%d", matri...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
d4a4d86d7c0223b8679cafd55cfd2dfc
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
/* practice with Dukkha */ #include <stdio.h> #define N 50 #define M 50 int main() { static int aa[N][M], bb[N][M], ii[N * M], jj[N * M]; int n, m, i, j, cnt; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &aa[i][j]); cnt = 0; for (i = 1; i < n; i++) for (j = 1; j < m...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
23116a58da4f0b747bf0e12e99e6e11a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> #define N 50 #define M 50 int main() { static int aa[N][M], bb[N][M], moves[2500][2]; int n, m, i, j, k; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &aa[i][j]); k = 0; for (i = 0; i + 1 < n; i++) for (j = 0; j + 1 < m; j++) if (aa[i][j] == 1 &...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
a5471d32d2ea6a9304212a76c48a0421
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include<stdio.h> int main() { int n,m; scanf("%d%d",&n,&m); int a[n][m]; int b[n][m]; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { scanf("%d",&a[i][j]); b[i][j]=0; } } int count1=0; int x[2500]; int y[2500]; for(int i=0;i<n-1;i++) { for(int j=0;j<m-1;j++) { i...
You are given two matrices $$$A$$$ and $$$B$$$. Each matrix contains exactly $$$n$$$ rows and $$$m$$$ columns. Each element of $$$A$$$ is either $$$0$$$ or $$$1$$$; each element of $$$B$$$ is initially $$$0$$$.You may perform some operations with matrix $$$B$$$. During each operation, you choose any submatrix of $$$B$$...
If it is impossible to make $$$B$$$ equal to $$$A$$$, print one integer $$$-1$$$. Otherwise, print any sequence of operations that transforms $$$B$$$ into $$$A$$$ in the following format: the first line should contain one integer $$$k$$$ β€” the number of operations, and then $$$k$$$ lines should follow, each line contai...
C
ad641a44ecaf78ca253b199f3d40ef96
7d25089d9fb20a30e457926880d619d8
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "implementation", "greedy" ]
1566484500
["3 3\n1 1 1\n1 1 1\n0 1 1", "3 3\n1 0 1\n1 0 1\n0 0 0", "3 2\n0 0\n0 0\n0 0"]
NoteThe sequence of operations in the first example: $$$\begin{matrix} 0 &amp; 0 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 0 &amp; &amp; 1 &amp; 1 &amp; 1 &amp; &amp; 1 &amp; 1 &amp; 1 \\ 0 &amp; 0 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 0 &amp; \rightarrow &amp; 1 &amp; 1 &amp; 1 &amp; \rightarrow &amp; 1 &amp; 1 &a...
PASSED
1,200
standard input
1 second
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 50$$$). Then $$$n$$$ lines follow, each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$A_{i, j}$$$. Each integer is either $$$0$$$ or $$$1$$$.
["3\n1 1\n1 2\n2 2", "-1", "0"]
#include <stdio.h> #include <stdlib.h> int main() { int n,m;scanf("%d",&n);scanf("%d",&m); int impossible=0; int arr[n][m]; int res[n][m]; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ int in; scanf("%d", &in); arr[i][j] = in; res[i]...