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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 02433b15b2f6e1ec1eb7f2c474b407e4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
int main()
{
int h, w;
scanf("%d %d", &h, &w);
int i, j;
int r[1003], c[1003];
for (i = 0; i < h; i++)
scanf("%d", &r[i]);
for (i = 0; i < w; i++)
scanf("%d", &c[i]);
int s[1003][1003];
for (i = 0; i < h; i++)
for (j = 0; j < w; j++)
s[i][j] = 0;
for (i = 0; i < h; i++)
{
for (j =... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | a9dc1a22dcf09d3a63561187a796514f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
int main()
{
int h,w;
scanf("%d %d",&h,&w);
long long int ways=1;
int i,j,r[h],c[w];
for(i=0;i<h;i++)
scanf("%d",&r[i]);
for(i=0;i<w;i++)
scanf("%d",&c[i]);
for(i=0;i<w;i++)
{
for(j=0;j<h;j++)
{
if(i+1>r[j]+1)
{
if(j+1>c[i]+1)
{
ways*=2;
ways=ways%1000000007;
... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 0df7caa685b7d3f559de33871821448d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
long long BP(long long a, long long b, long long p)
{
long long r = 1;
while (b)
{
if (b & 1)
{
r *= a;
r %= p;
}
a *= a;
a %= p;
b >>= 1;
}
return r;
}
int H[1001];
int W[1001];
int main()
{
int i, j;
... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 55eef044ad138bf1f9106f71243656b2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | /* AUTHOR:AKASH JAIN
* USERNAME:akash19jain
* DATE:06/10/2019
*/
/*#include<algorithm>
#include <bits/stdc++.h>
using namespace std;*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
#define SC1(x) scanf("%lld",&x)
#define SC2(x,y) ... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | dad2a16de13ad824ff4c08b7f77aed85 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | a[1111], b[1111], f[1111][1111], p = 1e9 + 7, aa;
pw(x, y) {
int r = 1;
for (; y; y >>= 1, x = 1ll * x * x % p)
if (y & 1) r = 1ll * r * x % p;
return r;
}
main(n, m, i, j) {
memset(f, -1, sizeof f);
scanf("%d%d", &n, &m);
for (i = 1; i <= n; i++) {
scanf("%d", a + i);
for (j = 1; j <= a[i]; j++) {
if (f... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 0ebf0094824f30d917a659510bddfa66 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
#include <math.h>
int R,C,i,j,x=0;
int ans=1;
int r[1001]={0},c[1001]={0},a[1002][1002]={0};
int main(int argc, char *argv[]) {
scanf("%d%d",&R,&C);
for(i=1;i<=R;i++){
scanf("%d",&r[i]);
for(j=1;j<=r[i];j++) a[i][j]+=2;
a[i][r[i]+1]+=1;
}
for(i=1;i<=C;i++){
scanf("%d",&c[i]);
for(j=1;j<... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 7ae527d7197ba293d9c72e0e9bcf1567 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int main() {
int h,w;
scanf("%d",&h);
scanf("%d",&w);
int flag=1;
int mat[h][w];//w-количесвто столбцоы h количесвто строк
//-1неопределенный цвет 0 белый 1-черный
for (int i=0;i<w;i++){
for (int j=0;j<h;j++){
mat[j][i]=-1;
}
}
int el... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | ab0096b2f883b23f5762b176d7bbbe9d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int main()
{
int i, j, k, l, h, w, num;
long long int possibility = 1;
scanf("%d %d", &h, &w);
int grid[h][w];
for (i=0; i<h; i++) {
for (j=0; j<w; j++) {
grid[i][j] = 2;
}
}
for (i=0; i<h; i++) {
scanf("%d", &num);
for (j=... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 03ba27873772a5342cc2ab1ce7ff3ae7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
#define N 1000000007
#define M 1000
long long power(int a, int b){
long long c=1;
for (int i=0; i<b; i++){
c*=a;
if (c>N) c%=N;
}
return c;
}
long long answer(const int *r, const int *c, int h, int w, int matr[][M]){
for (int i=0; i<h; i++){
for (int j=0;... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 4ffc1abe6e091e07d89af9e32af33491 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int main(void) {
int h,w;
scanf("%d %d\n", &h, &w);
int he[1000];
int we[1000];
for(int i=0;i<h;i++) {
scanf("%d ", &he[i]);
}
scanf("\n");
for(int i=0;i<w;i++) {
scanf("%d ", &we[i]);
}
int grid[1000][1000];
for(int i=0;i<1000;i++) {
... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 822a29999204fc2d5a47666554ee9a2f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int main(void) {
int h,w;
scanf("%d %d\n", &h, &w);
int he[1000];
int we[1000];
int grid[1000][1000];
for(int i=0;i<1000;i++) {
for(int j=0;j<1000;j++) {
grid[i][j]=0;
}
}
for(int i=0;i<h;i++) {
scanf("%d ", &he[i]);
}
scanf... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | b31f019ceddf4a7e01afb316caf8c674 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <limits.h>
typedef long long ll;
ll MAX = 100000000000; // 1e11
ll MIN = -100000000000; // -1e11
ll MOD = 1000000007;
ll longlongmax = __LONG_LONG_MAX__;
ll maxormin(ll a,... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 32c613c357d6b9ca4a04561efb2027eb | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int ar[1000][1000];
int main()
{
int r, c;
r = 0;
while (r < 1000)
{
c = 0;
while (c < 1000)
{
ar[r][c] = 0;
c++;
}
r++;
}
int flag = 1;
scanf("%d %d", &r, &c);
int i = 0;
int rr[r], cc[c];
while... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | a759b959f9143f0a290d40909c794ab8 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
#include<string.h>
char grid[1000][1000];
int main(){
int w, h, i, j, curr;
const long long mod=1000000007;
long long moznosti=1;
memset(grid, -1, sizeof(grid));
scanf("%d %d", &w, &h);
for(i=0;i<w;++i){
scanf("%d", &curr);
for(j=0;j<curr;++j){
grid[i][j]=1;
}
if(curr!=h) grid[i][cu... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | b87a37dd44b314c7df61c43472afb310 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
#define N 1001
#define M 1000000007
int main(){
char grid[N][N];
int i,j;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
grid[i][j]=0;
}
}
int h,w;
scanf("%d%d",&h,&w);
int r[N];
int c[N];
for(i=0;i<h;i++){
scanf("%d",&r[i]);
}
for(i... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | c7802982348063c1cc8e7257820f8eec | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
int main(){
long long int h,w,sum=0,count=0,product=1,j,i,arr[10001],row[10000],col[10000],p=1000000007;
scanf("%lld%lld",&h,&w);
for(i=0;i<h;i++){
scanf("%lld",&row[i]);}
for(i=0;i<w;i++){
scanf("%lld",&col[i]);}
for(i=0;i<h;i++){
if(row[i]==0){
if(col[0]>i)
count++;}
if(row[i]!=0){... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 5da41514fd94ad556dd1c0a2f4171271 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define MOD 1000000007
int main()
{
int h,w;
scanf("%d %d",&h,&w);
int mat[h][w];
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
mat[i][j] = -1;
}
int r[h];
int c[w];
for(int i=0;i<h;i++... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 178685dd315460430ebcb8976d999176 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int main()
{
int i, j, k, l, h, w, num;
long long int possibility = 1;
scanf("%d %d", &h, &w);
int grid[h][w];
for (i=0; i<h; i++) {
for (j=0; j<w; j++) {
grid[i][j] = 2;
}
}
for (i=0; i<h; i++) {
scanf("%d", &num);
for (j=... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 7d294521bb42e1aa54904260a4841919 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
#define MOD 1000000007
int grid[1003][1003], w, h, r[1003], c[1003];
int sol(){
int i, j;
for(i = 0;i < h;i++)for(j = 0;j < w;j++)grid[i][j] = -1;
for(i = 0;i < h;i++){
for(j = 0;j < r[i];j++)grid[i][j] = 1;
if(j < w)grid[i][j] = 0;
}
for(j = 0;j < w;j++){
for(i = 0;i < c[j];i... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | b8d27a232ba5e646a70c43c3633c618d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int main() {
int h,w,i,m,p,n=0,q=1000000007;
long long s=1;
scanf("%d %d",&h,&w);
int k[h][w],r[h],c[w];
for (i=0;i<h;i++) {
scanf("%d",&r[i]);
}
for (i=0;i<w;i++) {
scanf("%d",&c[i]);
}
for (m=0;m<h;m++) {
for (i=0;i<w;i++) {
k[m][i]=2;
}
}
for (m=0;m<h;m++) {
p=r[m];
fo... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 3ce1d9c186f2a3ac9295669b7abdd28f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int main ()
{
long long int h, w, i, k, j = 0, c, num =1, f = 0;
char d = 'c';
scanf("%lld%lld", &h, &w);
long long int a[1000][1000] = {0};
while(d != '\n')
{
scanf("%lld",&c);
for(k = 0; k < c; k++)
{
a[j][k] = 1;
}
... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | a4c6721ad322fb93143def1f6e8fa5df | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | //
// Created by Pulak on 29-09-2019.
//
// r verified is 0 + 1 = 1
//danger zone of r 0 + 4 = 4
// c verified is 0 + 1 = 1 or 1 + 1 = 2
//danger zone of c 0 + 4 =4, 4 + 4 = 8,
#include <stdio.h>
#include <string.h>
void print_matrix(int a[4][4], int h, int w) {
printf("\n");
for (int k = 0; k < h; ++k) {... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | fb9d94bd619a96c5f86bf1d3b7aadb6d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
long long int power(long long x, long long int y, long long int p)
{
long long int res = 1; // Initialize result
x = x % p; // Update x if it is more than or
// equal to p
while (y > 0)
{
... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 1c12173b9a414713bd596a51b19c0f8b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
main()
{
int h, w, i, j, cn=0;
scanf("%d%d",&h,&w);
int r[h+1], c[w+1];
for(i=1;i<=h;i++)
{scanf("%d",&r[i]); r[i]++;}
for(i=1;i<=w;i++)
{scanf("%d",&c[i]); c[i]++;}
for(i=1;i<=w;i++)
{
for(j=1;j<=h;j++)
{
if(c[i]==j && r[j]>i){... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 68b99158f65faa8f47035e2f2cb25ccb | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | /*
* author : anaksoleh
* 12 okt 2019
* link problem : https://codeforces.com/problemset/problem/1228/B
*/
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
typedef long long ll;
#define max(a,b) (a > b ? a : b)
#define min(a,b) (a < b ? a : b)
#define getI(a) scanf("%d",&a)
const int N = 1e9 + 7;
int ... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 6aa8c9ebd5131d24a7d163fb8051fda0 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
int main() {
int i, j, count = 0;
int m, n;
scanf("%d %d", &m, &n);
int r[m], c[n], a[m + 1][n + 1];
for(i = 0; i <= m; i++){
for(j = 0; j <= n; j++)
a[i][j] = 0;
}
for(i = 0; i < m; i++){
scanf("%d", &r[i]);
a[i][r[i]] = 1;
}
fo... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 489f77b5a5171a9a814b270860029fdf | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include<stdio.h>
#include<math.h>
long long int N=1e9+7;
int main()
{ long long int h,w,i,j,k=0,l,m=1;
scanf("%lld %lld",&h,&w);
long long int row[h+1];
long long int col[w+1];
for(i=1;i<=h;i++)
{scanf("%lld",&row[i]);}
for(i=1;i<=w;i++)
{scanf("%lld",&col[i]);}
col[0]=0;
row[0]=0;
for(i=1;i<=h;i++)
... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 78011d9c66bf017490986249e7688668 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
int main()
{
int h,w;
scanf("%d%d",&h,&w);
int arh[h];
for(int i=0;i<h;i++)
scanf("%d",&arh[i]);
int arw[w];
for(int i=0;i<w;i++)
scanf("%d",&arw[i]);
int ar1[h][w];
int ar2[h][w];
int temp;
for(int i=0;i<h;i++)
{
int flag=0;
if(arh[... | |
Suppose there is a $$$h \times w$$$ grid consisting of empty or full cells. Let's make some definitions: $$$r_{i}$$$ is the number of consecutive full cells connected to the left side in the $$$i$$$-th row ($$$1 \le i \le h$$$). In particular, $$$r_i=0$$$ if the leftmost cell of the $$$i$$$-th row is empty. $$$c_{j}$... | Print the answer modulo $$$1000000007\,(10^{9} + 7)$$$. | C | 907f7db88fb16178d6be57bea12f90a2 | 8725e881d38fc1a8a3fb3bd7f29dd425 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1569762300 | ["3 4\n0 3 1\n0 2 3 0", "1 1\n0\n1", "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4"] | NoteIn the first example, this is the other possible case. In the second example, it's impossible to make a grid to satisfy such $$$r$$$, $$$c$$$ values.In the third example, make sure to print answer modulo $$$(10^9 + 7)$$$. | PASSED | 1,400 | standard input | 1 second | The first line contains two integers $$$h$$$ and $$$w$$$ ($$$1 \le h, w \le 10^{3}$$$) — the height and width of the grid. The second line contains $$$h$$$ integers $$$r_{1}, r_{2}, \ldots, r_{h}$$$ ($$$0 \le r_{i} \le w$$$) — the values of $$$r$$$. The third line contains $$$w$$$ integers $$$c_{1}, c_{2}, \ldots, c_{w... | ["2", "0", "797922655"] | #include <stdio.h>
#include <string.h>
const int P = 1e9 + 7;
int r[1003], c[1003], a[1003][1003];
int main()
{
int n, m, i, j;
memset(a, -1, sizeof(a));
scanf("%d%d", &n, &m);
for (i = 0; i < n; ++i) {
scanf("%d", &r[i]);
for (j = 0; j < r[i]; ++j) a[i][j] = 1;
a[i][r[i]] = 0;
}
for (i = 0; i < m; ++i)... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | a7a6ce19278287e0e19ea966cc15d08d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 100
int main()
{
int m,n,i,j,total,mult;
char skill[MAX<<2][MAX],decimal[MAX],temp[MAX];
int level[MAX],crap;
scanf("%d%d %s",&n,&m,decimal);
mult=atoi(decimal+2);
for(i=0;i<n;i++){
scanf(" %s%d",skill[i],&level[i]);
leve... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | 20554d2818a85ffcca429b59905848a5 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char s[21];
int num;
} skill;
int cmp(const void *a, const void *b)
{
return strcmp(((skill *)a)->s, ((skill *)b)->s);
}
int main()
{
int n, m, k, z = 0, i, j;
char s1[20][21], s2[20][21];
int a[20];
skill ... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | fd56e0503a3cc14b148ae1142d5822a1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include<stdio.h>
#include<string.h>
int main(){
char res[41][30],tmp[30],k[10];
int value[41],v,i,j,n,m,s,count,check,K;
scanf("%d%d%s",&n,&m,k);
K=(k[2]-'0')*10+k[3]-'0';
for(i=0,j=0;i<n;i++){
scanf("%s%d",tmp,&v);
s=v*K/100;
if(s>=100){
strcpy(res[j],tmp);
... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | 5c18818598956996fe0e4c5fc3577d6b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int n, m, val[41];
char str[41][22];
void sort(void){
int i, j, q;
char s[22];
for (i = 1; i < n + m; i++){
for (j = n + m - 1; j >= i; j--){
if (strcmp(str[j], str[j - 1]) != 1){
strcpy(s, s... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | b5cd22c99afa4930cf8e779335d5fbe8 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include<stdio.h>
#include<string.h>
#include<Stdlib.h>
int n,m,skill_level[100],var_count=0;
double k;
char variables[100][100],**to_sort;
int compare(const void *a, const void *b){
const char **ia = (const char **)a;
const char **ib = (const char **)b;
return strcmp(*ia, *ib);
}
int get_var_num(char *... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | 77a06ca775a83124db9bf3f3e81bf50d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
typedef long long ll;
typedef struct{
char name[99];
int pt;
int use;
} ability;
int cmp(const void *a1, const void *a2){
ability ab1 = *(ability*)a1;
ability ab2 = *(ability*)a2;
... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | c2b9d8bbebce6221d90984ee55896110 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
char a[48][32];
int v[48];
int n,m,k;
int idx[48];
int cmp(const void *t1,const void *t2) {
return strcmp(a[*(int *)t1],a[*(int *)t2]);
}
int main() {
int i,j;
double p;
scanf("%d %d %lf",&n,&m,&p);
k=(int)floor(p*100+1e-12);
for(i=0;i<n;... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | 4c20484ae457f880a336af8714dbb6b9 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXN 55
struct node
{
char s[MAXN];
int a;
};
void sort (struct node a[MAXN], int l, int r)
{
int i, j;
struct node x, y;
i = l; j = r; x = a[(l+r)/2];
while (i <= j)
{
while (strcmp(a[i].s, x.s) < 0) i++;
while (strcmp(a[j].s, x.s) > 0) j-... | |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | Print on the first line number z — the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | C | 7da1a5c4c76540e1c7dc06e4c908c8b4 | c0a06c510d28352f9366bb002200a6b5 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1313247600 | ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"] | null | PASSED | 1,700 | standard input | 2 seconds | The first line contains three numbers n, m and k — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal p... | ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"] | #include <stdio.h>
#include <string.h>
struct case1
{
char str[25];
int v;
}p[45];
char str[25];
int main()
{
struct case1 t;
int i,j,n,m;
double k;
scanf("%d%d%lf",&n,&m,&k);
for (i=1;i<=n;i++)
{
scanf("%s%d",p[i].str+1,&p[i].v);
p[i].v=p[i].v*k+1e-8;
if (p[i].v<100)
{... | |
This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of n computers, some of them are... | In a single line print the network topology name of the given graph. If the answer is the bus, print "bus topology" (without the quotes), if the answer is the ring, print "ring topology" (without the quotes), if the answer is the star, print "star topology" (without the quotes). If no answer fits, print "unknown topolo... | C | 7bb088ce5e4e2101221c706ff87841e4 | 7da0fefcdd349bf0ab11c3eb69bb2c72 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"graphs"
] | 1366040100 | ["4 3\n1 2\n2 3\n3 4", "4 4\n1 2\n2 3\n3 4\n4 1", "4 3\n1 2\n1 3\n1 4", "4 4\n1 2\n2 3\n3 1\n1 4"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two space-separated integers n and m (4 ≤ n ≤ 105; 3 ≤ m ≤ 105) — the number of nodes and edges in the graph, correspondingly. Next m lines contain the description of the graph's edges. The i-th line contains a space-separated pair of integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of nodes that ... | ["bus topology", "ring topology", "star topology", "unknown topology"] | #include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)<(b))?(a):(b)
#define si(n) scanf("%d",&n)
#define ss(s) scanf("%s",s)
#define sort(a,n) qsort(a,n,sizeof(int),compare)
#define pi(n) printf("%d ",n)
#define ps(s) printf("%s",s)
#define loop... | |
This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of n computers, some of them are... | In a single line print the network topology name of the given graph. If the answer is the bus, print "bus topology" (without the quotes), if the answer is the ring, print "ring topology" (without the quotes), if the answer is the star, print "star topology" (without the quotes). If no answer fits, print "unknown topolo... | C | 7bb088ce5e4e2101221c706ff87841e4 | 08aadef8b671cd2c8aa7867d6e1889ae | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"graphs"
] | 1366040100 | ["4 3\n1 2\n2 3\n3 4", "4 4\n1 2\n2 3\n3 4\n4 1", "4 3\n1 2\n1 3\n1 4", "4 4\n1 2\n2 3\n3 1\n1 4"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line contains two space-separated integers n and m (4 ≤ n ≤ 105; 3 ≤ m ≤ 105) — the number of nodes and edges in the graph, correspondingly. Next m lines contain the description of the graph's edges. The i-th line contains a space-separated pair of integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of nodes that ... | ["bus topology", "ring topology", "star topology", "unknown topology"] | #include <stdio.h>
#include <stdlib.h>
int max(int a, int b)
{
if (a > b)
return a;
else
return b;
}
int main(void)
{
int n, m, i, s, f;
scanf("%d%d", &n, &m);
int a[n];
for (i = 0; i < n; i++)
a[i] = 0;
for (i = 0; i < m; i++)
{
scanf("%d%d", &s, &f);
a[s - 1]++;
a[f - 1]++;
}
s = 0;
f = 0;
f... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | 959ed4add011e21881fab40a8975bc22 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
long long test,i,j,k,*arr,*array,box,tot,max,g;
scanf("%lld",&test);
arr=(long long*)malloc(sizeof(long long)*test);
for( i=0;i<test;i++)
{ scanf("%lld",&box);tot=0;max=0;
array=(long long*)malloc(sizeof(long long)*box);
for(j=0;j<box;j++)
... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | d7555169ed3e867f70ff0d75f672fc79 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include<stdio.h>
long long a[100010];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long n;
long long max=0,min=1e9;
scanf("%lld",&n);
for(int i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
if(max<a[i]) max=a[i];
if(min>a[i]) min=a[i];
}
long long sum=0;
for(int i=1;i<=n;i++)
{
sum+=... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | 042f6df23f5bea270cf7a3a8a92ec674 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <inttypes.h>
typedef int64_t int64; typedef int32_t int32;
typedef uint64_t uint64; typedef uint32_t uint32;
#define in(i,bit) scanf("%"PRId##bit"",&i)
#define uin(i,bit) scanf("%"PRIu##bit"",&i)
#define out(i,bit,c) printf("%"PRId##bit"%c",i,c)
#define uout... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | 41721b200e3bf8fda16871ef9a056137 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include <stdio.h>
long long max(long long a, long long b) { return a > b ? a : b; }
int comp(const void* a, const void *b){
return *(long long *)a - *(long long *)b;
}
int main()
{
int x,y,z,i,j,k,b,c,n,m,t;
scanf("%d",&t);
long long sum,res,s,mat[100100];
while(t--)
{
res =... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | 9fb8e5d1507a748713f767c8a6b5cdf3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include<stdio.h>
int main(int argc, char *argv[])
{
long long int a,i,b,c,d,e,j,f,g,y;
scanf("%lld",&a);
for(i=0;i<a;i++){
d=0;
scanf("%lld",&b);
long long int x[b];
for(j=0;j<b;j++){
scanf("%lld",&x[j]);
d=d+x[j];
if(j==0)
e=x[j];
else{
if(e<x[j])
e=x[j];}}
f=b-1;
if(b<=2)
printf("%lld\... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | 16ecaff1a752bfa3d3272797d168dc17 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include<stdio.h>
int main(){
int t;
scanf("%d",&t);
while(t--){
long long int i,n,a,j,k,ans=0,b=-1;
scanf("%lld",&n);
for(i=0;i<n;i++){
scanf("%lld",&a);
b=a>b?a:b;
ans+=a;
}
j=ans/(n-1);
k=ans%(n-1);
if(k!=0)j++;
for(;1;){
if(j>=b)break;
j++;
}
printf("%lld\n",j*(n-1)-ans);
}
} | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | c698d9554939c59185069e688b129401 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include <stdio.h>
#include <math.h>
#include <string.h>
int max(int a,int b)
{
if(a>b)
return a;
else
return b;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long n,sum=0,mas=-1;
scanf("%lld",&n);
for(long long i=0;i<n;i++)
{
long long x;
scanf("%lld",&x);
mas=max(mas,x);
sum+=... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | f5ec0384b2b7f66fb33e3dffb6905846 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include<stdio.h>
#include<math.h>
#define MAXSIZE 100001
long long Max(long long a, long long b);
int main(int argv, char* argc[])
{
int n;
scanf("%d", &n);
while (n--)
{
long long boxs, blocks[MAXSIZE];
long long averge, sum = 0;
long long max=0, least;
scanf("%lld", &boxs);
for (int i = 0; i < boxs... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | b735cbb3fec97a8681e8ab9dd1dfb79b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include <stdio.h>
typedef long long int lli;
lli d[100005];
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n;
scanf("%d", &n);
lli sum = 0, maxv = 0;
for(int i = 0; i < n; i++)
{
scanf("%I64d", &d[i]);
sum += d[i];
if... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | fd002f15bf699aff0986c33012a4630e | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include <stdio.h>
typedef long long int lli;
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n;
scanf("%d", &n);
lli sum = 0, maxv = 0, tmp;
for(int i = 0; i < n; i++)
{
scanf("%I64d", &tmp);
sum += tmp;
if(tmp > maxv)
... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | a374dd59eaaf109373200c9d27be2aa2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include<stdio.h>
#include<string.h>
//#include<stack>
//#include<queue>
//#include<algorithm>
//using namespace std;
long long i,t,n,flag,x,y,sum=0,ans=0,a[200100],min,max;
//char a;
//priority_queue<long long,vector<long long>,greater<long long> >s;
int main(){
scanf("%lld",&t);
while(t--){
scanf("%lld",&n);... | |
You are asked to watch your nephew who likes to play with toy blocks in a strange way.He has $$$n$$$ boxes and the $$$i$$$-th box has $$$a_i$$$ blocks. His game consists of two steps: he chooses an arbitrary box $$$i$$$; he tries to move all blocks from the $$$i$$$-th box to other boxes. If he can make the same num... | For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite. | C | e75b88ce4341062c20b6014da1152d29 | becea0ba6d248981b5437ae4e6860fc6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"sortings",
"greedy",
"math"
] | 1605796500 | ["3\n3\n3 2 2\n4\n2 2 3 2\n3\n0 3 0"] | NoteIn the first test case, you can, for example, put one extra block into the first box and make $$$a = [4, 2, 2]$$$. If your nephew chooses the box with $$$4$$$ blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with $$$2$$$ blocks then he will move these two... | PASSED | 1,400 | standard input | 2 seconds | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of boxes. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^... | ["1\n0\n3"] | #include <stdio.h>
#include <stdlib.h>
int mod(int a)
{
if(a<0)
return(-a);
else
return(a);
}
int main()
{
int t;scanf("%d",&t);
while(t--)
{
int n;scanf("%d",&n);long long int k,z,sum=0,max=0, a[n],j;for(j=0;j<n;j++)scanf("%lld",(a+j));k=n;
for(j=0;j<n;j++)
{... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 013539354c709743dc964a53c5361930 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int a,b,k,temp;
scanf("%d %d",&a,&b);
if(a>b){temp=a;a=b;b=temp;}
k=b-a;
if(k>0)
{
int f,t,o;
f=k/5;
t=(k%5)/2;
o=((k%5)%2)/1;
printf("%d\n",f+t+o);
}
else if(k==0)
{
printf("0\n");
}
}
return 0;
} | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 71d125413077a319f502b20638e245c4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
#include <stdlib.h>
int vol(){
int a,b,s=0;
scanf("%d %d",&a,&b);
if(a<b){
if((b-a)>=5)
s=(b-a)/5;
if((b-a)%5==4 || (b-a)%5==3)
s+=2;
else if((b-a)%5==2 || (b-a)%5==1)
s++;
}
else if(a>b){
if((a-b)>=5)
s=(a-b)/5;
if((a-b)%5==4 || (a-b)%5==3)
s+=2;
else if((a-b)%5==2 |... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 9551fb170f517b4669c497c54d44d4de | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
long long int abs(long long int a)
{
if(a<0) return -a;
return a;
}
int m(int a,int b)
{
if(a>b) return b;
return a;
}
int main()
{
int but[6]={-5,-2,-1,1,2,5};
int cmd;
long long int a,b,goal,init=0,ways[6]={0,1,1,2,2,1};
scanf("%d",&cmd);
for(int i=0;i<cmd;i++)
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 16d974830e2d4dab69d6993f456a0f9b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
#include <math.h>
void fungsi(int d)
{
int sum=0;
if(d>=5)
{
sum += d/5;
d=d-((d/5)*5);
}
if(d>=2)
{
sum += d/2;
d=d-((d/2)*2);
}
if(d>=1)
{
sum += d;
}
printf("%d\n", sum);
}
int main (void)
{
int i,j,k,l;
int z;
scanf("%d", &k);
while(k--)
{
scanf("%d %d",&i,&j);
z= a... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | bb3bcc54de699c79ea1284db40d932ba | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
int a,b,n,c,d,e,f,x,y,t;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d %d",&a,&b);
if(a>b)
{
t=a-b;
if(t>=5)
{
x=t/5;
y=t%5;
if(y>=2)
{
c=y/2;
d=y%2;
printf("%d\n",x+c+d);
}
if(y<2)
printf("%d\n",x+y);
}
if(2<=t&&t<5)... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 76d69df16741a79d78ad5890ad2add44 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
#include<math.h>
int main()
{
long long int t,a,b,d,count;
scanf("%lld",&t);
while(t--)
{
d=0,count=0;
scanf("%lld%lld",&a,&b);
if(a>b)
d=a-b;
else if(a<b)
d=b-a;
else
{
printf("%d\n",count);
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 79fffce5db3312d61bc218c5047345e8 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main ()
{
int t;
scanf("%d",&t);
while(t--)
{
long int a,b,c,d,e,x;
long long m=10000000000000;
scanf("%ld %ld",&a,&b);
if(a==b)
printf("0\n");
else
{
c=b-a;
x=abs(c);
if(x==1)
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | c7a20c996d04d6c04ed0467348856cdf | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,x=0;
scanf("%d%d",&a,&b);
if(a>=b)
{
while(a!=b)
{
if(a-b>=5)
{
x+=(a-b)/5;
a-=((a-b)/5)*5;
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | fd035a911d097323495987ca57d20822 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,c,d,e,n,sum;
scanf("%d",&n);
for(c=0;c<n;c++)
{
sum=0;
scanf("%d%d",&a,&b);
d=abs(a-b);
for(;d>0;)
{
if(d>4)
{
e=d/5;
d=d%5;
sum+=e;
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 0838a5fd9d42c08f0caeb72ca18cc102 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
int t;
int a,b,c=0,i;
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d%d",&a,&b);
if(a<b){
a=a+b;
b=a-b;
a=a-b;
}
c=(a-b)/5+(a-b)%5/2+(a-b)%5%2;
printf("%d\n",c);
}
}
| |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | ea82e38e953feb3f992c37698ec691c6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
int tc;
scanf("%d",&tc);
while(tc--)
{
int a,b,subs,sum1=0,sum2=0,sum3=0,sum=0;
scanf("%d %d",&a,&b);
subs=a-b;
if(subs<0)
{
subs=subs*(-1);
}
if(subs>=5)
{
sum1=subs/5;
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 7978ab43880cd6070af27c78ee8d2d51 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,n,c,t,i;
scanf("%lld",&t);
for(i=1;i<=t;i++)
{
c=0;
scanf("%lld %lld",&a,&b);
n=fabs(a-b);
c=c+n/5;
n=n%5;
c=c+n/2;
n=n%2;
if(n==1)
{
c=c+1;
}
printf("%lld\n",c);
}
return 0;
}
| |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 2522cf7d2023445a9e2b6d2bd1a7d7bd | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,c,d,i,j,sum=0,r,x=0;
scanf("%d",&a);
while(a--)
{ sum=0;
scanf("%d %d",&b,&c);
j=abs(b-c);
if(j==5 || j==2 || j==1)
{
printf("1\n");
}
else if(j>5)
{
sum=sum+(j/5);... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 5ab707c9a6e15053091a05de38940caa | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] |
#include <stdio.h>
int main()
{
int n, a,b,d,k,r,i;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d %d",&a, &b);
if(a<b)d=b-a; else d=a-b;
k=d /5;
r=d%5;
if(r==1) k++;
if(r==2) k++;
if(r==3) k=k+2;
if(r==4) k=k+2;
printf("%d\n",k);
}... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | c6ffbcc01d3e5af912aaf6b37056fc15 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int a, b, ans=0, count=0,n;
scanf("%d %d", &a, &b);
ans= abs(b-a);
while(ans!=0)
{
if(ans>=5){n=(int)ans/5; ans-=n*5; count+=n;}
else if(ans>=2){n=(int) ans/2; ans-=n*2; count+=n;}
else if(an... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 0611e52f27352ec76ce56e9744b28ebb | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
#include <stdlib.h>
int main(){
int t;
scanf("%d", &t);
while (t--) {
int a, b, d;
scanf("%d%d", &a, &b), d = abs(a - b);
printf("%d\n", d / 5 + (d % 5 + 1) / 2);
}
return 0;
}
| |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 4c8853ac4a504eb45227c89e97dcccae | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
int cases,j,i,dif,rem,n,step=0;
scanf("%d",&cases);
int a[cases];
int b[cases];
for(j=0;j<cases;j++)
{
scanf("%d %d",&a[j],&b[j]);
}
for(i=0;i<cases;i++)
{
if(b[i]>a[i])
{
dif=b[i]-a[i];
}
else if(a[i]>b[... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | bfaa8219dc2ac119e03a271e3912aaaf | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
int t,a,b,count,z;
scanf(" %d", &z);
while(z--){
scanf(" %d %d", &a, &b);
count=0;
if(a!=b){
t=abs(b-a);
while(t){
if(t>=5){
count+=t/5;
t=t%5;
}
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 1c9ded20c2587501bfb4b4c442f32851 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
long long a ,b ,t ,rsp ,i , n;
int main()
{
rsp = 0;
scanf("%lld", &n);
for(i = 1; i <= n; ++i)
{
scanf("%lld %lld", &a ,&b);
if(a < b)
{
a += b;
b = a - b;
a = a - b;
}
rsp = (a - b) / 5;
t = (a - b) % 5;
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | b314a8b4e87e889411058bc64251f2ec | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
long a ,b ,t ,rsp ,i , n;
int main()
{
rsp = 0;
scanf("%ld", &n);
for(i = 1; i <= n; ++i)
{
scanf("%ld %ld", &a ,&b);
if(a < b)
{
a += b;
b = a - b;
a = a - b;
}
rsp = (a - b) / 5;
t = (a - b) % 5;
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 976364eb6e0f11c60ff09aa6c27e4161 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
unsigned long long int t,a,b,c=0;
scanf("%llu",&t);
while(t--){
scanf("%llu %llu",&a,&b);
if(a>b){
while(1){
if(a==b) break;
else if((a-b)>=100000000){a=a-100000000;
c=c+20000000;
continue;}
else if((a-b)>=1000000... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 9411794309faf4e1c6a44c7443ded68b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
#include<math.h>
int main()
{
int t,i,count,x,p,q;
scanf("%d",&t);
int a[t];
for(i=0; i<t; i++)
{
scanf("%d %d",&p,&q);
a[i]=abs(p-q);
}
for(i=0; i<t; i++)
{
x=0;
if(a[i]>0)
{
x=x+a[i]/5;
a[i]=a[i]%5;
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | efd5822e36649c8d329ec039f793a53a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
int t,c,d,min,i,a;
scanf("%d",&t);
for(i=1; i<=t; i++)
{
scanf("%d%d",&c,&d);
if(c>d)
a=c-d;
else
a=d-c;
if(a>=5)
{
min=a/5;
a=a%5;
if(a==4 || a==3)
min=min+... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 3be652f8f8bf92f2b97b389e06831959 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
int a,b,c,n,i,x,y;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
int count1=0,count2=0,count3=0;
scanf("%d %d",&a,&b);
c = abs(a-b);
x=c%5;
count1=(c-x)/5;
if(x!=0)
{
y=x%2;
count2=(x-y)/2;
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | b9631e206c67cfa95a7f1dddeff19704 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main()
{
int t_case, a, b, count;
scanf("%d", &t_case);
while(t_case--){
count=0;
scanf("%d %d", &a, &b);
if(a > b){
a=a+b;
b= a-b;
a= a-b;
}
b=b-a;
a=0;
while(1){
if(a==b)
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | ffe9296566702527e492a698962efd8f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
int main(){
int t;
long long int a,b,x,n,y,i,s,p,q;
scanf("%d",&t);
for(i=1;i<=t;i++){
s=0;
scanf("%lli%lli",&a,&b);
if(a==b){
printf("0\n");
}
else {
if(a<b){
x=a;
a=b;
b=x;
... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | 4f98f88f6de0b5daf3113b8a8449388f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
unsigned int t;scanf("%d",&t);
while(t--)
{
unsigned int b,a,cnt=0;
scanf("%d%d",&b,&a);
if(abs(a-b)>=5)cnt+=abs(a-b)/5;
if(b<a)b=a-abs(a-b)%5;
else b=a+abs(a-b)%5;
if(abs(a-b)==1||abs(a-b)==... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | f6d57161d08e9088f341fbd1c1abdd11 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
int a, nr = 0, b, t, d, i, r;
int main()
{
scanf("%d", &d);
for(i = 1; i <= d; i++)
{
scanf("%d %d", &a, &b);
if(a < b) {r = a ; a = b; b = r;}
t = a - b;
nr = t / 5;
r= t % 5;
if (r > 2) nr = nr + 2;
else if(r ... | |
Bob watches TV every day. He always sets the volume of his TV to $$$b$$$. However, today he is angry to find out someone has changed the volume to $$$a$$$. Of course, Bob has a remote control that can change the volume.There are six buttons ($$$-5, -2, -1, +1, +2, +5$$$) on the control, which in one press can either in... | For each test case, output a single integer — the minimum number of presses to change the TV volume from $$$a$$$ to $$$b$$$. If Bob does not need to change the volume (i.e. $$$a=b$$$), then print $$$0$$$. | C | ccfe798f5dc63c492ff54cf40bb40613 | e7019543ab4e672218feacb70145d342 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1574174100 | ["3\n4 0\n5 14\n3 9"] | NoteIn the first example, Bob can press the $$$-2$$$ button twice to reach $$$0$$$. Note that Bob can not press $$$-5$$$ when the volume is $$$4$$$ since it will make the volume negative. In the second example, one of the optimal ways for Bob is to press the $$$+5$$$ twice, then press $$$-1$$$ once.In the last example,... | PASSED | 800 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 1\,000$$$). Then the descriptions of the test cases follow. Each test case consists of one line containing two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{9}$$$) — the current volume and Bob's desire... | ["2\n3\n2"] | #include <stdio.h>
int a, nr = 0, b, t, d, i, r;
int main()
{
scanf("%d", &d);
for(i = 1; i <= d; i++)
{
scanf("%d %d", &a, &b);
if(a < b) {r = a ; a = b; b = r;}
t = a - b;
nr = t / 5;
r= t % 5;
if (r > 2) nr = nr + 2;
else if(r ... | |
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 | d8b00c0801fec82aa8335b91f93bc922 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
typedef unsigned u;
u A[444][444],B[444][444],(*C)[444],D[444],V[444];
int main()
{
u i,j,k,n,q;
scanf("%u%u",&n,&q);
for(i=0;++i<=n;D[i]=-1)for(j=0;++j<=n;)A[i][j]=1;
while(q--)
{
scanf("%u%u",&i,&j);
A[i][j]=A[j][i]=0;
B[i][j]=B[j][i]=1;
}
if(A[1][n])C=B;
if(B[1][n])C=A;
D[1]=0;
whil... | |
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 | a25c3980cbb36cbb3e6dc2fbf8143f6c | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
#define INF 1000000000
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
int adj1[400][400], adj2[400][400];
int main(void) {
int i, j, k;
int n, m;
int max;
scanf("%d %d", &n, &m);
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)... | |
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 | d963461959596d85c16720fdc8190d5a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
int n,a[401][401];
int bfs(int gt)
{
int q[401][2],d,c,fr[401],i,j;
for (i=1;i<=n;i++) fr[i]=1;
fr[1]=0;
d=0;
c=1;
q[c][0]=1;
q[c][1]=0;
do
{
d++;
if (d>c) break;
for (j=1;j<=n;j++)
if (a[q[d][0]][j]==gt && fr... | |
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 | 871c22284323c50f94570778ca71494e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
#define MAXN 400
int drum[MAXN+1][MAXN+1],cod[MAXN],lung[2][MAXN+1];
int BFS(int nod,int tip,int n){
int i,b,e;
cod[0]=nod;
lung[tip][nod]=1;
b=0;
e=1;
do{
for(i=1;i<=n;i++)
if(lung[tip][i]==0&&drum[i][cod[b]]==tip){
cod[e]... | |
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 | 8c742e7cac1e1e3bfd95369e3dc5b47e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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<math.h>
#include<string.h>
#include<time.h>
#include<ctype.h>
#include<limits.h>
#define eps 1e-7
#define MOD 1000000007
#define ll long long int
#define N 450000
int que[N];
int has[1000][1000];
int dist[N];
int visited[N];
int rear=-1;
int front=-1;
struct graph{
int v... | |
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 | 347480d0f2263c5cb20af9f8a036ee59 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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<math.h>
#include<string.h>
#include<time.h>
#include<ctype.h>
#include<limits.h>
#define eps 1e-7
#define MOD 1000000007
#define ll long long int
#define N 450000
int que[N];
int graph[1000][1000];
int new_graph[1000][1000];
int dist[N];
int visited[N];
int rear=-1;
int fro... | |
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 | e587766909684f89d2010a19f0e2a2d6 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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<math.h>
#include<string.h>
#include<time.h>
#include<ctype.h>
#include<limits.h>
#define eps 1e-7
#define MOD 1000000007
#define ll long long int
#define N 450000
int que[N];
int has[1000][1000];
int dist[N];
int visited[N];
int rear=-1;
int front=-1;
struct graph{
int v... | |
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 | 20934bf1e8fda7feef6b17b304f883bf | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
main()
{
int n,m,i,j,u,v,x,y,z,test;
int M[400],N[400];
int T[400][400];
scanf("%d%d",&n,&m);
for (i=0;i<n;i++) for (j=0;j<n;j++) T[i][j] = 0;
for (i=0;i<m;i++)
{
scanf("%d%d",&u,&v);
... | |
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 | b36386d45ddbf4747e266672b9fbbe59 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
#define N 400
int main() {
static char aa[N][N];
static int qq[N], dd[N];
int n, m, i, j, d, head, cnt;
scanf("%d%d", &n, &m);
while (m-- > 0) {
scanf("%d%d", &i, &j);
i--, j--;
aa[i][j] = aa[j][i] = 1;
}
if (aa[0][n - 1])
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
a... | |
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 | 63d568a53cde1093604c85a931cc4ea2 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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 <string.h>
#define INF 0x3f3f3f3f
int map1[410][410],map2[410][410];
int n,m;
void dijkstra(int map[410][410])
{
int ans[410];
int vis[410];
int point,min;
int i,j;
for(i=1;i<=n;i++)
{
vis[i]=0;
ans[i]=map[1][i];
}
for(i=1;i<=n;i++)
{
... | |
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 | d3241910e0f1c8f03139e82c4cbd589b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
#define MAXN 400
#define INF 2000000000
char d[MAXN][MAXN];
int dist[MAXN];
int q[MAXN];
inline void bfs(char x, int n){
int st = 0, dr = 1, i, nd;
dist[0] = 0;
q[0] = 0;
while(st < dr){
nd = q[st];
st++;
for(i = 0; i < n; i++){
if(i != nd && d[nd][i] == x && dist[i] > dist... | |
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 | 48662f35d57ae039da73db627850f276 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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 <string.h>
#define MAXV 401
typedef struct {
int to;
int next;
} Edge_t;
Edge_t ERoad[MAXV * MAXV];
Edge_t ERail[MAXV * MAXV];
int AdjRoad[MAXV];
int AdjRail[MAXV];
int SizeRoad, SizeRail;
int Queue[MAXV];
char Visited[MAXV];
char Flag[MAXV][MAXV];
void Initialize()
{
mems... | |
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 | 1be2fbc269464e6c955fa718ce69da94 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
int main() {
int e[500][500] = {{0}};
int rail[500] = {0};
int n, m, i, j, u, v, lvl;
int change;
scanf("%d%d", &n, &m);
for(i = 0; i < m; i++) {
scanf("%d%d", &u, &v);
e[u][v] = 1;
e[v][u] = 1;
}
if(e[1][n]) {
for(i = 1; i <= n; i++) {
for(j = 1; j <= n; j++)... | |
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 | 2c6dd0a2efb78afcafa657b16e907e99 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"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>
#define NMAX 410
typedef int adj_t[NMAX][NMAX];
void read(int *n, adj_t adj) {
int m, u, v;
scanf("%d%d", n, &m);
while (m-- > 0) {
scanf("%d%d", &u, &v);
adj[u][v] = adj[v][u] = 1;
}
}
int BFS(int n, adj_t adj, int mean) {
int status[NMAX] =... | |
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.The i-th walrus becomes displeased if there's a younger walrus standi... | Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus. | C | 668f85cc331bc7bcdd708d9190bbd6e8 | fc9d5ce72b269e30cf498beee08749cd | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"binary search"
] | 1308582000 | ["6\n10 8 5 3 50 45", "7\n10 4 6 3 2 8 15", "5\n10 3 1 10 11"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains an integer n (2 ≤ n ≤ 105) — the number of walruses in the queue. The second line contains integers ai (1 ≤ ai ≤ 109). Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other on... | ["2 1 0 -1 0 -1", "4 2 1 0 -1 -1 -1", "1 0 -1 -1 -1"] | #include<stdio.h>
#include<stdlib.h>
typedef struct Nodo{
int pos;
struct Nodo *sgte;
}Nodo;
int f[100010];
int r[100010];
int main(){
int i,j,n,m;
Nodo *aux;
Nodo *H=(Nodo *)calloc(1,sizeof(Nodo));
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&f[i]);
H->pos=n-1;
H->sgte=NULL;
for(i... | |
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.The i-th walrus becomes displeased if there's a younger walrus standi... | Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus. | C | 668f85cc331bc7bcdd708d9190bbd6e8 | 4a3692b2f3874f576688010f9ee0c644 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"binary search"
] | 1308582000 | ["6\n10 8 5 3 50 45", "7\n10 4 6 3 2 8 15", "5\n10 3 1 10 11"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains an integer n (2 ≤ n ≤ 105) — the number of walruses in the queue. The second line contains integers ai (1 ≤ ai ≤ 109). Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other on... | ["2 1 0 -1 0 -1", "4 2 1 0 -1 -1 -1", "1 0 -1 -1 -1"] | #include <stdio.h>
int morsas[100005], menor[100005];
int main() {
int n ,i, izq, der, med ;
scanf("%d", &n);
for(i = 0; i < n; i++) {
scanf("%d", &morsas[i]);
}
menor[n-1] = morsas[n-1];
for(i = n - 2; i >= 0; i--) {
if(morsas[i] < menor[i+1]){
menor[i] = morsas[i];... | |
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.The i-th walrus becomes displeased if there's a younger walrus standi... | Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus. | C | 668f85cc331bc7bcdd708d9190bbd6e8 | 17d967b7dc86653fe00ab881754bad6f | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"binary search"
] | 1308582000 | ["6\n10 8 5 3 50 45", "7\n10 4 6 3 2 8 15", "5\n10 3 1 10 11"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains an integer n (2 ≤ n ≤ 105) — the number of walruses in the queue. The second line contains integers ai (1 ≤ ai ≤ 109). Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other on... | ["2 1 0 -1 0 -1", "4 2 1 0 -1 -1 -1", "1 0 -1 -1 -1"] | #include <stdio.h>
int a[100005], Min[100005];
int main() {
int n;
scanf("%d", &n);
int i;
for(i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
Min[n-1] = a[n-1];
for(i = n - 2; i >= 0; i--) {
Min[i] = a[i] < Min[i+1] ? a[i] : Min[i+1];
}
for(i = 0; i < n - 1; i++) {
... | |
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.The i-th walrus becomes displeased if there's a younger walrus standi... | Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus. | C | 668f85cc331bc7bcdd708d9190bbd6e8 | 2f1fc223ad4a613623917f45770a8079 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"binary search"
] | 1308582000 | ["6\n10 8 5 3 50 45", "7\n10 4 6 3 2 8 15", "5\n10 3 1 10 11"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains an integer n (2 ≤ n ≤ 105) — the number of walruses in the queue. The second line contains integers ai (1 ≤ ai ≤ 109). Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other on... | ["2 1 0 -1 0 -1", "4 2 1 0 -1 -1 -1", "1 0 -1 -1 -1"] | #include<stdio.h>
#include<stdlib.h>
typedef struct Nodo
{
int posicion;
struct Nodo *siguiente;
} morsa;
int main()
{
morsa *siguiente,*aux;
int i,n;
scanf("%d",&n);
int a[n+1];
int v[n+1];
for(i = 0; i < n; i++)
scanf("%d",&a[i]);
siguiente = (morsa*)malloc(sizeof(morsa));
... | |
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.The i-th walrus becomes displeased if there's a younger walrus standi... | Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus. | C | 668f85cc331bc7bcdd708d9190bbd6e8 | d3977ffd04e65ff7175e08c7f8d1180d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"binary search"
] | 1308582000 | ["6\n10 8 5 3 50 45", "7\n10 4 6 3 2 8 15", "5\n10 3 1 10 11"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains an integer n (2 ≤ n ≤ 105) — the number of walruses in the queue. The second line contains integers ai (1 ≤ ai ≤ 109). Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other on... | ["2 1 0 -1 0 -1", "4 2 1 0 -1 -1 -1", "1 0 -1 -1 -1"] | #include <stdio.h>
#include <stdlib.h>
typedef struct{
int Pos;
struct NodoLista *ptrSiguiente;
}NodoLista;
int main(){
NodoLista *Aux;
NodoLista *Last = (NodoLista*)calloc(1,sizeof(NodoLista));
int N = 0, i = 0;
scanf("%d", &N);
int Edades[N];
int Disgusto[N];
for(i=0; i<N; i++)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.