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
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
2261c433f6fa58214d844610261c7d5b
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> int main() { int i,a,b,c,n,xa=0,ya=0,xb=0,yb=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d %d",&a,&b,&c); if(a==1) { xa=xa+b; ya=ya+c; } else { xb=xb+b; yb=yb+c; } } if...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
8ae618022c43ae98b74758b69878e2d5
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int main() { long n,t,x,y,s1,s2,i; s1=s2=0; scanf("%ld",&n); for (i=0;i<n;i++) { scanf("%ld%ld%ld",&t,&x,&y); if (t==1) s1+=x-y; else s2+=x-y; } printf("%s\n%s",s1>=0 ? "LIVE" : "DEAD",s2>=0 ? "LIVE" : "DEAD"); return 0; ...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
876636e86582bf84c6517bb009e16d46
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> int main() { int n,t[1001],x[1001],y[1001],s1=0,s2=0,s3=0,s4=0,i; scanf("%d",&n); for(i=1;i<=n;i++) {scanf("%d %d %d",&t[i],&x[i],&y[i]);} for(i=1;i<=n;i++) {if(t[i]==1) s1+=x[i]+y[i]; else s2+=x[i]+y[i];} for(i=1;i<=n;i++) {if(t[i]==1) s3+=x[i]; else s4+=x[i];} if(s3>=s1/2) printf("LIVE\n"); else pri...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
e6a161199f5f9b1f615687fa5dd49105
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include "stdio.h" typedef struct{ int x,y ; }ping ; int main(){ int n,t,xi,yi; ping host[3] = {{0,0},{0,0},{0,0}} ; scanf("%d",&n) ; while(n--){ scanf("%d %d %d",&t,&xi,&yi) ; host[t].x += xi ; host[t].y += yi ; } if(host[1].x >= host[1].y){ printf("LIVE\n") ; } else { printf("DEAD\n") ; } if(hos...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
a3cd6fe883624b3fe5e0a62fc6392efa
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> int main(void) { int n,t,x,y,count1=0,count2=0,cx,cy; cx=cy=0; scanf("%d",&n); while(n--) { scanf("%d%d%d",&t,&x,&y); if(t==1) { count1++; cx+=x; } else { count2++; cy+=x; } } if(cx>...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
e4dfc925a5e882e31c9757e3fcaa0caa
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int main() { int i; int n; int ti, xi, yi; int a_total = 0; int b_total = 0; int a_total_pack = 0; int b_total_pack = 0; int a, b; a = 0; b = 0; scanf("%d\n", &n); for(i = 0; i < n; i++) { scanf("%d %d %d\n", &ti, &xi, &...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
692a57f26d29acd2fbe68941be9ddbdb
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include"stdio.h" typedef struct { int liveSum; int sum; }pack; void main(){ int n,i,t,live,death; pack p1,p2; p1.liveSum=0; p1.sum=0; p2.liveSum=0; p2.sum=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&t,&live,&death); if(t==1) { p1.liveSum+=live; p1.sum+=10; } if(t==2) { p2.live...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
902556dfac35945b07c51338be057dde
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int main() { int n,i,j,s,t,w,v; int ara[1000][1000]; scanf("%d",&n); for (i=0;i<n;i++){ for(j=0;j<3;j++){ scanf("%d",&ara[i][j]); } } s=0; t=0; w=0; v=0; for (i=0;i<n;i++){ if (ara[i][0]==1){ s=s+ara[i][1]; t=t+ara[i][2]; } else{ w=w+ara[i][1]; v=v+ara[i][2]; } ...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
e26b3a6c7b6a53f45414652e4a6d4f0f
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> int main() { int n,i,j,x=0,y=0,a=0,b=0; scanf("%d",&n); int ping[n][3]; for(i=0;i<n;i++) { scanf("%d %d %d",&ping[i][0],&ping[i][1],&ping[i][2]); if(ping[i][0] == 1) { a=a+10; x=ping[i][1]+x; } else { b=b...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
0a460380685b999c98f3abe3e97e7d5e
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int main() { int a_t_received=0, b_t_received=0, a_t_lost=0, b_t_lost=0, n, t ; int a_received, a_lost, b_received, b_lost; scanf("%d", &n); while(n--) { scanf("%d", &t); if(t==1) { scanf("%d %d", &a_received, &a_lost); a_t_rece...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
323a78701302add22fb1a380ce09d3b2
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> int main() { int i,n,a1,a2,b1,b2,t,a,b; while(scanf("%d",&n)!=EOF) { a1=a2=b1=b2=0; for(i=1;i<=n;i++) { scanf("%d %d %d",&t,&a,&b); if(t==1){a1+=a;a2+=b;} else {b1+=a;b2+=b;} } if(a1>=a2)printf("LIVE\n"); else printf("DEAD\n"); if(b1>=b2)printf("LIVE\n"); else printf("DEAD\n"); } r...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
250ef891f1b742ee5c661ace23a8fdbf
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int main() { double n,i,j,s,a_sum=0,b_sum=0,a_pass=0,b_pass=0,x,y,z; double res1,res2; scanf("%lf",&n); for(y=1;y<=n;y++) { scanf("%lf %lf %lf",&s,&i,&j); if(s==1) { a_pass=a_pass+i; a_sum=a_sum+i+j; } else if(s==2) { ...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
99417eecda9312ab1a6bddab4f6e43e4
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> #include <string.h> int main() { int n,a,i,x,y; int s[2][2]; while(scanf("%d",&n)==1) { s[0][0]=0; s[0][1]=0; s[1][1]=0; s[1][0]=0; for(i=0;i<n;i++) { scanf("%d %d %d",&a,&x,&y); if(a==1){s[0][0]+=x;s[0][1]+=y;} ...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
08e38648c52c32eb36f9540bdf12799b
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int main(){ int n, t, acc, lst, a = 0, b = 0, ra = 0, rb = 0; scanf("%d", &n); for(int i = 0; i < n; i++){ scanf("%d%d%d", &t, &acc, &lst); if(t == 1){ a += 10; ra += acc; } else{ b += 10; rb += acc; } } printf("%s\n", (ra >= a/2) ? "LIVE" : "DEA...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
e1e1b5916d0f1161c4dac3a75f30e186
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int main() { int aa, al, ba, bl; int x, y, z; int i, N; scanf ("%d", &N); aa = 0; al = 0; ba = 0; bl = 0; for (i = 1; i <= N; i++) { scanf ("%d %d %d", &x, &y, &z); if (x == 1) { aa += y; al += z; } if (x == 2) { ba += y; bl += z; } } if (aa >= al) { printf("...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
6f15c17e59f5b41192cb620891dd9dfa
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> main() { int a[1010],x[1010],y[1010],n,s=0,p=0,f=0,l=0,i; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d %d %d",&a[i],&x[i],&y[i]); for(i=0;i<n;i++){ if(a[i]==1){ s+=x[i]; f++; } if(a[i]==2){ p...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
3c83f4eb6774f43f435e79350a4b76f0
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> //#define local int main() { #ifdef local freopen("data.txt","r",stdin); #endif int n,t,x[1001],y[1001],a1 = 0,a2 = 0,b1 = 0,b2 = 0,i = 0,j; scanf("%d",&n); for(;i < n;i++) { scanf("%d%d%d",&t,&x[i],&y[i]); if(t == 1) { a1 += x[i]; ...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
5b02e2878b649a8580104a239472da0d
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> #include <stdlib.h> int main() { int n,t,x1=0,y1=0,x2=0,y2=0,x,y,i; scanf("%d",&n); for(i=0;i<n;++i){ scanf("%d",&t); if(t==1){ scanf("%d",&x); x1=x1+x; scanf("%d",&y); y1=y1+y; } if(t==2){ scanf("%d",&x); x2=x2+x; scan...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
0f93559253ea94f8a8fb574d6bc6af93
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> int main() { int birg=0,birc=0,ikig=0,ikic=0,x,i,j; int arr[1000][4]={0}; scanf("%d",&x); for(i=0;i<x;i++) for(j=0;j<3;j++) scanf("%d",&arr[i][j]); for(i=0;i<x;i++){ if(arr[i][0]==1){ birg+=arr[i][1]; birc+=arr[i][2]; } else{ ikig+=arr[i][1]; ikic+=arr[i][2]; } } if(bir...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
8c87f1489008aacfc89f994ba0091fe5
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int main() { int i,n,x,y,t; while(scanf("%d",&n)!=EOF) { int a[10]={0},b[10]={0}; for(i=0;i<n;i++) { scanf("%d%d%d",&t,&x,&y); if(t==1) { a[1]=a[1]+x; a[2]=a[2]+y; } else ...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
0faf62b88a45deb317ef034804bd3a86
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> main() { int n,i,t[10000],x[10000],y[100000],s1=0,s2=0,s3=0,s4=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d %d",&t[i],&x[i],&y[i]); if(t[i]==1) { s1+=(x[i]+y[i]); s2+=x[i]; } else if(t[i]==2) { s3...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
29cf8e0622036c49bc7d44c24cf7049d
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> #include <stdlib.h> #include<string.h> #include<math.h> // dsklfjsdkjfsdkjfsdk int main() { int n, x, y, t, sum1 = 0, sum2 = 0, ove1 = 0, ove2 = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d %d", &t, &x, &y); if (t == 1) { sum1 += x; ove1 += 10; } else { sum2...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
cdf6e08ba879c491ca7176e6bd9d6e30
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> #include <stdlib.h> #include<string.h> #include<math.h> int main() { int n, x, y, t, sum1 = 0, sum2 = 0, ove1 = 0, ove2 = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d %d", &t, &x, &y); if (t == 1) { sum1 += x; ove1 += 10; } else { sum2 += x; ove2 += 10; ...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
97feaccd280db0425fe9505e3628ad27
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include<stdio.h> int main(){ int n,x,y,t,s1=0,s2=0,counter1=0,counter2=0; scanf("%d",&n); while(n--){ scanf("%d",&t); if(t==1){ scanf("%d%d",&x,&y); s1=s1+x; counter1++; } if(t==2){ scanf("%d%d",&x,&y); s2=s2+x; counter2++; } } counter1=counter1*10; if(s1>=counter1/2) printf("LIVE\n"...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
2e7feb81771048cc81cde2fb2188293f
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int x[2]; int y[2]; int main() { int i, n, xb, yb, t; scanf("%d\n", &n); for(i = 0; i < n; i++) { scanf("%d %d %d\n",&t, &xb, &yb); x[t - 1] += xb; y[t - 1] += yb; } for(i = 0; i < 2; i++) { if(x[i] < (x[i] + y[i]) / 2) { ...
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
C
1d8870a705036b9820227309d74dd1e8
7b580e381c3fbf8204f23dce9fd177f7
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1353339000
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
PASSED
800
standard input
2 seconds
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
["LIVE\nLIVE", "LIVE\nDEAD"]
#include <stdio.h> int numAccepts[3]; int numRejects[3]; int main() { int numTests; int i; scanf("%d", &numTests); while(numTests--) { int which; int accepts; int rejects; scanf("%d %d %d", &which, &accepts, &rejects); numAccepts[which] += accepts; numRejects[which] += rejects; } ...
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a1, a2, ..., an of length n, that the following condition fulfills: a2 - a1 = a3 - a2 = a4 - a3 = ... = ai + 1 - ai = ... = an - an - 1.For example, sequences [1, 5], [10], [5, 4,...
If Arthur can write infinitely many distinct integers on the card, print on a single line -1. Otherwise, print on the first line the number of integers that suit you. In the second line, print the numbers in the increasing order. Note that the numbers in the answer can exceed 108 or even be negative (see test samples).
C
e3ca8338beb8852c201be72650e9aabd
105cb764a04cf37492e2c5ad17f2dd0a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation", "sortings" ]
1389972600
["3\n4 1 7", "1\n10", "4\n1 3 5 9", "4\n4 3 4 5", "2\n2 4"]
null
PASSED
1,700
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 105) — the number of cards. The next line contains the sequence of integers — the numbers on Alexander's cards. The numbers are positive integers, each of them doesn't exceed 108.
["2\n-2 10", "-1", "1\n7", "0", "3\n0 3 6"]
#include <stdio.h> #include<stdlib.h> int compare (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main(void) { // your code goes here int n; scanf("%d",&n); int arr[n],i; for(i=0;i<n;i++) scanf("%d",&arr[i]); qsort(arr,n,sizeof(int),compare); if(n==1) { ...
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a1, a2, ..., an of length n, that the following condition fulfills: a2 - a1 = a3 - a2 = a4 - a3 = ... = ai + 1 - ai = ... = an - an - 1.For example, sequences [1, 5], [10], [5, 4,...
If Arthur can write infinitely many distinct integers on the card, print on a single line -1. Otherwise, print on the first line the number of integers that suit you. In the second line, print the numbers in the increasing order. Note that the numbers in the answer can exceed 108 or even be negative (see test samples).
C
e3ca8338beb8852c201be72650e9aabd
60e9a0b76b6c8b29b3b3317754a8fefc
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation", "sortings" ]
1389972600
["3\n4 1 7", "1\n10", "4\n1 3 5 9", "4\n4 3 4 5", "2\n2 4"]
null
PASSED
1,700
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 105) — the number of cards. The next line contains the sequence of integers — the numbers on Alexander's cards. The numbers are positive integers, each of them doesn't exceed 108.
["2\n-2 10", "-1", "1\n7", "0", "3\n0 3 6"]
#include<stdio.h> #include<stdlib.h> typedef long long int lint; int cmp(const void *x,const void *y) { return ((int)(*(lint*)x) -(int)(*(lint*)y)); } int main() { lint n,i,j,k,s=0,x=-1; lint a[100009]; scanf("%lld",&n); for(i=0;i<n;i++) scanf("%lld",&a[i]); if(n==1) printf("-1"); else if(n==2) { qsort(a,...
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a1, a2, ..., an of length n, that the following condition fulfills: a2 - a1 = a3 - a2 = a4 - a3 = ... = ai + 1 - ai = ... = an - an - 1.For example, sequences [1, 5], [10], [5, 4,...
If Arthur can write infinitely many distinct integers on the card, print on a single line -1. Otherwise, print on the first line the number of integers that suit you. In the second line, print the numbers in the increasing order. Note that the numbers in the answer can exceed 108 or even be negative (see test samples).
C
e3ca8338beb8852c201be72650e9aabd
164f65e53aa6efcda6657a886a9a5eab
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation", "sortings" ]
1389972600
["3\n4 1 7", "1\n10", "4\n1 3 5 9", "4\n4 3 4 5", "2\n2 4"]
null
PASSED
1,700
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 105) — the number of cards. The next line contains the sequence of integers — the numbers on Alexander's cards. The numbers are positive integers, each of them doesn't exceed 108.
["2\n-2 10", "-1", "1\n7", "0", "3\n0 3 6"]
#include <stdio.h> int cmpfunc (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main() { int a,b,c=0,d=-1,i,j=0; int x[100001],y[3]={0,0,0}; scanf("%d",&a); for(i=0;i<a;i++) scanf("%d",&x[i]); qsort(x,a...
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers a1, a2, ..., an of length n, that the following condition fulfills: a2 - a1 = a3 - a2 = a4 - a3 = ... = ai + 1 - ai = ... = an - an - 1.For example, sequences [1, 5], [10], [5, 4,...
If Arthur can write infinitely many distinct integers on the card, print on a single line -1. Otherwise, print on the first line the number of integers that suit you. In the second line, print the numbers in the increasing order. Note that the numbers in the answer can exceed 108 or even be negative (see test samples).
C
e3ca8338beb8852c201be72650e9aabd
31f0547ddd867d4a179c9431e56d2168
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation", "sortings" ]
1389972600
["3\n4 1 7", "1\n10", "4\n1 3 5 9", "4\n4 3 4 5", "2\n2 4"]
null
PASSED
1,700
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 105) — the number of cards. The next line contains the sequence of integers — the numbers on Alexander's cards. The numbers are positive integers, each of them doesn't exceed 108.
["2\n-2 10", "-1", "1\n7", "0", "3\n0 3 6"]
#include<stdio.h> #include<stdlib.h> int compare (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int a[100004],diff[100004]; int main() { int n,i,flag=1,cnt,dif; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); qsort(a,n,sizeof(int),compare); for(i=1;i<n;i++) { ...
Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold: there is integer j (l ≤ j ≤ r), such that all integers al, al + 1, ..., ar are divisible by aj; value r - l takes the maximum value amo...
Print two integers in the first line — the number of required pairs and the maximum value of r - l. On the following line print all l values from optimal pairs in increasing order.
C
da517ae908ba466da8ded87cec12a9fa
e99556f80f5a8a22ef3537933d4e78ba
GNU C
standard output
256 megabytes
train_003.jsonl
[ "two pointers", "math", "data structures", "binary search", "brute force" ]
1383379200
["5\n4 6 9 3 6", "5\n1 3 5 7 9", "5\n2 3 5 7 11"]
NoteIn the first sample the pair of numbers is right, as numbers 6, 9, 3 are divisible by 3.In the second sample all numbers are divisible by number 1.In the third sample all numbers are prime, so conditions 1 and 2 are true only for pairs of numbers (1, 1), (2, 2), (3, 3), (4, 4), (5, 5).
PASSED
2,000
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 3·105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 106).
["1 3\n2", "1 4\n1", "5 0\n1 2 3 4 5"]
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) void intSort(int d[],int s){int i=-1,j=s,k,t;if(s<=1)return;k=(d[0]+d[s-1])/2;for(;;){while(d[++i]<k);while(d[--j]>k);if(i>=j)break;t=d[i];d[i]=d[j];d[j]=t;}intSort(d,i);intSort(d+j+...
Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold: there is integer j (l ≤ j ≤ r), such that all integers al, al + 1, ..., ar are divisible by aj; value r - l takes the maximum value amo...
Print two integers in the first line — the number of required pairs and the maximum value of r - l. On the following line print all l values from optimal pairs in increasing order.
C
da517ae908ba466da8ded87cec12a9fa
bf4cd8a974696a592802a6bc9e3a4846
GNU C
standard output
256 megabytes
train_003.jsonl
[ "two pointers", "math", "data structures", "binary search", "brute force" ]
1383379200
["5\n4 6 9 3 6", "5\n1 3 5 7 9", "5\n2 3 5 7 11"]
NoteIn the first sample the pair of numbers is right, as numbers 6, 9, 3 are divisible by 3.In the second sample all numbers are divisible by number 1.In the third sample all numbers are prime, so conditions 1 and 2 are true only for pairs of numbers (1, 1), (2, 2), (3, 3), (4, 4), (5, 5).
PASSED
2,000
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 3·105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 106).
["1 3\n2", "1 4\n1", "5 0\n1 2 3 4 5"]
#include <stdio.h> int main() { int flag[300300]={0}; int i,j,n,l,r,ans,s[300300],top,a[300300]; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); top=0; ans=-1; for(i=1;i<=n;i++) { if(flag[i]==1) continue; l=i; while(l>1) { l--; ...
Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold: there is integer j (l ≤ j ≤ r), such that all integers al, al + 1, ..., ar are divisible by aj; value r - l takes the maximum value amo...
Print two integers in the first line — the number of required pairs and the maximum value of r - l. On the following line print all l values from optimal pairs in increasing order.
C
da517ae908ba466da8ded87cec12a9fa
eff6493eb16636cea4d10c0336215800
GNU C
standard output
256 megabytes
train_003.jsonl
[ "two pointers", "math", "data structures", "binary search", "brute force" ]
1383379200
["5\n4 6 9 3 6", "5\n1 3 5 7 9", "5\n2 3 5 7 11"]
NoteIn the first sample the pair of numbers is right, as numbers 6, 9, 3 are divisible by 3.In the second sample all numbers are divisible by number 1.In the third sample all numbers are prime, so conditions 1 and 2 are true only for pairs of numbers (1, 1), (2, 2), (3, 3), (4, 4), (5, 5).
PASSED
2,000
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 3·105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 106).
["1 3\n2", "1 4\n1", "5 0\n1 2 3 4 5"]
#include <stdio.h> #define swap( F, A, B ) ({ F FF = A; A = B; B = FF; }) #define min( F, A, B ) ({ F FF = A, FFF = B; FF < FFF ? FF : FFF; }) #define max( F, A, B ) ({ F FF = A, FFF = B; FF > FFF ? FF : FFF; }) #define abs( F, A ) ({ F FF = A; FF > 0 ? FF : -FF; }) #define MAX 300000 int a[ MAX + 10 ], f[ MAX + 10 ][ ...
Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold: there is integer j (l ≤ j ≤ r), such that all integers al, al + 1, ..., ar are divisible by aj; value r - l takes the maximum value amo...
Print two integers in the first line — the number of required pairs and the maximum value of r - l. On the following line print all l values from optimal pairs in increasing order.
C
da517ae908ba466da8ded87cec12a9fa
a4acb7e30fd7e254669569c267e91e50
GNU C
standard output
256 megabytes
train_003.jsonl
[ "two pointers", "math", "data structures", "binary search", "brute force" ]
1383379200
["5\n4 6 9 3 6", "5\n1 3 5 7 9", "5\n2 3 5 7 11"]
NoteIn the first sample the pair of numbers is right, as numbers 6, 9, 3 are divisible by 3.In the second sample all numbers are divisible by number 1.In the third sample all numbers are prime, so conditions 1 and 2 are true only for pairs of numbers (1, 1), (2, 2), (3, 3), (4, 4), (5, 5).
PASSED
2,000
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 3·105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 106).
["1 3\n2", "1 4\n1", "5 0\n1 2 3 4 5"]
#include<stdio.h> #include<math.h> int gcd(int a,int b) { if (b==0) return a; int hcf; while(a%b!=0) { hcf=a%b; a=b; b=hcf; } return b; } int mineqgcd(int T[][19],int M[][19],int *A,int l,int r) { int j,ans=0,temp=l; for(j=18;j>=0,l<=r;--j) ...
You have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m good pairs of integers (i1, j1), (i2, j2), ..., (im, jm). Each good pair (ik, jk) meets the following conditions: ik + jk is an odd number and 1 ≤ ik &lt; jk ≤ n.In one operation you can perform a sequence of actions: tak...
Output the answer for the problem.
C
10efa17a66af684dbc13c456ddef1b1b
cc2c911005addbcf62f0e854a978cb37
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "graph matchings", "flows", "number theory" ]
1419438600
["3 2\n8 3 8\n1 2\n2 3", "3 2\n8 12 8\n1 2\n2 3"]
null
PASSED
2,100
standard input
1 second
The first line contains two space-separated integers n, m (2 ≤ n ≤ 100, 1 ≤ m ≤ 100). The second line contains n space-separated integers a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ 109) — the description of the array. The following m lines contain the description of good pairs. The k-th line contains two space-separated integer...
["0", "2"]
/* practice with Dukkha */ #include <stdio.h> #include <stdlib.h> #define N 100 #define M 100 #define N_ (N + 2) #define M_ (N + M) #define INF 100 int min(int a, int b) { return a < b ? a : b; } struct V { int a, k, i; } vv[N * 9]; int compare(const void *a, const void *b) { struct V *u = (struct V *) a; struct...
Polycarp invented a new way to encode strings. Let's assume that we have string T, consisting of lowercase English letters. Let's choose several pairs of letters of the English alphabet in such a way that each letter occurs in at most one pair. Then let's replace each letter in T with its pair letter if there is a pair...
Print number k — the number of suitable positions in string S. In the next line print k integers m1, m2, ..., mk — the numbers of the suitable positions in the increasing order.
C
faa26846744b7b7f90ba1b521fee0bc6
60d0942aee5f727bdbd3700871d7b5eb
GNU C
standard output
256 megabytes
train_003.jsonl
[ "hashing", "string suffix structures", "strings" ]
1429286400
["11 5\nabacabadaba\nacaba", "21 13\nparaparallelogramgram\nqolorreraglom"]
null
PASSED
2,400
standard input
3 seconds
The first line of the input contains two integers, |S| and |T| (1 ≤ |T| ≤ |S| ≤ 2·105) — the lengths of string S and string T, respectively. The second and third line of the input contain strings S and T, respectively. Both strings consist only of lowercase English letters.
["3\n1 3 7", "1\n5"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #define MAX 200010 #define BASE 1925728309 #define max(a,b) ((a)>(b) ? (a):(b)) #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) char str[2][MAX]; int n, m, ar[26], counter[26], out[MAX], power[MAX], hash[26][MAX]; int...
Polycarp invented a new way to encode strings. Let's assume that we have string T, consisting of lowercase English letters. Let's choose several pairs of letters of the English alphabet in such a way that each letter occurs in at most one pair. Then let's replace each letter in T with its pair letter if there is a pair...
Print number k — the number of suitable positions in string S. In the next line print k integers m1, m2, ..., mk — the numbers of the suitable positions in the increasing order.
C
faa26846744b7b7f90ba1b521fee0bc6
3a6e678c982e581ad35a91b4baf9ebf3
GNU C
standard output
256 megabytes
train_003.jsonl
[ "hashing", "string suffix structures", "strings" ]
1429286400
["11 5\nabacabadaba\nacaba", "21 13\nparaparallelogramgram\nqolorreraglom"]
null
PASSED
2,400
standard input
3 seconds
The first line of the input contains two integers, |S| and |T| (1 ≤ |T| ≤ |S| ≤ 2·105) — the lengths of string S and string T, respectively. The second and third line of the input contain strings S and T, respectively. Both strings consist only of lowercase English letters.
["3\n1 3 7", "1\n5"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #define MAX 200010 #define BASE 1925728309 #define max(a,b) ((a)>(b) ? (a):(b)) #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) char str[2][MAX]; long long power[MAX], hash[2][26][MAX]; int n, m, len[2], out[MAX], coun...
Polycarp invented a new way to encode strings. Let's assume that we have string T, consisting of lowercase English letters. Let's choose several pairs of letters of the English alphabet in such a way that each letter occurs in at most one pair. Then let's replace each letter in T with its pair letter if there is a pair...
Print number k — the number of suitable positions in string S. In the next line print k integers m1, m2, ..., mk — the numbers of the suitable positions in the increasing order.
C
faa26846744b7b7f90ba1b521fee0bc6
6f8e93affc99b099cde112a99f692046
GNU C
standard output
256 megabytes
train_003.jsonl
[ "hashing", "string suffix structures", "strings" ]
1429286400
["11 5\nabacabadaba\nacaba", "21 13\nparaparallelogramgram\nqolorreraglom"]
null
PASSED
2,400
standard input
3 seconds
The first line of the input contains two integers, |S| and |T| (1 ≤ |T| ≤ |S| ≤ 2·105) — the lengths of string S and string T, respectively. The second and third line of the input contain strings S and T, respectively. Both strings consist only of lowercase English letters.
["3\n1 3 7", "1\n5"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #define MAX 200010 #define BASE 1925728309 #define max(a,b) ((a)>(b) ? (a):(b)) #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) char str[2][MAX]; int n, m, ar[26], counter[26], out[MAX], power[MAX], hash[26][MAX]; int...
Polycarp invented a new way to encode strings. Let's assume that we have string T, consisting of lowercase English letters. Let's choose several pairs of letters of the English alphabet in such a way that each letter occurs in at most one pair. Then let's replace each letter in T with its pair letter if there is a pair...
Print number k — the number of suitable positions in string S. In the next line print k integers m1, m2, ..., mk — the numbers of the suitable positions in the increasing order.
C
faa26846744b7b7f90ba1b521fee0bc6
342fc03bea5144b65d4acb94f8c0cb77
GNU C
standard output
256 megabytes
train_003.jsonl
[ "hashing", "string suffix structures", "strings" ]
1429286400
["11 5\nabacabadaba\nacaba", "21 13\nparaparallelogramgram\nqolorreraglom"]
null
PASSED
2,400
standard input
3 seconds
The first line of the input contains two integers, |S| and |T| (1 ≤ |T| ≤ |S| ≤ 2·105) — the lengths of string S and string T, respectively. The second and third line of the input contain strings S and T, respectively. Both strings consist only of lowercase English letters.
["3\n1 3 7", "1\n5"]
#include <stdio.h> #define MAX 200010 #define BASE 1925728309 char str[2][MAX]; int n, m, ar[26], counter[26], out[MAX], power[MAX], hash[26][MAX]; int gethash(int c, int l, int r){ return hash[c][r + 1] - (hash[c][l] * power[r - l + 1]); } void generate(){ int i, j, k, c, x, y; for (power[0] = 1, i = 1...
Polycarp invented a new way to encode strings. Let's assume that we have string T, consisting of lowercase English letters. Let's choose several pairs of letters of the English alphabet in such a way that each letter occurs in at most one pair. Then let's replace each letter in T with its pair letter if there is a pair...
Print number k — the number of suitable positions in string S. In the next line print k integers m1, m2, ..., mk — the numbers of the suitable positions in the increasing order.
C
faa26846744b7b7f90ba1b521fee0bc6
1be685d7c9a0a1ef628789aff7fc1d7e
GNU C
standard output
256 megabytes
train_003.jsonl
[ "hashing", "string suffix structures", "strings" ]
1429286400
["11 5\nabacabadaba\nacaba", "21 13\nparaparallelogramgram\nqolorreraglom"]
null
PASSED
2,400
standard input
3 seconds
The first line of the input contains two integers, |S| and |T| (1 ≤ |T| ≤ |S| ≤ 2·105) — the lengths of string S and string T, respectively. The second and third line of the input contain strings S and T, respectively. Both strings consist only of lowercase English letters.
["3\n1 3 7", "1\n5"]
#include <stdio.h> #define MAX 200010 #define BASE 1925728309 char str[2][MAX]; int n, m, ar[26], counter[26], out[MAX], power[MAX], hash[26][MAX]; int gethash(int c, int l, int r){ return hash[c][r + 1] - (hash[c][l] * power[r - l + 1]); } void generate(){ int i, j, k, c, x, y; for (power[0] = 1, i = 1...
Polycarp invented a new way to encode strings. Let's assume that we have string T, consisting of lowercase English letters. Let's choose several pairs of letters of the English alphabet in such a way that each letter occurs in at most one pair. Then let's replace each letter in T with its pair letter if there is a pair...
Print number k — the number of suitable positions in string S. In the next line print k integers m1, m2, ..., mk — the numbers of the suitable positions in the increasing order.
C
faa26846744b7b7f90ba1b521fee0bc6
712a1ef1cb9d7f51d57e4e9a8dc47161
GNU C
standard output
256 megabytes
train_003.jsonl
[ "hashing", "string suffix structures", "strings" ]
1429286400
["11 5\nabacabadaba\nacaba", "21 13\nparaparallelogramgram\nqolorreraglom"]
null
PASSED
2,400
standard input
3 seconds
The first line of the input contains two integers, |S| and |T| (1 ≤ |T| ≤ |S| ≤ 2·105) — the lengths of string S and string T, respectively. The second and third line of the input contain strings S and T, respectively. Both strings consist only of lowercase English letters.
["3\n1 3 7", "1\n5"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #define MAX 200010 #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) const unsigned long long base = 2078526727; char S[MAX], T[MAX], E[26]; int n, m, pos[MAX], next[MAX][26]; unsigned long long ar[26], power[MAX]; boo...
Polycarp invented a new way to encode strings. Let's assume that we have string T, consisting of lowercase English letters. Let's choose several pairs of letters of the English alphabet in such a way that each letter occurs in at most one pair. Then let's replace each letter in T with its pair letter if there is a pair...
Print number k — the number of suitable positions in string S. In the next line print k integers m1, m2, ..., mk — the numbers of the suitable positions in the increasing order.
C
faa26846744b7b7f90ba1b521fee0bc6
9eabbc1aa9121a26375826fd45bb6ad3
GNU C
standard output
256 megabytes
train_003.jsonl
[ "hashing", "string suffix structures", "strings" ]
1429286400
["11 5\nabacabadaba\nacaba", "21 13\nparaparallelogramgram\nqolorreraglom"]
null
PASSED
2,400
standard input
3 seconds
The first line of the input contains two integers, |S| and |T| (1 ≤ |T| ≤ |S| ≤ 2·105) — the lengths of string S and string T, respectively. The second and third line of the input contain strings S and T, respectively. Both strings consist only of lowercase English letters.
["3\n1 3 7", "1\n5"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #define MAX 200010 #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) const unsigned long long base = 2078526727; char S[MAX], T[MAX], E[26]; int n, m, pos[MAX], next[MAX][26]; unsigned long long ar[26], power[MAX]; boo...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
be15220d6736831ff1485ca588e516df
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> #include <stdbool.h> #define MAX 100 void init (int *c) { int i; for (i = 0; i < MAX + 1; i++) { if (c[i] == 2) continue; else c[i] = 0; } } int main () { int i, j; int n, m, k; int matrix[MAX + 1][MAX + 1]; int cell[MAX + 1] = {0}; int record[MAX + 1] = {0}; scanf ("%d %d %d", &n,...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
e2a9071c179f1c722bb329b7a050de6a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> int locked[101], ans[100]; int main(void) { int i, j; int n, m, k, x[100][100]; scanf("%d %d %d", &n, &m, &k); for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", x[i] + j); for (j = 0; j < m; j++) { int stack[101][100], sp[101] = {0}; ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
422882f2b405522f2dec668efae410a5
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include<stdio.h> int main() { int arr[105][105]; int core[105],cell[105][2]; int n,m,k,i,j; scanf("%d%d%d",&n,&m,&k); for(i=0;i<=101;i++) core[i]=cell[i][0]=0; for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",&arr[i][j]); for(j=1;j<=m;j++) { for(i=1;i...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
e138555ebdb79013150776bf9b043fc9
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include<stdio.h> int main(){ int n,m,k,i,j,x,y,sum = 0,flag = 1; scanf("%d %d %d",&n,&m,&k); int a[n][m] , cores[2][n] , cell[k],cells[k][2]; for(i=0;i<n;i++){ cores[0][i] = 1; cores[1][i] = 0; } for(i=0;i<k;i++){ cell[i] = 1; } for(i=0;i<n;i++){ for(j=0;...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
8a58621bc6086d442713488023a3b9f1
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#define rep(i,a,b) for(i=a;i<b;++i) #define get(a) scanf("%d",&a) int arr[101][101]; int mem[101], cor[101]; int main() { int n,m,k,i,j; get(n);get(m);get(k); rep(i, 0, n) { rep(j, 0, m) { get(arr[i][j]); } } rep(i, 0, m) { int cont[101] = {}; ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
37648d31f14ba91e6dc7c919c84e21ca
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> int a[100][100]; int b[100]; int c[100]; int d[100]; int main() { int n, m, k, i, j; scanf("%d %d %d", &n, &m, &k); for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { scanf("%d", &a[i][j]); } } for (i = 0; i < m; i++) { for (j ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
d4b99c1d6b9ecd623536c4e9264ffb96
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #define LOCKED 1 #define UNLOCKED 0 #define BUSY 2 int main( void ) { const int Max = 100; int params[Max+1][Max+1]; int cells[Max+1]; int log[Max+1]; int n, m, k, c; int i, j; scanf("%i %i %i", &n, &m, &k); for( i = 0; i < n; i++ ) for( j =...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
2792ba9eb5315d57498379673d2bcf53
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include<stdio.h> #include<string.h> int main() { int i,j,k,t,n,m,a[105][105],b[105]={0},c[105]={0},d[105]={0}; scanf("%d%d%d",&n,&m,&t); for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",&a[i][j]); for(j=1;j<=m;j++){ memset(c,0,sizeof(c)); for(i=1;i<=n;i++) ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
14582352e9ab8119a8519544b7af3b2e
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> #include <string.h> #define N 100 #define M 100 #define K 100 int main() { static int ll[K + 1], cc[K + 1], tt[N]; static int aa[N][M]; int n, m, k, a, i, j; scanf("%d%d%d", &n, &m, &k); for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &aa[i][j]); for (j = 0; j < m; j++) { ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
d8645291130519d667126b806f87b184
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> #define N 100 #define M 100 #define K 100 int main() { static int ll[K], cc[N], ii[K]; static int xx[N][M]; int n, m, k, h, i, j; scanf("%d%d%d", &n, &m, &k); for (i = 0; i < n; i++) for (j = 0; j < m; j++) { scanf("%d", &xx[i][j]); xx[i][j]--; } for (j = 0; j < m; j++) { for (h ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
dc9e3c6705f2b3cc18639911e349b7d5
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> #include <stdlib.h> int main() { int n , m , k , i , j , l , flag = 0; scanf("%d%d%d" , &n , &m , &k); int A[n + 5][m + 5] , Bc[105] = {0} , Bco[105] = {0}; for(i = 0;i < n;i++) { for(j = 0;j < m;j++) { scanf("%d" , &A[i][j]); } } /*for...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
212cfa78be49e7fa4dee732bb96d7d67
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include<stdio.h> int main() { int n,m,k,i,j,k1; int a[105][105],mem[105]={0},core[105]={0}; scanf("%d%d%d",&n,&m,&k); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%d",&a[i][j]); } } for(i=1;i<=m;i++) { for(k1=1;k1<=k;k1++) { ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
8b460e7e3461fd675a54c4429d3c8dc2
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> #define MAXN 110 int i, j, c, n, m, k, tmp; int intable[MAXN][MAXN]; int locktable[MAXN]; int main() { scanf("%d %d %d", &n, &m, &k); for(i = 1; i<= n; i++) for(j = 1; j <= m; j++) scanf("%d", &intable[i][j]); for(j = 1; j <= m; j++) for( c = 1; c <= ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
f1c328930e0d2cfeb3c76c3606457388
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include<stdio.h> int kar[105],arr[105][105],c[105]; int main() { int i,j,n,m,k,l,count,res; scanf("%d%d%d",&n,&m,&k); for(i=0;i<n;i++) { for(j=0;j<m;j++) scanf("%d",&arr[i][j]); } /*printf("Original array is:\n"); for(i=0;i<n;i++) { for(j=0;j<m;j++) {...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
744303a08a5485b27cd8fadacd0d1f0e
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> int core[105]; int mem[105]; int mat[105][105]; int main(void) { int n, m, k; int i, j, p; scanf(" %d %d %d", &n, &m, &k); for (i = 1; i <= n; i++) { core[i] = 0; } for (i = 1; i <= k; i++) { mem[i] = 0; } for (i = 1; i <= n; i++) { for (j ...
The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to...
Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.
C
6422a70e686c34b4b9b6b5797712998e
e5d22112acd47026fdd7ca13ed4c8ef0
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1397505600
["4 3 5\n1 0 0\n1 0 2\n2 3 1\n3 2 0", "3 2 2\n1 2\n1 2\n2 2", "1 1 1\n0"]
null
PASSED
1,600
standard input
1 second
The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains m integers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction...
["1\n1\n3\n0", "1\n1\n0", "0"]
#include <stdio.h> int main() { int m,n,k,i,j; scanf("%d %d %d",&n,&m,&k); int arr[n][m]; int spare[100]; int res[100]={0}; for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",&arr[i][j]); } } int l=0; int c=0,v=0; for(l=0;l<m;l++) { ...
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n cities in Berland and neighboring countries in total and exactly n - 1 two-way r...
Output the answer, number t — what is the least amount of days needed to rebuild roads so that from each city it became possible to reach all the others. Then output t lines — the plan of closure of old roads and building of new ones. Each line should describe one day in the format i j u v — it means that road between ...
C
1c1641aeb850e5b20a4054e839cc22e4
233c49ef13f373e832741b177480cbc3
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dsu", "trees", "graphs" ]
1280761200
["2\n1 2", "7\n1 2\n2 3\n3 1\n4 5\n5 6\n6 7"]
null
PASSED
1,900
standard input
2 seconds
The first line contains integer n (2 ≤ n ≤ 1000) — amount of cities in Berland and neighboring countries. Next n - 1 lines contain the description of roads. Each road is described by two space-separated integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — pair of cities, which the road connects. It can't be more than one road b...
["0", "1\n3 1 3 7"]
#include <stdio.h> typedef struct arista { int nodos[2]; }Arista; typedef struct cola_pila { Arista arreglo[50]; int cabeza; int cola; int tamanho; }COLA; typedef struct unionFind { int p; int rank; }UnionFind; Arista pop_cola(COLA *cola); void insertar_en_cola(COLA *mi_cola, Arista elemento...
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n cities in Berland and neighboring countries in total and exactly n - 1 two-way r...
Output the answer, number t — what is the least amount of days needed to rebuild roads so that from each city it became possible to reach all the others. Then output t lines — the plan of closure of old roads and building of new ones. Each line should describe one day in the format i j u v — it means that road between ...
C
1c1641aeb850e5b20a4054e839cc22e4
d282a7733d47206d65991fce92fb8c29
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dsu", "trees", "graphs" ]
1280761200
["2\n1 2", "7\n1 2\n2 3\n3 1\n4 5\n5 6\n6 7"]
null
PASSED
1,900
standard input
2 seconds
The first line contains integer n (2 ≤ n ≤ 1000) — amount of cities in Berland and neighboring countries. Next n - 1 lines contain the description of roads. Each road is described by two space-separated integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — pair of cities, which the road connects. It can't be more than one road b...
["0", "1\n3 1 3 7"]
/* practice with Dukkha */ #include <stdio.h> #include <string.h> #define N 1000 int dsu[N]; int find(int i) { return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i])); } int join(int i, int j) { i = find(i); j = find(j); if (i == j) return 0; if (dsu[i] > dsu[j]) dsu[i] = j; else { if (dsu[i] == dsu[j]) dsu[...
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n cities in Berland and neighboring countries in total and exactly n - 1 two-way r...
Output the answer, number t — what is the least amount of days needed to rebuild roads so that from each city it became possible to reach all the others. Then output t lines — the plan of closure of old roads and building of new ones. Each line should describe one day in the format i j u v — it means that road between ...
C
1c1641aeb850e5b20a4054e839cc22e4
cbdaedcdb5609a405cab5967106e17b6
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dsu", "trees", "graphs" ]
1280761200
["2\n1 2", "7\n1 2\n2 3\n3 1\n4 5\n5 6\n6 7"]
null
PASSED
1,900
standard input
2 seconds
The first line contains integer n (2 ≤ n ≤ 1000) — amount of cities in Berland and neighboring countries. Next n - 1 lines contain the description of roads. Each road is described by two space-separated integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — pair of cities, which the road connects. It can't be more than one road b...
["0", "1\n3 1 3 7"]
#include<stdio.h> #define maxn 1005 #define FOR(a, b, c) for(int a=b; a<=c; a++) int fa[maxn], n, eu, ev, cnt, nmsl[maxn]={0}; struct node { int u, v; }rua[maxn], ans[maxn]; int find(int x) { while(x!=fa[x]) x = fa[x] = fa[fa[x]]; return x; } void kkp() { FOR(i, 1, n-1) { nmsl[ru...
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only if there is no railway between them. Travelling to a different town using one r...
Output one integer — the smallest possible time of the later vehicle's arrival in town n. If it's impossible for at least one of the vehicles to reach town n, output  - 1.
C
fbfc333ad4b0a750f654a00be84aea67
200663e02c74e92e19604f7e54513669
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "shortest paths", "graphs" ]
1448382900
["4 2\n1 3\n3 4", "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4", "5 5\n4 2\n3 5\n4 5\n5 1\n1 2"]
NoteIn the first sample, the train can take the route and the bus can take the route . Note that they can arrive at town 4 at the same time.In the second sample, Absurdistan is ruled by railwaymen. There are no roads, so there's no way for the bus to reach town 4.
PASSED
1,600
standard input
2 seconds
The first line of the input contains two integers n and m (2 ≤ n ≤ 400, 0 ≤ m ≤ n(n - 1) / 2) — the number of towns and the number of railways respectively. Each of the next m lines contains two integers u and v, denoting a railway between towns u and v (1 ≤ u, v ≤ n, u ≠ v). You may assume that there is at most one ra...
["2", "-1", "3"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define max(x,y) x > y ? x : y void djk(int *res,int (*map)[401],int len,int s){ int solve[len+1]; memset(solve,0,sizeof(solve)); solve[s] = 1; res[s] = 0; int solved = 1; for(int i=1;i<=len;i++){ if(map[s][i]){ res...
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only if there is no railway between them. Travelling to a different town using one r...
Output one integer — the smallest possible time of the later vehicle's arrival in town n. If it's impossible for at least one of the vehicles to reach town n, output  - 1.
C
fbfc333ad4b0a750f654a00be84aea67
88c3f405d1a622e7dd73b019ad9fed36
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "shortest paths", "graphs" ]
1448382900
["4 2\n1 3\n3 4", "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4", "5 5\n4 2\n3 5\n4 5\n5 1\n1 2"]
NoteIn the first sample, the train can take the route and the bus can take the route . Note that they can arrive at town 4 at the same time.In the second sample, Absurdistan is ruled by railwaymen. There are no roads, so there's no way for the bus to reach town 4.
PASSED
1,600
standard input
2 seconds
The first line of the input contains two integers n and m (2 ≤ n ≤ 400, 0 ≤ m ≤ n(n - 1) / 2) — the number of towns and the number of railways respectively. Each of the next m lines contains two integers u and v, denoting a railway between towns u and v (1 ≤ u, v ≤ n, u ≠ v). You may assume that there is at most one ra...
["2", "-1", "3"]
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <ctype.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <limits.h> #include <math.h> #define MaxVNum 401 int MINDIST(int a, int* st, int* d, int size) { int i; int min_s, min_d; min_s = -1; min_d = INT_MAX; for ...
It has been noted that if some ants are put in the junctions of the graphene integer lattice then they will act in the following fashion: every minute at each junction (x, y) containing at least four ants a group of four ants will be formed, and these four ants will scatter to the neighbouring junctions (x + 1, y), (x ...
Print t integers, one per line — the number of ants at the corresponding junctions when the movement of the ants stops.
C
e7a07efba27f2b1f9ec7c4a8fb997b00
6f069ded4674854224370a18ef4ea07c
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "brute force" ]
1371223800
["1 3\n0 1\n0 0\n0 -1", "6 5\n0 -2\n0 -1\n0 0\n0 1\n0 2"]
NoteIn the first sample the colony consists of the one ant, so nothing happens at all.In the second sample the colony consists of 6 ants. At the first minute 4 ants scatter from (0, 0) to the neighbouring junctions. After that the process stops.
PASSED
2,000
standard input
1 second
First input line contains integers n (0 ≤ n ≤ 30000) and t (1 ≤ t ≤ 50000), where n is the number of ants in the colony and t is the number of queries. Each of the next t lines contains coordinates of a query junction: integers xi, yi ( - 109 ≤ xi, yi ≤ 109). Queries may coincide. It is guaranteed that there will be a ...
["0\n1\n0", "0\n1\n2\n1\n0"]
/* practice with Dukkha */ #include <stdio.h> #define Z 200 int main() { static int kk[Z + 1 + Z][Z + 1 + Z]; int n, t, x, y, k, updated; scanf("%d%d", &n, &t); kk[Z][Z] = n; while (1) { updated = 0; for (x = 1; x < Z + Z; x++) for (y = 1; y < Z + Z; y++) if (kk[x][y] >= 4) { k = kk[x][y] / 4; ...
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
Print on the single line the handle of the room leader.
C
b9dacff0cab78595296d697d22dce5d9
ecf399798cd18564fdf397a2b124b9c4
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1302879600
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
PASSED
1,000
standard input
2 seconds
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
["tourist"]
#include<stdio.h> //using namespace std; int main() { char name[50][50]; int plus[50],min[50],a[50],b[50],c[50],d[50],e[50],score[50]; int n; int arr[500]; scanf("%d",&n); //cin>>n; int i,pos,max; for(i=0;i<n;i++) { scanf("%s %d %d %d %d %d %d %d",name[i],&plus[i],&min[i],&a[i],&b[i],&c[i],&d[i],&e[i]); //...
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
Print on the single line the handle of the room leader.
C
b9dacff0cab78595296d697d22dce5d9
6e9e3ba5506e16fd401c839c210770db
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1302879600
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
PASSED
1,000
standard input
2 seconds
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
["tourist"]
#include<stdio.h> #include<string.h> int main() { char str[32],name[32]; int t,i,r=-1000000000,n,a,s,u,j; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s %d %d",str,&s,&u); t=100*s-50*u; for(j=0;j<5;j++) scanf("%d",&a),t+=a; if (t>r) r=t,strcpy(name,str); } puts(name); return 0; }
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
Print on the single line the handle of the room leader.
C
b9dacff0cab78595296d697d22dce5d9
7acf5dc5a6fbef8a91ce175efe11262c
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1302879600
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
PASSED
1,000
standard input
2 seconds
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
["tourist"]
#include <stdio.h> #include <stdlib.h> int T[50]; char name[50][21]; int indice(int n) { int i,max=0; for(i=1;i<n;i++) { if (T[i]>T[max]) max=i;} return max; } int main() { int n,i,p,m,a,b,c,d,e; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s",&name[i]); scanf("%d%d%d%d%d%d%d",&p,&m,...
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
Print on the single line the handle of the room leader.
C
b9dacff0cab78595296d697d22dce5d9
8527bd5c7b1f20015b1e53240b52958c
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1302879600
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
PASSED
1,000
standard input
2 seconds
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
["tourist"]
#include<stdio.h> int main() { int n,plus,minus,a,b,c,flag=0,d,e,i,k,max,l,j; char s[100][20]; scanf("%d",&n); scanf("%s %d %d %d %d %d %d %d",s[0],&plus,&minus,&a,&b,&c,&d,&e); k = (100*plus)-(50*minus)+a+b+c+d+e; max = k; for(i=1;i<n;i++) { scanf("%s %d %d %d %d %d %d %d",...
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
Print on the single line the handle of the room leader.
C
b9dacff0cab78595296d697d22dce5d9
0533e73ff9fffb6e116e22f3463b278b
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1302879600
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
PASSED
1,000
standard input
2 seconds
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
["tourist"]
#include <stdio.h> int main() { int sum,i,n,k,p,m,a,b,c,d,e,max; char s[60][100]; while(scanf("%d",&n)!=EOF) { getchar(); for(i=0;i<n;i++) { scanf("%s %d %d %d %d %d %d %d",s[i],&p,&m,&a,&b,&c,&d,&e); sum=0; sum=sum+p*100+m*(-50)+a+b+c+d+e; ...
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
Print on the single line the handle of the room leader.
C
b9dacff0cab78595296d697d22dce5d9
76a6cdf49bfe82e5aa63b2f879387382
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1302879600
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
PASSED
1,000
standard input
2 seconds
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
["tourist"]
#include<stdio.h> #include<string.h> int main() { char name[100],winner[100]; int sh,uh,a,b,v,c,d,e; int n,i; int sum; int total=sum; scanf("%d",&n); scanf("%s %d %d %d %d %d %d %d",name,&sh,&uh,&a,&b,&c,&d,&e); sum = sh*100-uh*50+a+b+c+d+e; total=sum; strcpy(winner,n...
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
Print on the single line the handle of the room leader.
C
b9dacff0cab78595296d697d22dce5d9
e8f3c3033862c9fca5922d2118c9aab3
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1302879600
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
PASSED
1,000
standard input
2 seconds
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
["tourist"]
#include <stdio.h> #include <string.h> int main() { char name[21], lider[21]; int n, h, l, i, a, b, c, d, e, sum, max; scanf("%d", &n); max = -2000000000; while (n--) { sum = 0; scanf("%s %d%d%d%d%d%d%d", name, &h, &l, &a, &b, &c, &d, &e); sum = 100 * h - 50 * l + a + b + c ...
Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems...
Print on the single line the handle of the room leader.
C
b9dacff0cab78595296d697d22dce5d9
b51b9af2bfa6ba65ec248d2c3714499a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1302879600
["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"]
NoteThe number of points that each participant from the example earns, are as follows: Petr — 3860 tourist — 4140 Egor — 4030 c00lH4x0R —  - 350 some_participant — 2220 Thus, the leader of the room is tourist.
PASSED
1,000
standard input
2 seconds
The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessf...
["tourist"]
#include <stdio.h> char name[51][33]; int s[51]; int main() { int i,n,x,y,a,b,c,d,e,p=1; scanf("%d",&n); for (i=1;i<=n;i++) { scanf("%s%d%d%d%d%d%d%d",name[i],&x,&y,&a,&b,&c,&d,&e); s[i]=100*x-50*y+a+b+c+d+e; if (s[i]>s[p]) p=i; } puts(name[p]); return 0; }
An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $$$091$$$), a colon (ASCII code $$$058$$$), some (possibly zero) vertical line characters (ASCII code $$$124$$$), ano...
If it is not possible to obtain an accordion by removing some characters from $$$s$$$, print $$$-1$$$. Otherwise print maximum possible length of the resulting accordion.
C
915b4776a6b1fa15886247eb1ad40b60
8179a69a5249208adf3b07c19a4ceb7e
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy" ]
1547217300
["|[a:b:|]", "|]:[|:]"]
null
PASSED
1,300
standard input
3 seconds
The only line contains one string $$$s$$$ ($$$1 \le |s| \le 500000$$$). It consists of lowercase Latin letters and characters [, ], : and |.
["4", "-1"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char a[500300]; scanf("%s", a); int count= 0, i = 0 , flag = 1, len = strlen(a), co = 0 , co1 = 0, index ; while(a[i]!= '[' ){ i++; if(i >= len) { flag = 0; break; } } if(a[i]== '[') count++; while(a[i] !=...
An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $$$091$$$), a colon (ASCII code $$$058$$$), some (possibly zero) vertical line characters (ASCII code $$$124$$$), ano...
If it is not possible to obtain an accordion by removing some characters from $$$s$$$, print $$$-1$$$. Otherwise print maximum possible length of the resulting accordion.
C
915b4776a6b1fa15886247eb1ad40b60
b5bae0e47d8edbd2df3ce348fc17491a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy" ]
1547217300
["|[a:b:|]", "|]:[|:]"]
null
PASSED
1,300
standard input
3 seconds
The only line contains one string $$$s$$$ ($$$1 \le |s| \le 500000$$$). It consists of lowercase Latin letters and characters [, ], : and |.
["4", "-1"]
#include<stdio.h> #define ll long long int #include<string.h> char s[500001]; int main(){ scanf("%s",s); int i,n=strlen(s),k=0,f=0; for(i=0;i<n;i++){ if(s[i]=='['){ f=1;k=1;break;} else f=0; } if(f){ for(++i;i<n;i++){ if(s[i]==':'){ f=1;k+=1;break; } else ...
An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $$$091$$$), a colon (ASCII code $$$058$$$), some (possibly zero) vertical line characters (ASCII code $$$124$$$), ano...
If it is not possible to obtain an accordion by removing some characters from $$$s$$$, print $$$-1$$$. Otherwise print maximum possible length of the resulting accordion.
C
915b4776a6b1fa15886247eb1ad40b60
f6e9c0fa7e01f72d5829d98c65cf7d5e
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy" ]
1547217300
["|[a:b:|]", "|]:[|:]"]
null
PASSED
1,300
standard input
3 seconds
The only line contains one string $$$s$$$ ($$$1 \le |s| \le 500000$$$). It consists of lowercase Latin letters and characters [, ], : and |.
["4", "-1"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXSIZE 500000 int main() { char ca[MAXSIZE]; int cb[MAXSIZE]; int l,nm = 0,flag = 0,p = -1,q = -1,pp = 0,qq = 0; scanf("%s",ca); l = strlen(ca); for(int i = 0;i < l;i++) { if(ca[i] == '|') cb[i] = ++nm; ...
An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $$$091$$$), a colon (ASCII code $$$058$$$), some (possibly zero) vertical line characters (ASCII code $$$124$$$), ano...
If it is not possible to obtain an accordion by removing some characters from $$$s$$$, print $$$-1$$$. Otherwise print maximum possible length of the resulting accordion.
C
915b4776a6b1fa15886247eb1ad40b60
5db8964012fe0abf2724f96387a62483
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy" ]
1547217300
["|[a:b:|]", "|]:[|:]"]
null
PASSED
1,300
standard input
3 seconds
The only line contains one string $$$s$$$ ($$$1 \le |s| \le 500000$$$). It consists of lowercase Latin letters and characters [, ], : and |.
["4", "-1"]
// #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> // #include <vector> // using namespace std; int main(){ char s[500001]; scanf("%s", s); int size = strlen(s); // printf("%d\n", size); if (size < 4) { printf("%d\n", -1); // free(s); return 0; } int i = 0; int opening_bra...
An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $$$091$$$), a colon (ASCII code $$$058$$$), some (possibly zero) vertical line characters (ASCII code $$$124$$$), ano...
If it is not possible to obtain an accordion by removing some characters from $$$s$$$, print $$$-1$$$. Otherwise print maximum possible length of the resulting accordion.
C
915b4776a6b1fa15886247eb1ad40b60
96323024fe49858cce987c2bb49c3ef8
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy" ]
1547217300
["|[a:b:|]", "|]:[|:]"]
null
PASSED
1,300
standard input
3 seconds
The only line contains one string $$$s$$$ ($$$1 \le |s| \le 500000$$$). It consists of lowercase Latin letters and characters [, ], : and |.
["4", "-1"]
#include<stdio.h> #include<string.h> int main(){ char s[500001]; scanf("%s",s); int l = strlen(s); int i,j; int open = -1, close = -1; for(i = 0;i < l;i++){ if(s[i] == '['){ open = i; break; } } for(i = l-1;i >= 0;i--){ if(s[i] == ']'){ close = i; break; } } if(open == -1 || close == -1 ...
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the secon...
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≤ a ≤ n - 1, 0 ≤ b ≤ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
ca1136934637e1acb7259f104a99346b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "constructive algorithms", "greedy", "graphs" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal — as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≤ degreei ≤ n - 1, 0 ≤ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
/* practice with Dukkha */ #include <stdio.h> #define N (1 << 16) int main() { static int dd[N], ss[N], qq[N]; int n, m, i, j, head, cnt; scanf("%d", &n); m = 0; for (i = 0; i < n; i++) { scanf("%d%d", &dd[i], &ss[i]); m += dd[i]; } m /= 2; printf("%d\n", m); head = 0, cnt = 0; for (i = 0; i < n; i++) ...
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the secon...
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≤ a ≤ n - 1, 0 ≤ b ≤ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
4af571fabeee081b4fffb99fb5eec68a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "constructive algorithms", "greedy", "graphs" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal — as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≤ degreei ≤ n - 1, 0 ≤ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #define ll long long int ll pt1[200009],pt2[200009]; void sort(ll l,ll r) { if(l>=r) return; ll mid=l+(r-l)/2; sort(l,mid); sort(mid+1,r); ll left1[200009],left2[200009],lc=0; ll right1[200009],right2[200009],...
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the secon...
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≤ a ≤ n - 1, 0 ≤ b ≤ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
418dc9e787f77dd614e0c7ea4ba44e72
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "constructive algorithms", "greedy", "graphs" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal — as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≤ degreei ≤ n - 1, 0 ≤ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> typedef long long int ll; #define MAX 65540 #define MAXQ 10000000 typedef struct { ll val; ll deg; ll xor; ll skip; } node; typedef struct { ll n1, n2; } edge; node* qu[MAXQ]; ll top = -1; void push(node* val){ qu[++...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
01c8142f80dbaf6d51a0669a2c093d50
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main(){ long long int a,b,c,d; long long int time; int t; scanf("%d",&t); while(t--){ scanf("%lld%lld%lld%lld",&a,&b,&c,&d); if(b>=a){ printf("%d\n",b); } else{ if(c>d){ if((a-b)%(c-d)==0) { time=b+((a-b)/(c-d))*c; printf("%lld\n",time); } ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
f5bffdba425c849ac41500bf4f57fcbd
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> #include<stdlib.h> #include<limits.h> #include<math.h> void solution(void); int main() { int t; scanf(" %d",&t); while((t--)>0) { solution(); } return 0; } void solution(void) { long long int a,b,c,d; scanf(" %lld %lld %lld %lld",&a,&b,&c,&d); long long int sleep=0,curr_sleep=c-d,time=0;...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
73887d2045e58102eb54ee1ac8f5718c
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include <stdio.h> #include <stdlib.h> #include <limits.h> #include <math.h> int main (int argc, char *argv[]) { int t; scanf("%d",&t); while (t--) { long long int a,b,c,d; scanf("%lld%lld%lld%lld",&a,&b,&c,&d); long long int time; time =0; a-=b; time=b; if (a<=0) { printf("%lld\n",time); cont...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
4b7fa4fa7b3c904bea524fe52b3d7b25
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include <stdio.h> #include <math.h> #define max(a,b) (a>b)?a:b; int main() { long long t,a,b,c,d; scanf("%lld",&t); while(t--) { scanf("%lld %lld %lld %lld",&a,&b,&c,&d); a=max(0,a-b); if(a>0 && c<=d) printf("-1\n"); else if(a==0) printf("%lld\n",b); else { int p=ceil(a*1.0/(c-d)); printf("%lld...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
b7be449a906fe4cb14ebc3660920ffe6
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> #include<math.h> int main() { long long a, b, c, d, to_time = 0; int x; int T; scanf("%d",&T); while(T--) { scanf("%lld %lld %lld %lld", &a, &b, &c, &d); if(a <= b) printf("%lld\n",b); else { if(c <= d) printf("-1\n"); el...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
79fc785be2ea9362ccf91e18241e0016
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include <stdio.h> int main(){ int t; scanf("%d", &t); while (t--){ int a, b, c ,d; scanf("%d %d %d %d", &a, &b, &c, &d); long long ans; if (b >= a){ ans = b; } else if (c - d <= 0){ ans = -1; } else{ long l...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
e137cdf57d520acb707e263838801ca8
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main() { int t,i; scanf("%d",&t); for(i = 1; i <= t; i++) { int a,b,c,d; long long int s,l,m,f; scanf("%d %d %d %d",&a,&b,&c,&d); s = a - b; l = b; m = c - d; if(b < a) { if(c > d) { ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
3378b2f58e2ae4acb31369dbe9c4cd11
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
// 题二.c.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <stdio.h> #include<stdio.h> #include<string.h> int main() { long long t; long long n, a, b, c, d,flag; scanf("%lld", &n); while (n--) { scanf("%lld %lld %lld %lld", &a, &b, &c, &d); if (a <= b) { printf("%lld\n", b); //t = b; continue; ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
96186e58144345b351bab7f4ef527cb4
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main() { long long unsigned i,a,b,c,f,n,m,s,t; long long int d; double e; scanf("%llu",&t); for(i=1;i<=t;i++) { scanf("%llu%llu%llu%llu",&n,&a,&b,&c); if(n>a) { s=(n-a); d=(b-c); if(d<0 || d==0) ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
7a53686684e2d959045ea7f380d54a2d
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> #define ll long long int main() { int t; scanf("%d",&t); while(t--) { ll int a,b,c,d,temp,t2; scanf("%lld %lld %lld %lld",&a,&b,&c,&d); ll int total=0; ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
889a94c7454f5b9464c800d75ad58f70
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include <stdio.h> int main() { long long table[1000][4]; long long m, s, r, k; scanf("%lld", &m); for( int i = 0; i < m; ++i) scanf("%lld %lld %lld %lld", &table[i][0], &table[i][1], &table[i][2], &table[i][3]); for( int i = 0; i < m; ++i) { k = table[i][0] - table[i][1]; ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
b49f74304babfce8f8a9a7ed675144a7
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main(){ int t, a, b, c, d; long long e; scanf("%d", &t); while(t--){ scanf("%d%d%d%d", &a,&b,&c,&d); if(a <= b) printf("%d\n", b); else{ if(c <= d) printf("-1\n"); else{ e = b + (long long)c * ((a-b)/(c-d)+ ((a-b)%(c-d)!= 0)); printf("%lld\n", ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
846edb776342b197e9bda0c9ea5ec20b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main() { int a,i,j; scanf("%d",&a); for(i=0;i<a;i++) { long long int A,B,C,D,E,F,H=0; scanf("%lld %lld %lld %lld",&A,&B,&C,&D); if(A>B && C<=D) printf("-1\n"); else { if(A<=B) printf("%lld\n",B); else {...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
9f98ccb1b5939c0b38024aa3881409cf
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main(){ int i,t; scanf("%d",&t); for(i=1;i<=t;i++){ long long a,b,c,d; long long res,k,mid; scanf("%lld %lld %lld %lld",&a,&b,&c,&d); if(a<=b) res=b; else{ k=c-d; if(k<=0) res=-1; else{ mid=(a-b)/k; if(mid*k<a-b) mid++; res=(mid*c)+b; } } print...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
c8fc277e888ed3924903e288cd12cf6e
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> #include<string.h> int main() { int n; long long int a,b,c,d; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%lld%lld%lld%lld",&a,&b,&c,&d); if(a<=b) { printf("%lld\n",b); continue; } else { if(c<=d)...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
23bec9da3eb72c7f37e0f8e3b947f627
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main(){ long long int t,a,b,c,d,val,res,k; scanf("%lld",&t); while(t--){ scanf("%lld %lld %lld %lld",&a,&b,&c,&d); if(a<=b){ k=b; } else if(c<=d){ k = -1; } else if(a>b){ val=(a-b)%(c-d); ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
be4fa59c4027123fb3df6241e67275b1
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include <stdio.h> #include <math.h> int main () { int t; scanf ("%d", &t); while (t--) { long long a, b, c, d, s; scanf ("%lld%lld%lld%lld", &a, &b, &c, &d); if (b < a && d >= c) { s = -1; } else { s = b; if (b < a) { s += ceil ( (a - b) / (double) (c - d) ) * c; } } printf("%lld\n",...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
fd535f11222a21c39357512ed5e5e929
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main(){ long long int t,a,b,c,d,m=0,k=0,i; scanf("%lld",&t); for(i=0;i<t;i++){ scanf("%lld%lld%lld%lld",&a,&b,&c,&d); if(b>=a){ printf("%lld",b); } else{ if(d>=c){ printf("-1"); } else{ ...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
4db671b980e5468937a495137248f4ca
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include<stdio.h> int main() { long long int a,b,c,d,k; int i,n; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%lli%lli%lli%lli",&a,&b,&c,&d); if(b>=a) { printf("%lli\n",b); } else { if(c<=d) { printf("-1...
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ...
For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed.
C
1ab174688ba76168ca047ed2b06b0670
022b26bd71f63fa18fb4eb38d18ccf10
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "math" ]
1589707200
["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"]
NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle...
PASSED
900
standard input
2 seconds
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every...
["27\n27\n9\n-1\n1\n6471793\n358578060125049"]
#include <stdio.h> int main() { int t; scanf("%d", &t); while(t--) { long long a, b, c, d; scanf("%lld%lld%lld%lld", &a, &b, &c, &d); if(b >= a) { printf("%lld\n", b); continue; } else { if(d >= c) {...