prob_desc_description stringlengths 63 3.8k | prob_desc_output_spec stringlengths 17 1.47k ⌀ | lang_cluster stringclasses 2
values | src_uid stringlengths 32 32 | code_uid stringlengths 32 32 | lang stringclasses 7
values | prob_desc_output_to stringclasses 3
values | prob_desc_memory_limit stringclasses 19
values | file_name stringclasses 111
values | tags listlengths 0 11 | prob_desc_created_at stringlengths 10 10 | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_notes stringlengths 4 3k ⌀ | exec_outcome stringclasses 1
value | difficulty int64 -1 3.5k ⌀ | prob_desc_input_from stringclasses 3
values | prob_desc_time_limit stringclasses 27
values | prob_desc_input_spec stringlengths 28 2.42k ⌀ | prob_desc_sample_outputs stringlengths 2 796 | source_code stringlengths 42 65.5k | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
You are given an array $$$a_1, a_2, \dots, a_n$$$ of integer numbers.Your task is to divide the array into the maximum number of segments in such a way that: each element is contained in exactly one segment; each segment contains at least one element; there doesn't exist a non-empty subset of segments such that bitw... | Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists. | C | 0e0f30521f9f5eb5cff2549cd391da3c | 0a3e01a76e824328c1f9ade4891ad682 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"math",
"matrices"
] | 1547217300 | ["4\n5 5 7 2", "3\n1 2 3", "3\n3 1 10"] | NoteIn the first example $$$2$$$ is the maximum number. If you divide the array into $$$\{[5], [5, 7, 2]\}$$$, the XOR value of the subset of only the second segment is $$$5 \oplus 7 \oplus 2 = 0$$$. $$$\{[5, 5], [7, 2]\}$$$ has the value of the subset of only the first segment being $$$5 \oplus 5 = 0$$$. However, $$$\... | PASSED | 2,300 | standard input | 2 seconds | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). | ["2", "-1", "3"] | a[31],s[1<<18],n,i;int I(int p){for(i=30;~i;--i)if(p>>i&1){if(!a[i]){a[i]=p;return 1;}p^=a[i];}return 0;}int main(x){scanf("%d",&n);for(i=x=1;i<=n;++i)scanf("%d",s+i),s[i]^=s[i-1];if(!s[n])exit(0&puts("-1"));I(s[n]);while(--n)x+=I(s[n]);exit(!printf("%d",x));} | |
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ... | In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap... | C | e71640f715f353e49745eac5f72e682a | 0b80f3ec6d502f5f522c99b0dbd0c7d2 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"constructive algorithms",
"dfs and similar",
"graphs"
] | 1454605500 | ["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"] | NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to... | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains two integers n and m — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ... | ["Yes\naa", "No"] | #include<stdio.h>
#include<stdlib.h>
typedef unsigned u;
int F(const void*x,const void*y){return*(int*)y-*(int*)x;}
char C[555],bad;
u G[555][555],S[555],l;
void D(u n,u x)
{
if(bad||C[n]=='b')return;
if(C[n])
{
if(x){if(C[n]!='c')bad=1;}
else{if(C[n]!='a')bad=1;}
return;
}
C[n]=x?'c':'a';u i;
for(i=-1;++i<... | |
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ... | In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap... | C | e71640f715f353e49745eac5f72e682a | 538dade29907fb4381fb9e271eb6091c | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"constructive algorithms",
"dfs and similar",
"graphs"
] | 1454605500 | ["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"] | NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to... | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains two integers n and m — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ... | ["Yes\naa", "No"] | #include<stdio.h>
#include<stdlib.h>
int cmpfunc (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
void swap(int *a, int *b){
int c;
c=*a;
*a=*b;
*b=c;
}
int adj[502][502], n_adj[502], sum[502], grp[502], n_grp,gcnt[3],gnei[3], gneil[3][3], revgr[3];
char ans[502];
int main(){
int n, m, ... | |
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ... | In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap... | C | e71640f715f353e49745eac5f72e682a | 68e5fa5fb441b6f1345e66d946d30663 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"constructive algorithms",
"dfs and similar",
"graphs"
] | 1454605500 | ["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"] | NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to... | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains two integers n and m — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ... | ["Yes\naa", "No"] | #include<stdio.h>
int main()
{
char vertice[500];
int edge[500][500];
int m,n,i,j,x,y;
int judge=1;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
vertice[i]='b';
for(i=0;i<n;i++)
for(j=0;j<n;j++)
edge[i][j]=0;
for(i=0;i<n;i++)
edge[i][i]=1;
for(i=0;i<m;i++)
{
scanf("%d%d",&x,&y);
edge[x-1][y-1]=1;... | |
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ... | In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap... | C | e71640f715f353e49745eac5f72e682a | 09b1a07402f2fe66d0fdb7f26e838963 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"constructive algorithms",
"dfs and similar",
"graphs"
] | 1454605500 | ["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"] | NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to... | PASSED | 1,800 | standard input | 2 seconds | The first line of the input contains two integers n and m — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ... | ["Yes\naa", "No"] | #include <stdio.h>
#include <math.h>
int main()
{
int n,m,i,j,arr[501][501],a,b,find[501]={0},k,count=0,flag=0,br=0;
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
arr[i][j]=0;
}
for(i=0;i<m;i++)
{
scanf("%d %d",&a,&b);
arr[a][b]=1;
arr[b][a]=1;
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n && j... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 0f3fde8a68c43846b86e28525e05d5d1 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | int n,a[200002];
int l[200002];
int r[200002];
int main()
{
unsigned long long int i=0,sum1=0,sum0=0,flag1=-1,flag0=-1,sum=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]==1)
{
flag1=1;
sum1++;
}
if(a[i]==0)
{
flag0=1;
sum0++;
}
}
for(i=n;i>=1;... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 2c8bba015afdcd1636de77a1b74b80b4 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
int x,y,z,i,o,p,j,k,n,t;
long long l,m;
long long a[200005],b[200005],c[200005];
int main ()
{
a[1]=0;
scanf("%d",&n);
for (i=1;i<=n;i++)
scanf("%d",&a[i]);
for (i=1;i<=n;i++)
if(a[i]) b[i+1]=b[... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 4e70ed4c51dc14bee574a4dc01c9d5a9 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
int main()
{
int i,j,n,k;
scanf("%d",&n);
long long int a[n];
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
}
long long int ans=0,t=0;
for(i=0;i<n;i++)
{
if(a[i]==1) t++;
else ans+=t;
}
printf("%lld\n",ans);
return 0;
}
| |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | c06dc908da0688b572258f596fc3c0d1 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i,t,n,h;
long long s;
while(scanf("%d",&n)!=EOF)
{
s=0;
h=0;
for(i=0;i<n;i++)
{
scanf("%d",&t);
if(t==1)
{
h++;
}
else if(t==0&&h!=0)
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 93db32f8b4a93b9477ae6b1216a90f93 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | # include <stdio.h>
int arr[200010];
int main()
{
long long int a,b;
int i,j,n;
int ca,cb;
while(~scanf("%d",&n))
{
ca = cb = 0;
a = b = 0;
for(i = 0;i < n;i ++)
{
scanf("%d",&arr[i]);
if(arr[i] == 0) ca += 1;
else cb += 1;
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 31a2d2a6c1ebca24c944acba4e24f909 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <stdlib.h>
int niu[200002];
int main()
{
int n,i;
long long sum=0,jishu=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&niu[i]);
if(niu[i]==1)
jishu++;
else
sum+=jishu;
}
printf("%I64d",sum);
return 0;
} | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | e78274a971bb1db3b8d9dcff40dcc69b | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
int main()
{
int n,i,sum=0;
long long int inv = 0;
int a;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a);
sum+=a;
if(a == 0)
{
inv += sum;
}
}
printf("%I64d\n",inv);
return 0;
} | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 3a2002e7ed838dab85aafa5568ca9ee9 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
long long n,i,c1=0,c2=0;
scanf("%I64d",&n);
long long arr[n];
for(i=0;i<n;i++)
{
scanf("%I64d",&arr[i]);
}
for(i=0;i<n;i++)
{
if(arr[i]==1)
{
c1++;
}
else
{
c2+=c1... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | b270e51864191ced7dd74a73c816d14e | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
int main()
{
int i,j,n,k;
scanf("%d",&n);
long long int arr[n];
for(i=0;i<n;i++)
{
scanf("%I64d",&arr[i]);
}
long long int ans=0,t=0;
for(i=0;i<n;i++)
{
if(arr[i]==1) t++;
else ans+=t;
}
printf("%I64d\n",ans);
return 0;
} | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | b6fefe7705350e1165e5fd987f43a6bc | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
int main()
{
long long n,a[200004],i,c=0,ans=0;
scanf("%I64d",&n);
for(i=0;i<n;i++)
scanf("%I64d",&a[i]);
for(i=0;i<n;i++)
{
if(a[i]==1)
c++;
else
ans=ans+c;
}
printf("%I64d",ans);
return 0;
}
| |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 5f8c6bf56f1e6d2558715aed48f5b5ea | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
int main(void) {
long long int count = 0;
int n, i, temp, ones = 0;
scanf("%d\n", &n);
for (i = 0; i < n; i++) {
scanf("%d", &temp);
if (!temp) count += ones;
else ones++;
}
printf("%lld\n", count);
return 0;
} | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 4055143fcb6f03b6eeb2545fb9551786 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
#include<stdlib.h>
int main(){
long long int n,i,sum=0,count0=0,count1=0;
scanf("%I64d",&n);
int a[200005]={0};
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]==0) count0++;
else if(a[i]==1) count1++;
}
if(count0<=count1){
for(i=0;i<n;i++){
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 33f1916e385eb10fd39a1037cd464c0d | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
__int64 s[200001]={0};
int main(void)
{
int n,i,c,t;
while(scanf("%d",&n)!=EOF)
{
t=0;
for(i=1;i<=n;i++)
{
scanf("%d",&c);
s[i]=s[i-1];
if(c==1)
t++;
else
s[i]+=t;
}
printf("%I64d\n",s[n]);
}
return 0;
}
| |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | bd906604c11aa0f0ee5bea7077e41b1e | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
int main()
{
int n,x[200003],cum[200003]={0},i,j;
long long ans=0;
scanf("%d",&n);
for(i=1;i<=n;++i)
scanf("%d",&x[i]);
if(x[n]==0)
cum[n]=1;
for(i=n-1;i>=1;--i)
{
if(x[i]==0)
{
cum[i]=cum[i+1]+1;
}
else
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 442ff5c798bc357f9ff9b9009acd86c7 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define For(i,n) for(i=0;i<n;i++)
#define MIN(x,y) (x)>(y)?(y):(x)
#define MAXN 111
main()
{
int i, n, m, x=0;
long long ans=0;
scanf("%d",&n);
For(i,n){
scanf("%d",&m);
if(m) x++;
else ans+=x;
}
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 8d9d07ddfadb4103ffbb8f77a8ab678f | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
main()
{
long long int n,a[1000005],s0=0,l=0,t1=0,i;
scanf("%lld",&n);
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
if(a[i]==0)
s0++;
}
for(i=0;i<n;i++)
{
if(a[i]==1)
{
l=l+s0;
}
else
s0--;
}
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | b8d027e08aa3199123f3be69e5b31ea5 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
long long int N,arr[200005]={0};
long long int i=0,sum=0,count0=0,count1=0;
scanf("%I64d",&N);
for(i=0;i<N;i++){
scanf("%d",&arr[i]);
if(arr[i]==0) count0++;
else count1++;
}
if(count0<=count1){
for(i=0;i<N;i... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | b0e665b7351d2cf73a8c951c3bbb5195 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
long long int N,arr[200005]={0};
long long int i=0,sum=0,count0=0,count1=0;
scanf("%I64d",&N);
for(i=0;i<N;i++){
scanf("%d",&arr[i]);
if(arr[i]==0) count0++;
else count1++;
}
for(i=0;i<N;i++){
if(arr[... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | d2ab5a258f311609e96d5c82518bf997 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i=0,N,arr[200005]={0},count0=0,count1=0;
long long int sum=0;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&arr[i]);
if(arr[i]==0) count0++;
else count1++;
}
for(i=0;i<N;i++){
if(arr[i]==1) sum+=c... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | b6ad723bb4ec93e2b551ee5f11d2cdeb | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | // OUM NAMA MA SWARASATI
#include"math.h"
#include"stdio.h"
#include"string.h"
#include"stdlib.h"
#define pf printf
#define sf scanf
#define r return
typedef long long int ll;
int main()
{
ll ans;
int n;
sf("%d", &n);
int a[n],i=0,ch=1,c0=0,c1=0,cn=-2,cn0=0;
while(i<n){
sf("%d", &a[i++]);
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | cda99cf64c5a9c04853a87d14f0d8881 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
int a[200050],s[200050];
main()
{
int n,i,j,k,ans,a1v;
long long int a1,a2;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
s[1]=a[1];
for(i=2;i<=n;i++)
s[i]=s[i-1]+a[i];
a1=0;
for(i=n;i>=1;i--)
{
if(a[i]==0)
{
a1v=s[... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | 02116474b25d1d73dac4a491683b34f6 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
long long T,N,i,j,val,K,M,k,l,cnt,zero,one,Czero,Cone,Tzero,Tone;
//scanf("%lld",&T);
//while(T--)
//{
scanf("%lld",&N);
long long A[N];
for(i=0,zero=0,one=0;i<N;i++)
{
scanf("%lld",&A[i]);
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | bd44353d60901d960578a1c616e4bbe4 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
long long a[2][200005];
int main(){
long long left,right,count;
int n,i,t;
while(scanf("%d",&n)!=EOF){
memset(a,-1,sizeof(a));
for(i=1,left=rig... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | bc2949dcbdef32f0e2391ee7d8a7abe8 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
int main(){
int n,c1,i;
long long int c2;
scanf("%d",&n);
c1=0;c2=0;
int a[n][2];
for(i=0;i<n;i++){
scanf("%d",&a[i][0]);
if(a[i][0]==1)
c1++;
a[i][1]=c1;
}
for(i=0;i<n;i++){
if(a[i][0]==0)
c2+=a[i][1];
}
printf("%lld\n",c2);
return 0;
}
... | |
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi... | Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1a3b22a5a8e70505e987d3e7f97e7883 | adbad91bf663a23d851cc5437d5733f2 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy"
] | 1390231800 | ["4\n0 0 1 0", "5\n1 0 1 0 1"] | NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost. | PASSED | 1,600 | standard input | 1 second | The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right. | ["1", "3"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(void)
{
__int64 n, count, temp, i, x;
while(scanf("%I64d",&n)!=EOF){
count=0;
temp=0;
for(i=0;i<n;i++){
scanf("%I64d",&x);
if(x==0){
if(temp<i){
count+=temp;
}
else{
count+=i;
}
}
else{
te... | |
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | In the first line print single integer k — the minimal number of symbols that need to be replaced. In the second line print k distinct integers denoting the positions of symbols in the string s which need to be replaced. Print the positions in any order. If there are several solutions print any of them. The numbering o... | C | dd26f45869b73137e5e5cc6820cdc2e4 | 24cfa2a6812dad28f298702a1b64b58c | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"brute force",
"strings"
] | 1499011500 | ["3 5\nabc\nxaybz", "4 10\nabcd\nebceabazcd"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains two integers n and m (1 ≤ n ≤ m ≤ 1000) — the length of the string s and the length of the string t correspondingly. The second line contains n lowercase English letters — string s. The third line contains m lowercase English letters — string t. | ["2\n2 3", "1\n2"] | #include <stdio.h>
int main()
{
int n,m,i,j;
scanf("%d %d",&n,&m);
char a[n+1],b[m+1];
int flag[m-n+1],min=99999,ind;
scanf("%s %s",a,b);
for(i=0;i<=m-n;i++)
{
flag[i]=0;
for(j=0;j<n;j++)
{
if(a[j]!=b[j+i])
flag[i]++;
}
if(flag[i]<min)
... | |
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | In the first line print single integer k — the minimal number of symbols that need to be replaced. In the second line print k distinct integers denoting the positions of symbols in the string s which need to be replaced. Print the positions in any order. If there are several solutions print any of them. The numbering o... | C | dd26f45869b73137e5e5cc6820cdc2e4 | 4809e14f29cfac1e3cc1caaaac807b1b | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"brute force",
"strings"
] | 1499011500 | ["3 5\nabc\nxaybz", "4 10\nabcd\nebceabazcd"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains two integers n and m (1 ≤ n ≤ m ≤ 1000) — the length of the string s and the length of the string t correspondingly. The second line contains n lowercase English letters — string s. The third line contains m lowercase English letters — string t. | ["2\n2 3", "1\n2"] | #include <stdio.h>
#include<string.h>
int main()
{
int a, b, n1, n2, i, j, gcd, ls, lt, m, cnt, idx, pos=0;
char s[10000], t[10000];
scanf("%d %d", &a, &b);
scanf("%s %s", s, t);
ls = strlen(s);
lt = strlen(t);
int ar[ls];
//printf("%d %d\n", ls, lt);
int boro[lt-ls+1];
for(i=0;i... | |
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | In the first line print single integer k — the minimal number of symbols that need to be replaced. In the second line print k distinct integers denoting the positions of symbols in the string s which need to be replaced. Print the positions in any order. If there are several solutions print any of them. The numbering o... | C | dd26f45869b73137e5e5cc6820cdc2e4 | 7e56856c0d1056df7bfe3819c5ff1338 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"brute force",
"strings"
] | 1499011500 | ["3 5\nabc\nxaybz", "4 10\nabcd\nebceabazcd"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains two integers n and m (1 ≤ n ≤ m ≤ 1000) — the length of the string s and the length of the string t correspondingly. The second line contains n lowercase English letters — string s. The third line contains m lowercase English letters — string t. | ["2\n2 3", "1\n2"] | #include <stdio.h>
#include<string.h>
int main()
{
int a, b, n1, n2, i, j, gcd, ls, lt, m, cnt, idx, pos=0;
char s[10000], t[10000];
scanf("%d %d", &a, &b);
scanf("%s %s", s, t);
ls = strlen(s);
lt = strlen(t);
int ar[ls];
//printf("%d %d\n", ls, lt);
int boro[lt-ls+1];
for(i=0;i... | |
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | In the first line print single integer k — the minimal number of symbols that need to be replaced. In the second line print k distinct integers denoting the positions of symbols in the string s which need to be replaced. Print the positions in any order. If there are several solutions print any of them. The numbering o... | C | dd26f45869b73137e5e5cc6820cdc2e4 | 4d8705e812f4f10c49891f475c985f76 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"brute force",
"strings"
] | 1499011500 | ["3 5\nabc\nxaybz", "4 10\nabcd\nebceabazcd"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains two integers n and m (1 ≤ n ≤ m ≤ 1000) — the length of the string s and the length of the string t correspondingly. The second line contains n lowercase English letters — string s. The third line contains m lowercase English letters — string t. | ["2\n2 3", "1\n2"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmpfunc (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
main()
{
//freopen("in.txt", "r", stdin);
int n, m, l, i, j, k = 0, c = 0, max = 0;
scanf("%d %d", &n, &m);
char st1[n+1], st2[m+1];
scanf("%s %s", st1, st... | |
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | In the first line print single integer k — the minimal number of symbols that need to be replaced. In the second line print k distinct integers denoting the positions of symbols in the string s which need to be replaced. Print the positions in any order. If there are several solutions print any of them. The numbering o... | C | dd26f45869b73137e5e5cc6820cdc2e4 | a53ba2eca6baae0d693f39dc6a2b6db8 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"brute force",
"strings"
] | 1499011500 | ["3 5\nabc\nxaybz", "4 10\nabcd\nebceabazcd"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains two integers n and m (1 ≤ n ≤ m ≤ 1000) — the length of the string s and the length of the string t correspondingly. The second line contains n lowercase English letters — string s. The third line contains m lowercase English letters — string t. | ["2\n2 3", "1\n2"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
int n = 0, m = 0, i = 0, j = 0;
int match = 0, max = 0, pos = 0;
char s[1001] = {0, }, t[1001] = {0, };
scanf("%d %d", &n, &m);
scanf("%s", s);
scanf("%s", t);
for (i=0;i<=m-n;i++) {
match = 0;
... | |
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | In the first line print single integer k — the minimal number of symbols that need to be replaced. In the second line print k distinct integers denoting the positions of symbols in the string s which need to be replaced. Print the positions in any order. If there are several solutions print any of them. The numbering o... | C | dd26f45869b73137e5e5cc6820cdc2e4 | 3411483f1ebb1a42cf0703c7cf06fb87 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"brute force",
"strings"
] | 1499011500 | ["3 5\nabc\nxaybz", "4 10\nabcd\nebceabazcd"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains two integers n and m (1 ≤ n ≤ m ≤ 1000) — the length of the string s and the length of the string t correspondingly. The second line contains n lowercase English letters — string s. The third line contains m lowercase English letters — string t. | ["2\n2 3", "1\n2"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int n,m,i,j,match,maxmatch=0,pos=0;
scanf("%d %d ",&n,&m);
char *s = malloc((n+1)*sizeof(char));
char *t = malloc((m+1)*sizeof(char));
scanf("%s %s",s,t);
n = strlen(s);
m = strlen(t);
for(i=0; i<=m-n; i++)
{
match = 0;
for(j=0; j<n; ... | |
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | In the first line print single integer k — the minimal number of symbols that need to be replaced. In the second line print k distinct integers denoting the positions of symbols in the string s which need to be replaced. Print the positions in any order. If there are several solutions print any of them. The numbering o... | C | dd26f45869b73137e5e5cc6820cdc2e4 | 7ef45f212c99520df26dea7ba87534f4 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"brute force",
"strings"
] | 1499011500 | ["3 5\nabc\nxaybz", "4 10\nabcd\nebceabazcd"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains two integers n and m (1 ≤ n ≤ m ≤ 1000) — the length of the string s and the length of the string t correspondingly. The second line contains n lowercase English letters — string s. The third line contains m lowercase English letters — string t. | ["2\n2 3", "1\n2"] | #include <stdio.h>
#include <stdlib.h>
int main(void) {
int i, n, m, ni, mi;
int sm_let_rep, let_rep, sm_let;
char s[1001];
char t[1001];
scanf("%i", &n);
scanf("%i", &m);
scanf("%s", s);
scanf("%s", t);
sm_let_rep = n;
sm_let = 0;
for (mi = 0; mi < m - n + 1; mi++)
{
let_rep = n;
for (ni = 0; ni < n... | |
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr... | Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins. | C | 67e51db4d96b9f7996aea73cbdba3584 | 24e3b666a061dba7352836c64dbcee43 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"games"
] | 1433595600 | ["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"] | NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ... | PASSED | 2,200 | standard input | 1 second | The first line contains two positive space-separated integers, n and k (1 ≤ k ≤ n ≤ 2·105) — the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≤ ai ≤ 106), which represent the population of each city in Westeros. | ["Stannis", "Daenerys", "Stannis"] | /* practice with Dukkha */
#include <stdio.h>
int main() {
int n, k, l, m, a, o, e, odd;
scanf("%d%d", &n, &k), l = n - k;
o = 0, e = 0;
while (n--) {
scanf("%d", &a);
if (a % 2 == 0)
e++;
else
o++;
}
if (l == 0)
odd = o % 2;
else if (o <= l / 2)
odd = 0;
else if (e <= l / 2)
odd = k % 2;
e... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 1a996addd179ad2f8fe9bfb9c128a204 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include <stdio.h>
const int M = 31;
int main(){
int a[M][M],ans=0;
int n,i,j;
for (i=0;i<M;i++) for(j=0;j<M;j++) a[i][j]=0;
scanf("%i",&n);
for (i=0;i<n;i++){
for(j=0;j<n;j++){
scanf("%i",&a[i][j]);
a[i][M-1]+=a[i][j];
a[M-1][j] += a[i][j];
}
... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 7bf9aa9eb5acce208c3209a45692d08c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int sum[2][35];
int main()
{
int n,i,j,px=0;
scanf("%d",&n);
int a[n][n];
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
sum[0][i]+=a[i][j];
sum[1][j]+=a[i][j];
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(sum[0][i]<sum[1][j])
px++;
printf("%d",px);
return 0;
... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 626459f7c9a886706e0b6bec90b72030 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int n, i, k, j, h, x, c=0;
scanf("%d", &n);
int a[n][2];
for(i=0; i<n; i++)
{
a[i][0]=0;
for(k=0; k<n; k++)
{
scanf("%d", &x);
a[i][0]+=x;
if(i==0)
{
a[k][1]=x;
}
else
{
a[k][1]+=x;
}
}
}
for(h=0; h<n; h++)
{
for(j=0; j<n; j++)... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 09ba6a12a469ceaed0fe7ca67a001bc1 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int n, i, k, h, x, j, c=0;
scanf("%d", &n);
int a[n], b[n];
for(i=0; i<n; i++)
{
a[i]=0;
for(k=0; k<n; k++)
{
scanf("%d", &x);
a[i]+=x;
if(i==0){
b[k]=x;
}
else{
b[k]+=x;
}
}
}
for(h=0; h<n; h++)
{
for(j=0; j<n; j++)
{
if(b[j]>a[h])... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 0b313e1c40d63b61d9d44cb7c8ac4f02 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int i,j,n,k=0;
scanf("%d",&n);
int G[n][n];
int row[n];
int col[n];
for(i=0;i<n;i++)
{
row[i]=0;
col[i]=0;
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&G[i][j]);
}
}
for(i=0;i<n;i++... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | be933f24fb0aec3ef3cbe1eff9cbd605 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
int main() {
int i,j,n;
scanf("%d",&n);
int a[n][n];
for(i=0; i<n; i++){
for(j=0; j<n; j++){
scanf("%d",&a[i][j]);
}}
int x,y,counter=0,sum_r,sum_c;
for(x=0; x<n; x++){
... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 474247bbaeae551ae537fc5230e87147 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main(){
int i,j,n,x,y,count=0;
int a[30][30],r[30],c[30];
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
scanf("%d",&a[i][j]);
}
}
for(i=0;i<n;i++){
x=0,y=0;
for(j=0;j<n;j++){
x+=a[i][j];
y+... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | cc4fdca5ad2f1010ca86b63272fbad63 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int i,j,n,x=0,y=0,c=0,k=0,l=0;
int tab[50][50];
int s1[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&tab[i][j]);
}
}
i=0;
j=0;
while(i>=0&&i<n)
{s... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 052f28080b2eba8d064f7de6c7bf76a6 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int i,j,n,x=0,y=0,c=0,k=0,l=0;
int tab[50][50];
int s1[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&tab[i][j]);
}
}
i=0;
j=0;
while(i>=0&&i<n)
{s... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | a6735a698bc7b2e23346599eb80f500b | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int i,j,n,x=0,y=0,c=0,k=0,l=0;
int tab[50][50];
int s1[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&tab[i][j]);
}
}
i=0;
j=0;
while(i>=0&&i<n)
{s... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | d6236c902f5ce48a3fb6d0de292dbcab | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include <stdio.h>
int main()
{
int t,a[105][105],i,j,count=0,sum1,sum2,k,l;
scanf("%d", &t);
for(j=0; j<t; j++)
{
for(i=0; i<t; i++)
{
scanf("%d", &a[j][i]);
}
}
for(i=0;i<t;i++)
{
sum1=0;
for(j=0;j<t;j++)
{
sum1=sum1+a[i][j]... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 6e92943f01658c2c68763e63e9db875c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include <stdio.h>
int main ()
{
int i,j,l,n,ar[30][30]={0},check,a=0,flag=1;
scanf("%d",&n);
check=scanf("%d",&ar[0][0]);
j=1;
if(n==1)
{
printf("0\n");
return 0 ;
}
for(i=0;i<n;i++,j=0)
{
check= scanf("%d",&ar[i][j]);
while(check==1 && getchar()!='\n... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 07f1099f0cbda91ff480dc027fde7efd | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int tc;
scanf("%d",&tc);
int input[105][105];
int total[50];
int sum[50];
for(int i = 0;i<5;i++) total[i] = 0;
for(int i = 0;i<tc;i++)
{
for(int j = 0;j<tc;j++)
{
scanf("%d",&input[i][j]);
total[i] += input[i][j];
}
}
for(int i = 0;i<tc;i++)
{
for(int j = 0;j<tc;j... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 9d924e0a66986d4159075568d5f27c97 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int n,i,j,x,k,c=0;
scanf("%d",&n);
int a[n],b[n];
for(i=0;i<n;i++){
a[i]=0;
b[i]=0;
}
i=0;
j=0;
for(k=0;k<n*n;k++){
scanf("%d",&x);
if(k!=0 && k%n==0)
i++;
a[i]=a[i]+x;
if(k!=0 && k%n==0)
j=0;
b[j]=b[j]+x;
j++;
}
for(i=0;i<n;i++)
for(j=0;j<n;j++){
if(b[j]>a[... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 26008a83f94fe30e25dd0986b8c81067 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include <stdio.h>
#define rep(i,a,b) for (int i=a; i<b; i++)
void scan(int *biarr, int length, int width) {
int step=0;
rep (i,0,length) {
rep (j,0,width) scanf("%d",((biarr+step)+j));
step+=width;
scanf("\n");
}
}
int winning(int *biarr, int length, int width) {
int rowsum[leng... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | afcc464ae445ae7fe5bdb702135bcef7 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int n,i,j,k,t,a[35][35];
int sum1,sum2,sum=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
scanf("%d",&a[i][j]);
}
for(i=1;i<=n;i++)
{
sum1=0;
for(k=1;k<=n;k++)
sum1+=a[i][k];
for(j=1;j<=n;j++)
{
sum2=0;
for(t=1;t<=n;t++)
sum2+=a[t][j];
if(sum... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 085433a1633e9ee04196f8a550ef94b4 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,i,j,csum=0,rsum=0,c=0,x=0;
scanf("%d",&n);
int a[n][n];
for(i=0;i<n;i++)
{
for (j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<n;i++)
{
for (j=0;j<n;j++)
{
for (x... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | ebb4f7ee2de79a1567deba593c5a39cb | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int n,i,j;
scanf("%d",&n);
int x[n][n],win=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&x[i][j]);
}
}
int sumc=0,sumr=0,s,f;
for(s=0;s<n;s++)
{
for(f=0;f<n;f++)
{
sumr=0; sumc=0;
for(j=0;j<n;j++)
{
sumr+=x[f][j];
sum... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | fda54d2544dfd7f258223519f051c04d | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include <stdio.h>
int main()
{
int n,i,j,k,row=0,col=0,p=0,a,b,c,s[35][35];
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&s[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<n;k++)
{
... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | fc85b522e63ea177d4d53fd96de84783 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int sumofno(int i,int j,int n,int a[n][n]);
int main()
{
int n,s=0;
scanf("%d",&n);
int a[n][n];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 6a2904c451ef6862975a69b4f4948a58 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main()
{
int n, i, k, h, x, j, c=0;
scanf("%d", &n);
int a[n], b[n];
for(i=0; i<n; i++)
{
a[i]=0;
for(k=0; k<n; k++)
{
scanf("%d", &x);
a[i]+=x;
if(i==0){
b[k]=x;
}
else{
b[k]+=x;
}
}
}
for(h=0; h<n; h++)
{
for(j=0; j<n; j++)
{
if(b[j]>a[h])... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | c0644b296018411142c1689bd1f96a6c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n ;
scanf("%d",&n);
int board[n][n] ;
int sumRow[n];
int sumColumn[n];
int i,j;
for(i=0;i<n;i++){
sumRow[i]=0;
for(j=0;j<n;j++){
scanf("%d",&board[i][j]);
sumRow[i] = sumRow[i]+board[i][j];
... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | a9d1b59591e2a9144d94e6340d7fff0c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main(void)
{
int i,j,x,k=0,l,n,sum,sum1,count=0;
scanf("%d",&n);
int array[n][n],row[n],col[n];
for(i=0;i<n;i++)
{
for(j=0,sum=0;j<n;j++)
{
scanf("%d",&array[i][j]);
sum+=array[i][j];
}
if(i==n-1)
{
for... | |
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | Print the single number — the number of the winning squares. | C | 6e7c2c0d7d4ce952c53285eb827da21d | 3ed29b7504212c3ec052ccdcf3e1cf5c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"brute force"
] | 1330536600 | ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"] | NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3 | PASSED | 800 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100. | ["0", "2", "6"] | #include<stdio.h>
int main(){
int n, sumbaris = 0, sumkolom = 0, cnt = 0;
scanf("%d", &n);
int a[n][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
scanf("%d", &a[i][j]);
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
for(int row = 0; row < n; row++){
sumbaris += a[i][r... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 4836ac556d4f1409f6dd02a28d43c013 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include<stdio.h>
int main()
{
int n , m , i,j,max,c = 0;
scanf("%d %d",&n,&m);
char A[n][m+1];
for( i = 0; i < n; i++)
{
scanf(" %s",A[i]);
}
for( i = 0 ; i < m; i++)
{
char max = A[0][i];
for( j = 0; j < n-1; j++)
{
if( A[j+1][i] >= max)
{
max = A[j+1][i];
... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | cfd48f2af099fdd468c2be287b4a72bb | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include<stdio.h>
int main()
{
int n,m,i,j,k=0;
scanf("%d%d",&n,&m);
char a[101][101],b[100];
for(i=0;i<n;i++)
scanf("%s",a[i]);
for(j=0;j<m;j++)
{
for(i=0;i<n;i++)
{
if(b[j]<a[i][j])
b[j]=a[i][j];
}
}
for(i=0;i<n;i++)
f... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | b4ac208cca3c729578f3b92398a1e502 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
int main()
{
int n, m, cnt=0, i, j, idx=-1, arr[100]={0};
char temp[100]={0}, ar[100][100]={0};
scanf("%d %d", &n, &m);
for ( i=0; i<n; i++ )
{
getchar();
for ( j=0; j<m; j++ )
{
scanf("%c", &ar[i][j]);
if ( ar[i][j]>temp[j] ) temp[... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 780acff60635182e1d9b73ba75e63003 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include<stdio.h>
#include<string.h>
int main ()
{
int n,m,i,j,count=0,x;
scanf("%d %d",&n,&m);
char ch[n][m];
int max[m];
memset(max,0,sizeof(max));
for(i=0;i<n;i++)
{
scanf("%s",ch[i]);
for(j=0;j<m;j++)
{
x=ch[i][j]-'0';
if(x>max[j])
... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 65dfb7b557f8041ec4113e812739e084 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
int main()
{
int n, m, i, j, c = 0, *suc;
char **s, max;
scanf("%d %d", &n, &m);
s = (char**)malloc(sizeof(char*)*n);
suc = (int*)malloc(sizeof(int)*n);
for (i = 0; i < n; i++)
s[i] = (char*)malloc(sizeof(char)*(m+1));
for (i = 0; i... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 5203ac4e189501f4f0ac2ecc3c7cdef7 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
int main()
{
int n, m, i, j, c = 0, *suc;
char **s, max;
scanf("%d %d", &n, &m);
s = (char**)malloc(sizeof(char*)*n);
suc = (int*)malloc(sizeof(int)*n);
for (i = 0; i < n; i++)
s[i] = (char*)malloc(sizeof(char)*(m+1));
for (i = 0; i... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | fff9c35c5d167716382fb94dbcbc0367 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
int main() {
int n, m;
scanf("%d%d", &n, &m);
int a[n][m];
for (int i=0;i<n;i++) {
for (int j=0;j<m;j++) scanf("%1d", &a[i][j]);
}
int c=0;
for (int i=0;i<n;i++) {
for (int j=0;j<m;j++) {
int max=a[i][j], f=1;
for (int k=0;k<n;k++) {
if (a[k][j]>max) f=0;
}
if (f) {
c... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 96d3dd14a7652cbf399afa620e775b18 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
long long int ch[200000]= {0},cp[500000];
char kh[200][200],arr[1000000];
int a,b=0,c,d,e,i=0,j=0,k=0,l=0,tep,temp,m,n,x,y;
double z,go;
scanf("%d%d",&a,&b);
j=0;
k=0;
l=0;
for(i=0; i<a; i++)
{
scanf("... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 4f804e161433eb67a73dacddf5c3dc7f | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
int power(int a, int b);
int main(void){
int students, subjects, mark;
scanf("%d %d", &students, &subjects);
char marks[100][100];
for(int i=0; i<students; ++i)
scanf("%s", &marks[i][0]);
int max;
int succesful[100] = {0};
for(int i=0; i<subjects; +... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | cc4cb74292909cb3973f61c8c11742e0 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
int power(int a, int b);
int main(void){
int students, subjects, mark;
scanf("%d %d", &students, &subjects);
char marks[100][100];
for(int i=0; i<students; ++i)
scanf("%s", &marks[i][0]);
int max;
int succesful[100] = {0};
for(int i=0; i<subjects; +... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 6336ade7af736ef319483d7f3c4d5ac9 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
int main()
{
int n, m, cnt=0, i, j, idx=-1, arr[100]={0};
char temp[100]={0}, ar[100][100]={0};
scanf("%d %d", &n, &m);
for ( i=0; i<n; i++ )
{
getchar();
for ( j=0; j<m; j++ )
{
scanf("%c", &ar[i][j]);
if ( ar[i][j]>temp[j] ) temp[... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 1330c11eb56ec2a9bc048c92d9926a8e | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,m,i,j,l=0;
char x[100][100],y[100];
scanf("%d%d",&n,&m);
for(i=0;i<m;i++)
y[i]='0';
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{
scanf(" %c",&x[i][j]);
if(x[i][j]>y[j])
y[j]=x[i][j];
... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 037ad7624c3181eed7f60cf7e0944f97 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include<stdio.h>
int main(){
int n, m;
scanf("%d%d", &n, &m);
int i, j, arr[n];
char a[n][m];
for(i = 0; i < n; i++){
scanf("%s", a[i]);
arr[i] = 0;
}
int sum = 0;
char max;
for(j = 0; j < m; j++){
max = a[0][j];
for(i = 0; i < n; i++){
... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number — the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | af295440f788076d7fac4734ddecf932 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <string.h>
#include <stdio.h>
int main()
{
int n,m;
scanf("%d %d\n",&n,&m);
char a[n][m];
int i,j;
for(i=0;i<n;i++)
{
scanf("%s",a[i]);
}
int k,l,o,p;
char max;
int y[n*m],t=1;
for(i=0;i<m;i++)
{
max=a[0][i];
... | |
You are given a matrix of size n × m. Each element of the matrix is either 1 or 0. You have to determine the number of connected components consisting of 1's. Two cells belong to the same component if they have a common border, and both elements in these cells are 1's.Note that the memory limit is unusual! | Print the number of connected components consisting of 1's. | C | 78b319ee682fa8c4dab53e0fcd018255 | cb1e0f0f76cc57c19d82b2bbed1c9126 | GNU C11 | standard output | 16 megabytes | train_001.jsonl | [
"dsu"
] | 1509113100 | ["3 4\n1\nA\n8", "2 8\n5F\nE3", "1 4\n0"] | NoteIn the first example the matrix is: 000110101000It is clear that it has three components.The second example: 0101111111100011It is clear that the number of components is 2.There are no 1's in the third example, so the answer is 0. | PASSED | 2,500 | standard input | 3 seconds | The first line contains two numbers n and m (1 ≤ n ≤ 212, 4 ≤ m ≤ 214) — the number of rows and columns, respectively. It is guaranteed that m is divisible by 4. Then the representation of matrix follows. Each of n next lines contains one-digit hexadecimal numbers (that is, these numbers can be represented either as d... | ["3", "2", "0"] | /* practice with Dukkha */
#include <stdio.h>
#include <string.h>
#define M (1 << 14)
int dsu[M * 2];
int find(int i) {
return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i]));
}
int join(int i, int j) {
i = find(i);
j = find(j);
if (i == j)
return 0;
if (dsu[i] > dsu[j])
dsu[i] = j;
else {
if (dsu[i] == dsu[j]... | |
You are given a matrix of size n × m. Each element of the matrix is either 1 or 0. You have to determine the number of connected components consisting of 1's. Two cells belong to the same component if they have a common border, and both elements in these cells are 1's.Note that the memory limit is unusual! | Print the number of connected components consisting of 1's. | C | 78b319ee682fa8c4dab53e0fcd018255 | dbbc5d37a3d57bdd8b8b18e29ca36102 | GNU C | standard output | 16 megabytes | train_001.jsonl | [
"dsu"
] | 1509113100 | ["3 4\n1\nA\n8", "2 8\n5F\nE3", "1 4\n0"] | NoteIn the first example the matrix is: 000110101000It is clear that it has three components.The second example: 0101111111100011It is clear that the number of components is 2.There are no 1's in the third example, so the answer is 0. | PASSED | 2,500 | standard input | 3 seconds | The first line contains two numbers n and m (1 ≤ n ≤ 212, 4 ≤ m ≤ 214) — the number of rows and columns, respectively. It is guaranteed that m is divisible by 4. Then the representation of matrix follows. Each of n next lines contains one-digit hexadecimal numbers (that is, these numbers can be represented either as d... | ["3", "2", "0"] | #include <stdio.h>
#include <string.h>
#include <ctype.h>
#define uLL unsigned long long
long FPC;
long right[200000],pre[200000],left[200000];
void DynamicAllocation(uLL size)
{
long i;
FPC=2;
for (i=FPC;i<=size;i++){right[i]=i+1;}right[i]=0;
}
long Allocate()
{
long i,j,k;
k=FPC;FPC=right[FPC];pre[k]=0;left[k]=0... | |
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right.Unfortunately, Joe di... | Print a single number — the maximum number of diamonds Joe can steal. | C | b81e7a786e4083cf7188f718bc045a85 | 2367c17ccf3241efe25632ca13f4182d | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy",
"math"
] | 1308236400 | ["2 3 1\n2 3", "3 2 2\n4 1 3"] | NoteIn the second sample Joe can act like this:The diamonds' initial positions are 4 1 3.During the first period of time Joe moves a diamond from the 1-th cell to the 2-th one and a diamond from the 3-th cell to his pocket.By the end of the first period the diamonds' positions are 3 2 2. The check finds no difference a... | PASSED | 1,800 | standard input | 1 second | The first line contains integers n, m and k (1 ≤ n ≤ 104, 1 ≤ m, k ≤ 109). The next line contains n numbers. The i-th number is equal to the amount of diamonds in the i-th cell — it is an integer from 0 to 105. | ["0", "2"] | int main(){
int n,m,k,i,j;
scanf("%d%d%d",&n,&m,&k);
int ar[n];
for(i=0;i<n;i++) scanf("%d",&ar[i]);
if(!(n&1)){ printf("0\n");return 0;}
int p=(n+1)>>1;
m/=p;
int min=1<<29;
for(i=0;i<n;i+=2){min=min<ar[i]?min:ar[i];}
printf("%d\n",(((long long)m)*k)<min?(((long long)m)*k):min);... | |
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right.Unfortunately, Joe di... | Print a single number — the maximum number of diamonds Joe can steal. | C | b81e7a786e4083cf7188f718bc045a85 | e637407587d7966f69664e43f9ff72e2 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy",
"math"
] | 1308236400 | ["2 3 1\n2 3", "3 2 2\n4 1 3"] | NoteIn the second sample Joe can act like this:The diamonds' initial positions are 4 1 3.During the first period of time Joe moves a diamond from the 1-th cell to the 2-th one and a diamond from the 3-th cell to his pocket.By the end of the first period the diamonds' positions are 3 2 2. The check finds no difference a... | PASSED | 1,800 | standard input | 1 second | The first line contains integers n, m and k (1 ≤ n ≤ 104, 1 ≤ m, k ≤ 109). The next line contains n numbers. The i-th number is equal to the amount of diamonds in the i-th cell — it is an integer from 0 to 105. | ["0", "2"] | #include<stdio.h>
#include<stdlib.h>
#define MIN(x,y) ((x<y)?(x):(y))
int main(void){
unsigned int n,m,k;
unsigned int i,j;
unsigned int *cell;
unsigned int min=100001;
scanf("%u %u %u",&n,&m,&k);
if(n%2==0 || (n+1)/2>m){
for(i=0;i<n;i++) scanf("%u",&j);
puts("0");
return 0;
}
cell=(uns... | |
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right.Unfortunately, Joe di... | Print a single number — the maximum number of diamonds Joe can steal. | C | b81e7a786e4083cf7188f718bc045a85 | d81bd74db5cb4bddefb6b5bb25e57f1f | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy",
"math"
] | 1308236400 | ["2 3 1\n2 3", "3 2 2\n4 1 3"] | NoteIn the second sample Joe can act like this:The diamonds' initial positions are 4 1 3.During the first period of time Joe moves a diamond from the 1-th cell to the 2-th one and a diamond from the 3-th cell to his pocket.By the end of the first period the diamonds' positions are 3 2 2. The check finds no difference a... | PASSED | 1,800 | standard input | 1 second | The first line contains integers n, m and k (1 ≤ n ≤ 104, 1 ≤ m, k ≤ 109). The next line contains n numbers. The i-th number is equal to the amount of diamonds in the i-th cell — it is an integer from 0 to 105. | ["0", "2"] | #include <stdio.h>
long long min(long long a, long long b)
{
if (a < b) {
return a;
} else {
return b;
}
}
int main()
{
int n, m, k, p = 100000, i;
int a[10000];
scanf("%d %d %d", &n, &m, &k);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
if (i % 2 == 0 && a[i] < p) p... | |
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right.Unfortunately, Joe di... | Print a single number — the maximum number of diamonds Joe can steal. | C | b81e7a786e4083cf7188f718bc045a85 | 9966b584cca541d5b849b7b4959494fc | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy",
"math"
] | 1308236400 | ["2 3 1\n2 3", "3 2 2\n4 1 3"] | NoteIn the second sample Joe can act like this:The diamonds' initial positions are 4 1 3.During the first period of time Joe moves a diamond from the 1-th cell to the 2-th one and a diamond from the 3-th cell to his pocket.By the end of the first period the diamonds' positions are 3 2 2. The check finds no difference a... | PASSED | 1,800 | standard input | 1 second | The first line contains integers n, m and k (1 ≤ n ≤ 104, 1 ≤ m, k ≤ 109). The next line contains n numbers. The i-th number is equal to the amount of diamonds in the i-th cell — it is an integer from 0 to 105. | ["0", "2"] | #include<stdio.h>
int main()
{
long long n,m,k,i;
long long a[10000],j,x,y,z,w;
scanf("%lld%lld%lld",&n,&m,&k);
for(i=0;i<n;i++)
scanf("%lld",&a[i]);
if(n%2==0)
printf("0");
else
{
j=(long long)m*k;
x=n/2+1;
w=(long long)m/x;//num of removals per sec.
y=a[0];
for(i=0... | |
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right.Unfortunately, Joe di... | Print a single number — the maximum number of diamonds Joe can steal. | C | b81e7a786e4083cf7188f718bc045a85 | 7619d24e3735a2d9439efdceb9a737db | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy",
"math"
] | 1308236400 | ["2 3 1\n2 3", "3 2 2\n4 1 3"] | NoteIn the second sample Joe can act like this:The diamonds' initial positions are 4 1 3.During the first period of time Joe moves a diamond from the 1-th cell to the 2-th one and a diamond from the 3-th cell to his pocket.By the end of the first period the diamonds' positions are 3 2 2. The check finds no difference a... | PASSED | 1,800 | standard input | 1 second | The first line contains integers n, m and k (1 ≤ n ≤ 104, 1 ≤ m, k ≤ 109). The next line contains n numbers. The i-th number is equal to the amount of diamonds in the i-th cell — it is an integer from 0 to 105. | ["0", "2"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define N 10005
#define LL long long
int a[N];
int n, m, k;
void init()
{
// freopen( "input.txt", "r", stdin );
int i, o, p, j;
scanf( "%d %d %d", &n, &m, &k );
for (i=0;i<n;++i)
scanf( "%d", &a[i] );
}
void work()
{
int i, o, j;... | |
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right.Unfortunately, Joe di... | Print a single number — the maximum number of diamonds Joe can steal. | C | b81e7a786e4083cf7188f718bc045a85 | f5e0174257717b1e432b9f253a67bb9b | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy",
"math"
] | 1308236400 | ["2 3 1\n2 3", "3 2 2\n4 1 3"] | NoteIn the second sample Joe can act like this:The diamonds' initial positions are 4 1 3.During the first period of time Joe moves a diamond from the 1-th cell to the 2-th one and a diamond from the 3-th cell to his pocket.By the end of the first period the diamonds' positions are 3 2 2. The check finds no difference a... | PASSED | 1,800 | standard input | 1 second | The first line contains integers n, m and k (1 ≤ n ≤ 104, 1 ≤ m, k ≤ 109). The next line contains n numbers. The i-th number is equal to the amount of diamonds in the i-th cell — it is an integer from 0 to 105. | ["0", "2"] | #include<stdio.h>
int a[10000];
int n,m,k;
int main() {
int i,mn=100000000,t,ret=0;
scanf("%d %d %d",&n,&m,&k);
if (n%2==0) {
puts("0");
return 0;
}
for(i=0;i<n;i++) {
scanf("%d",&a[i]);
if (i%2==0 && a[i]<mn) mn=a[i];
}
t=(n+1)/2;
t=m/t;
for(i=0;i<k;i++) if (t<mn) ret+=t,mn-=t; else ret+=mn,mn=0;
p... | |
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right.Unfortunately, Joe di... | Print a single number — the maximum number of diamonds Joe can steal. | C | b81e7a786e4083cf7188f718bc045a85 | 36609a5b7ff3d9fcc7112dfb0420701d | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"greedy",
"math"
] | 1308236400 | ["2 3 1\n2 3", "3 2 2\n4 1 3"] | NoteIn the second sample Joe can act like this:The diamonds' initial positions are 4 1 3.During the first period of time Joe moves a diamond from the 1-th cell to the 2-th one and a diamond from the 3-th cell to his pocket.By the end of the first period the diamonds' positions are 3 2 2. The check finds no difference a... | PASSED | 1,800 | standard input | 1 second | The first line contains integers n, m and k (1 ≤ n ≤ 104, 1 ≤ m, k ≤ 109). The next line contains n numbers. The i-th number is equal to the amount of diamonds in the i-th cell — it is an integer from 0 to 105. | ["0", "2"] | #include <stdio.h>
#include <stdlib.h>
int arr[100000];
int main()
{
long long n,m,k,min,r;
int i;
scanf("%I64d%I64d%I64d",&n,&m,&k);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
if(n%2==0||m<(n/2+1))
{
printf("0\n");
return;
}
min=arr[0];
for(i=0;i<n;i=i+2)
if(arr[i... | |
You've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections and self-touches. The vertices of both polygons are given in the clockwise order. For each polygon no three consecu... | Print on the only line the answer to the problem — if polygon B is strictly inside polygon A, print "YES", otherwise print "NO" (without the quotes). | C | d9eb0f6f82bd09ea53a1dbbd7242c497 | 08db14c3feaa46b78d3ef40b3438e654 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"geometry"
] | 1332516600 | ["6\n-2 1\n0 3\n3 3\n4 1\n3 -2\n2 -2\n4\n0 1\n2 2\n3 1\n1 0", "5\n1 2\n4 2\n3 -3\n-2 -2\n-2 1\n4\n0 1\n1 2\n4 1\n2 -1", "5\n-1 2\n2 3\n4 1\n3 -2\n0 -3\n5\n1 0\n1 1\n3 1\n5 -1\n2 -1"] | null | PASSED | 2,100 | standard input | 2 seconds | The first line contains the only integer n (3 ≤ n ≤ 105) — the number of vertices of polygon A. Then n lines contain pairs of integers xi, yi (|xi|, |yi| ≤ 109) — coordinates of the i-th vertex of polygon A. The vertices are given in the clockwise order. The next line contains a single integer m (3 ≤ m ≤ 2·104) — the n... | ["YES", "NO", "NO"] | #include <stdio.h>
#define MAXN 100010
#define EPS 1e-6
#define DIMS 2
int N,M;
double A[MAXN][2];
double B[MAXN][2];
double cross(double *a,double *b)
{
return (a[0])*(b[1])-(a[1])*(b[0]);
}
void sub(double *res,double *a,double *b)
{
int i;
for(i=0;i<DIMS;i++)
res[i]=a[i]-b[i];
}
double ab... | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | fdd6d9d21de3fb4da129c988576b4c1c | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include<stdio.h>
int b[1000000];
int main()
{
int n,i,x,y=0;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
b[a[i]]++;
}
for(i=0;i<1000000;i++)
{
if(b[i]%2!=0)
{y=1;
break;
}
}
if(y==1)
printf("Conan");
else
printf("Agasa");
} | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | ead6c58ea377509398b27ea47c27978e | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include<stdio.h>
int main()
{
long n,i,p,max=0,b=2;
scanf("%ld",&n);
int a[100001]={0};
for(i=0;i<n;i++)
{
scanf("%ld",&p);
if(p>max)
max=p;
a[p]++;
}
for(i=max;i>0;i--)
{
if(a[i]%2!=0)
{
b=1;
break;
}
... | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | 9ede17937bdad5ab455e9428b1bf4e6b | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include<stdio.h>
#include<stdbool.h>
int main()
{
long long N,temp;
scanf("%lld",&N);
bool A[100002]={false};
while(N--)
{
scanf("%lld",&temp);
if(A[temp])
A[temp]=false;
else
A[temp]=true;
}
N=100001;
while(N--)
{
if(A[N])
... | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | 3b52400b42eb39282b24f97053eaba86 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include <stdio.h>
int main(void){
int n;
scanf("%d", &n);
int a[100000] = {0};
int temp;
for(int i = 0; i < n ; i++){
scanf("%d", &temp);
a[temp - 1]++;
}
int flag = 0;
for(int i = 0; i < 100000 ; i++){
if(a[i]%2 == 1){
flag = 1;
break;
}
}
if(flag == 1){
printf("Conan\n");
}
else{
print... | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | d16d3a871870bd78c5054b9746326113 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int arr[n],i,counter[100005]={0};
int count=0;
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
counter[arr[i]]++;
}
for(i=0;i<100005;i++)
{
if(counter[i]>0 && counter[i]%2==1)
{
count++;
}
}
if(count==0)
{
printf("Agasa\n");
}
else
{
printf(... | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | f826b9349cc5eeaf12ce6f89c3818407 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include <stdio.h>
void merging(int a[],int low,int mid,int high){
int i,j,k;
int s1=mid-low+1;
int s2=high-mid;
int a1[s1],a2[s2];
for(i=0;i<s1;i++)
a1[i]=a[low+i];
for(i=0;i<s2;i++)
a2[i]=a[mid+1+i];
i=0;j=0;k=low;
while(i<s1 && j<s2)
{
if(a1[i]<=a2[j])
{ a[k]=a1[i];
i++;
}
else
{ a[k]=a... | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | a153c2cfd25a7e1fbbd8b6aed5982fe8 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] |
#include <stdio.h>
#include <stdlib.h>
int cmpfunc(const void *b,const void *c){
return(*(int*)b - *(int*)c);}
int main()
{
int no;
scanf("%d\n",&no);
int a[no];
int c;
c=0;
for(int i=0;i<no;i++){
scanf("%d",&a[i]);}
qsort(a,no,sizeof(int),cmpfunc);
for(int i=0;i<no;i+=... | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | db42486d940c1298ae9ff89cf5572326 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include<stdio.h>
int a[200000];
int main(){
int N,x,i;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&x);
a[x]++;
}
for(i=0;i<=100000;i++)
if(a[i]%2==1){
printf("Conan\n");
return 0;
}
printf("Agasa\n");
return 0;
}
| |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | ddff53371ce086714badb26057920d0f | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include<stdio.h>
int a[1000001];
int result=0;
int main()
{
int n,m;
int max=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&m);
a[m]++;
if(max<m)
{
max=m;
}
}
for(int i=max;i>=0;i--)
{
if(a[i]!=0)
{
if(a[i]%2==0)
result=result^0;
else
... | |
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all car... | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | C | 864593dc3911206b627dab711025e116 | 441020041de4f1ee17b4f13e0e93d2df | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"greedy",
"games"
] | 1516462500 | ["3\n4 5 7", "2\n1 1"] | NoteIn the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when ... | PASSED | 1,200 | standard input | 2 seconds | The first line contains an integer n (1 ≤ n ≤ 105) — the number of cards Conan has. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number on the i-th card. | ["Conan", "Agasa"] | #include <stdio.h>
int main()
{
long long n,s,i;
while(~scanf("%d",&n))
{
long long a[100005]={0};
for(i=0;i<n;i++)
{
scanf("%d",&s);
a[s]++;
}
for(i=100004;i>=0;i--)
{
if(a[i]%2==1)
{
printf("Conan\n");
break;
}
}
if(i==-1)
printf("Agasa\n");
}
ret... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 55098b9e99f0ad9cf0fc3d38c6a13ed0 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1 ≤ k ≤ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≤ |s| ≤ 1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
int main()
{
int k,a[26],i,comp,flag=0,j=0,z;
char in[1001],res[1001];
scanf("%d",&k);
scanf("%s",in);
for(i=0;i<26;i++)
{
a[i]=0;
}
for(i=0;in[i]!='\0';i++)
{
a[in[i]-97]++;
}
i=0;
while(a[i]==0)
{
i++;
}
comp=a[i];
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 75e3367c2fa23cf20c5cb63c1e35375b | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1 ≤ k ≤ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≤ |s| ≤ 1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
main()
{
int k,i,j,y,n,x,l,c[30]={0};
int m[30];
l=0;
char s[1000],r[30];
scanf("%d",&k);
scanf("%s",s);
x=strlen(s);
for(i=1;i<x;i++)
{
y=s[i];
for(j=i-1;j>=0&&y<s[j];j--)
s[j+1]=s[j];
s[j+1]=y;
}
s[i]='\0';
y=0;
j=0;
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 0015c5a852ee22b748c2e3c3d4fcbdc4 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1 ≤ k ≤ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≤ |s| ≤ 1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
int main(){
int k,a[26]={0},s,i;
char c;
scanf("%d",&k);
s=0;
while(scanf("%c",&c)==1){
a[c-'a']++;
s++;
}s-=2;
if(s%k==0){
int b=1,j,k1;
for(i=0;i<26;i++){
if(a[i]%k!=0)b=0;
}
if(b==1){
for(i=0;i<k;i++){
for(j=0;j<26;j++){
int t=a[j]/k;
for(k1=0;k1<t;k1++){
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 9d5070d0f6c3847eca1f996c2f5cdbb8 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1 ≤ k ≤ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≤ |s| ≤ 1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
int main() {
char str[20000], h1[300];
int k, h[30] = {0}, i, f = 1, j, l = 0;
scanf("%d%s",&k,str);
for(i = 0 ; i < strlen(str) ; i++)
++h[str[i]- 'a'];
for(i = 0 ; i < 26 ; i++)
if(h[i] && h[i]%k) {
f = 0;
break;
}
else if(h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.