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 bitwise XOR of the numbers from them is equal to $$$0$$$. Print the maximum number of segments the array can be divided into. Print -1 if no suitable division exists.
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, $$$\{[5, 5, 7], [2]\}$$$ will lead to subsets $$$\{[5, 5, 7]\}$$$ of XOR $$$7$$$, $$$\{[2]\}$$$ of XOR $$$2$$$ and $$$\{[5, 5, 7], [2]\}$$$ of XOR $$$5 \oplus 5 \oplus 7 \oplus 2 = 5$$$.Let's take a look at some division on $$$3$$$ segments — $$$\{[5], [5, 7], [2]\}$$$. It will produce subsets: $$$\{[5]\}$$$, XOR $$$5$$$; $$$\{[5, 7]\}$$$, XOR $$$2$$$; $$$\{[5], [5, 7]\}$$$, XOR $$$7$$$; $$$\{[2]\}$$$, XOR $$$2$$$; $$$\{[5], [2]\}$$$, XOR $$$7$$$; $$$\{[5, 7], [2]\}$$$, XOR $$$0$$$; $$$\{[5], [5, 7], [2]\}$$$, XOR $$$5$$$; As you can see, subset $$$\{[5, 7], [2]\}$$$ has its XOR equal to $$$0$$$, which is unacceptable. You can check that for other divisions of size $$$3$$$ or $$$4$$$, non-empty subset with $$$0$$$ XOR always exists.The second example has no suitable divisions.The third example array can be divided into $$$\{[3], [1], [10]\}$$$. No subset of these segments has its XOR equal to $$$0$$$.
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. For all pairs of vertices i and j, where i ≠ j, there is an edge connecting them if and only if characters si and sj are either equal or neighbouring in the alphabet. That is, letters in pairs "a"-"b" and "b"-"c" are neighbouring, while letters "a"-"c" are not. Vasya painted the resulting graph near the string and then erased the string. Next day Vasya's friend Petya came to a lecture and found some graph at his desk. He had heard of Vasya's adventure and now he wants to find out whether it could be the original graph G, painted by Vasya. In order to verify this, Petya needs to know whether there exists a string s, such that if Vasya used this s he would produce the given graph G.
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 graph built using this string must coincide with G. If there are multiple possible answers, you may print any of them.
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 all three other vertices, but these three vertices are not connected with each other. That means that they must correspond to distinct letters that are not adjacent, but that is impossible as there are only two such letters: a and c.
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 vertexes appear in this list no more than once.
["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<l;)if(i!=n) { if(G[i][n])D(i,x); else D(i,x^1); } return; } int main() { u n,q,i,j; for(scanf("%u%u",&n,&q);q--;G[i][j]=G[j][i]=1) {scanf("%u%u",&i,&j);++S[--i];++S[--j];}l=n; for(i=-1;++i<n;)if(S[i]==n-1)C[i]='b'; for(i=-1;++i<n;)if(!C[i])D(i,0); printf(bad?"No\n":"Yes\n%s\n",C); return 0; }
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. For all pairs of vertices i and j, where i ≠ j, there is an edge connecting them if and only if characters si and sj are either equal or neighbouring in the alphabet. That is, letters in pairs "a"-"b" and "b"-"c" are neighbouring, while letters "a"-"c" are not. Vasya painted the resulting graph near the string and then erased the string. Next day Vasya's friend Petya came to a lecture and found some graph at his desk. He had heard of Vasya's adventure and now he wants to find out whether it could be the original graph G, painted by Vasya. In order to verify this, Petya needs to know whether there exists a string s, such that if Vasya used this s he would produce the given graph G.
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 graph built using this string must coincide with G. If there are multiple possible answers, you may print any of them.
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 all three other vertices, but these three vertices are not connected with each other. That means that they must correspond to distinct letters that are not adjacent, but that is impossible as there are only two such letters: a and c.
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 vertexes appear in this list no more than once.
["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, i, j, k; scanf("%d %d",&n, &m); ans[n]='\0'; n_grp=0; for(i=0;i<n;i++){ n_adj[i]=0; sum[i]=0; adj[i][n_adj[i]++]=i; sum[i]+=i; grp[i]=-1; } for(i=0;i<m;i++){ scanf("%d %d", &j, &k); j--;k--; adj[j][n_adj[j]++]=k; sum[j]+=k; adj[k][n_adj[k]++]=j; sum[k]+=j; } for(i=0;i<n;i++){ qsort(adj[i], n_adj[i], sizeof(int), cmpfunc); } for(i=0;i<n;i++){ if(grp[i]==-1){ grp[i]=n_grp++; for(j=i;j<n;j++){ if(grp[j]==-1 && n_adj[i]==n_adj[j] && sum[i]==sum[j]){ for(k=0;k<n_adj[i];k++){ if(adj[i][k]!=adj[j][k]) break; } if(k==n_adj[i]) grp[j]=grp[i]; } } } } // printf("ngrp %d\n",n_grp); if(n_grp>3){ printf("No\n"); return 0; } if(n_grp==1){ printf("Yes\n"); for(i=0;i<n;i++) printf("a"); printf("\n"); return 0; } for(i=0;i<3;i++){ gcnt[i]=0; gnei[i]=0; revgr[i]=i; for(j=0;j<3;j++){ gneil[i][j]=0; } } for(i=0;i<n;i++){ gcnt[grp[i]]++; } for(i=0;i<n;i++){ for(j=0;j<n_adj[i];j++){ if(grp[i]!=grp[adj[i][j]]){ gneil[grp[i]][grp[adj[i][j]]]=1; gneil[grp[adj[i][j]]][grp[i]]=1; } } } for(i=0;i<3;i++){ for(j=0;j<3;j++){ gnei[i]+=gneil[i][j]; } } i=0;j=1; if(gnei[i]>gnei[j]){ swap(gnei+i, gnei+j); swap(gcnt+i, gcnt+j); swap(revgr+i, revgr+j); } i=1;j=2; if(gnei[i]>gnei[j]){ swap(gnei+i, gnei+j); swap(gcnt+i, gcnt+j); swap(revgr+i, revgr+j); } i=0;j=1; if(gnei[i]>gnei[j]){ swap(gnei+i, gnei+j); swap(gcnt+i, gcnt+j); swap(revgr+i, revgr+j); } if(n_grp==2){ if(gnei[1]==1 && gnei[2]==1){ printf("Yes\n"); for(i=0;i<n;i++){ if(grp[i]==0) ans[i]='a'; else if(grp[i]==1) ans[i]='b'; } printf("%s\n",ans); } else if(gnei[2]==0){ printf("Yes\n"); for(i=0;i<n;i++){ if(grp[i]==0) ans[i]='a'; else if(grp[i]==1) ans[i]='c'; } printf("%s\n",ans); } else{ printf("No\n"); } } else{ if(gnei[0]==1 && gnei[1]==1 && gnei[2]==2){ printf("Yes\n"); for(i=0;i<n;i++){ if(grp[i]==revgr[0]){ ans[i]='a'; } else if(grp[i]==revgr[1]){ ans[i]='c'; } else if(grp[i]==revgr[2]){ ans[i]='b'; } /* for(i=0;i<gcnt[0];i++){ */ /* printf("a"); */ /* } */ /* for(i=0;i<gcnt[2];i++){ */ /* printf("b"); */ /* } */ /* for(i=0;i<gcnt[1];i++){ */ /* printf("c"); */ /* } */ } printf("%s\n",ans); } else{ printf("No\n"); } } return 0; }
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. For all pairs of vertices i and j, where i ≠ j, there is an edge connecting them if and only if characters si and sj are either equal or neighbouring in the alphabet. That is, letters in pairs "a"-"b" and "b"-"c" are neighbouring, while letters "a"-"c" are not. Vasya painted the resulting graph near the string and then erased the string. Next day Vasya's friend Petya came to a lecture and found some graph at his desk. He had heard of Vasya's adventure and now he wants to find out whether it could be the original graph G, painted by Vasya. In order to verify this, Petya needs to know whether there exists a string s, such that if Vasya used this s he would produce the given graph G.
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 graph built using this string must coincide with G. If there are multiple possible answers, you may print any of them.
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 all three other vertices, but these three vertices are not connected with each other. That means that they must correspond to distinct letters that are not adjacent, but that is impossible as there are only two such letters: a and c.
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 vertexes appear in this list no more than once.
["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; edge[y-1][x-1]=1; } for(i=0;i<n;i++) for(j=i;j<n;j++) { if(edge[i][j]==0&&vertice[i]=='b') { vertice[i]='a'; vertice[j]='c'; } else if(edge[i][j]==0&&vertice[i]=='a') { vertice[j]='c'; } else if(edge[i][j]==0&&vertice[i]=='c') { vertice[j]='a'; } } for(i=0;i<n;i++) { if(vertice[i]=='a') { for(j=i;j<n;j++) { if(vertice[j]=='a'&&edge[i][j]==0) { printf("No\n"); return 0; } } for(j=i;j<n;j++) { if(vertice[j]=='c'&&edge[i][j]==1) { printf("No\n"); return 0; } } } } if(judge==0)printf("No\n"); else { printf("Yes\n"); for(i=0;i<n;i++) { printf("%c",vertice[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. For all pairs of vertices i and j, where i ≠ j, there is an edge connecting them if and only if characters si and sj are either equal or neighbouring in the alphabet. That is, letters in pairs "a"-"b" and "b"-"c" are neighbouring, while letters "a"-"c" are not. Vasya painted the resulting graph near the string and then erased the string. Next day Vasya's friend Petya came to a lecture and found some graph at his desk. He had heard of Vasya's adventure and now he wants to find out whether it could be the original graph G, painted by Vasya. In order to verify this, Petya needs to know whether there exists a string s, such that if Vasya used this s he would produce the given graph G.
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 graph built using this string must coincide with G. If there are multiple possible answers, you may print any of them.
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 all three other vertices, but these three vertices are not connected with each other. That means that they must correspond to distinct letters that are not adjacent, but that is impossible as there are only two such letters: a and c.
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 vertexes appear in this list no more than once.
["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!=i;j++) { for(k=1;k<=n && k!=i && k!=j;k++) { if(arr[i][j]==1 && arr[i][k]==1 && arr[j][k]==0) find[i]=2; else if(arr[j][i]==1 && arr[j][k]==1 && arr[i][k]==0) find[j]=2; else if(arr[k][i]==1 && arr[k][j]==1 && arr[i][j]==0) find[k]=2; // else if(find[i]!=0 && find[i]!=2) // flag=1; } } } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(j!=i) { if(arr[i][j]==0 && find[i]==0 && find[j]==0) { find[i]=1; find[j]=3; br=1; break; } } } if(br==1) break; } // for(i=1;i<=n;i++) // printf("%d ",find[i]); // printf("\n"); // for(i=1;i<=n;i++) // { // for(j=1;j<=n;j++) // printf("%d ",arr[i][j]); // printf("\n"); // } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(arr[i][j]==0 && j!=i) { if(find[i]==0 && find[j]==3) find[i]=1; else if(find[i]==0 && find[j]==1) find[i]=3; else if(find[i]==1 && find[j]==0) find[j]=3; else if(find[i]==3 && find[j]==0) find[j]=1; else if(find[i]==find[j] && find[i]!=0 && find[j]!=0) flag=1; } else if(arr[i][j]==1 && j!=i) { if(find[i]==1 && find[j]==3) flag=1; else if(find[i]==3 && find[i]==1) flag=1; } } } // for(i=1;i<=n;i++) // printf("%d ",find[i]); // printf("\n"); for(i=1;i<=n;i++) { for(j=1;j<=n && j!=i;j++) { if(arr[i][j]==0) { if(fabs(find[i]-find[j])!=2) flag=1; } else { if(fabs(find[i]-find[j])==2) flag=1; } } } if(flag==0) { printf("Yes\n"); for(i=1;i<=n;i++) { for(j=1;j<=n &&j!=i;j++) { if(arr[i][j]==1 && find[i]==0) { if(find[i]==0 && find[j]==0) { } else { if(find[j]==0) find[j]=find[i]; else if(find[i]==0) find[i]=find[j]; } } } } for(i=1;i<=n;i++) { if(find[i]==1) printf("a"); else if(find[i]==2) printf("b"); else printf("c"); } printf("\n"); } else printf("No\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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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;i--) { if(a[i]==0) l[i]=l[i+1]+1; else l[i]=l[i+1]; } for(i=1;i<=n;i++) { if(a[i]==1) r[i]=r[i-1]+1; else r[i]=r[i-1]; } if(sum1>sum0) { for(i=1;i<=n;i++) { if(a[i]==1) { sum=sum+l[i]; } } printf("%llu",sum); } else { for(i=n;i>=1;i--) { if(a[i]==0) { sum=sum+(r[i]); } } printf("%llu",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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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[i]+1; else b[i+1]=b[i]; for (i=n;i>=1;i--) if(!a[i]) c[i-1]=c[i]+1; else c[i-1]=c[i]; l=k=0; for (i=1;i<=n;i++) if (!a[i]) l+=b[i]; for (i=n;i>=1;i--) if (a[i]) m+=c[i]; if (l<m) printf("%I64d",l); else printf("%I64d",m); }
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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) { s+=h; } } printf("%I64d\n",s); } 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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; } if(ca > cb) { for(i = n-1;i >= 0;i --) { if(arr[i] == 0)a += cb; else cb -= 1; } printf("%I64d\n",a); } else { for(i = 0;i < n;i ++) { if(arr[i] == 1)b += ca; else ca -= 1; } printf("%I64d\n",b); } } 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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; } } printf("%I64d",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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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++){ if(a[i]==1) sum+=count0; else count0--; } } else if(count1<count0){ for(i=n-1;i>=0;i--){ if(a[i]==0) sum+=count1; else count1--; } } 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 cum[i]=cum[i+1]; } for(i=1;i<=n;++i) { if(x[i]==1) ans=ans+cum[i]; } 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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; } 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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--; } printf("%lld",l); 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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++){ if(arr[i]==1) sum+=count0; else count0--; } } if(count1<count0){ for(i=N-1;i>=0;i--){ if(arr[i]==0) sum+=count1; else count1--; } } 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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[i]==1) sum+=count0; else count0--; } 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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+=count0; else count0--; } 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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++]); if(a[i-1]&&ch) cn=i-1,ch=0; if(cn<0) cn0+=1; if(a[i-1]) c1++; else c0++; } for(i=cn, ans=0;i<n;i+=1){ if(a[i]){ ans+=c0-cn0; } else{ cn0++; } } pf("%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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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[i]; a1=a1+a1v; } } if(a[n]==0) s[n]=1; else s[n]=0; for(i=n-1;i>=1;i--) { if(a[i]==0) s[i]=s[i+1]+1; else s[i]=s[i+1]; } a2=0; for(i=1;i<=n;i++) { if(a[i]==1) { a1v=s[i]; a2=a2+a1v; } } if(a1<a2) printf("%I64d",a1); else printf("%I64d",a2); 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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]); if(A[i]==0) zero++; else one++; } Tzero=zero; for(i=0,Cone=0;i<N;i++) { if(A[i]==1) Cone+=zero; else zero--; } for(i=N-1,Czero=0;i>-1;i--) { if(A[i]==0) Czero+=one; else one--; } if(Czero<Cone) printf("%lld\n",Czero); else printf("%lld\n",Cone); //} 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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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=right=0;i<=n;i++){ scanf("%d",&t); if(t) right++; else left++; a[0][i] = left; a[1][i] = t; } for(i=1;i<=n;i++){ a[0][i] = left - a[0][i]; } for(i=1,count=0;right>0;i++){ if(a[1][i]){ count += a[0][i]; right--; } } printf("%I64d\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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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 milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.
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{ temp++; } } printf("%I64d\n",count); } return 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 task. You are able to do it too, aren't you?Leha has two strings s and t. The hacker wants to change the string s at such way, that it can be found in t as a substring. All the changes should be the following: Leha chooses one position in the string s and replaces the symbol in this position with the question mark "?". The hacker is sure that the question mark in comparison can play the role of an arbitrary symbol. For example, if he gets string s="ab?b" as a result, it will appear in t="aabrbb" as a substring.Guaranteed that the length of the string s doesn't exceed the length of the string t. Help the hacker to replace in s as few symbols as possible so that the result of the replacements can be found in t as a substring. The symbol "?" should be considered equal to any other symbol.
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 of the positions begins from one.
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) min=flag[i]; } printf("%d\n",min); for(i=0;i<=m-n;i++) { if(flag[i]==min) {ind=i;break;} } for(i=0;i<n;i++) { if(a[i]!=b[ind+i]) printf("%d ",i+1); } return 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 task. You are able to do it too, aren't you?Leha has two strings s and t. The hacker wants to change the string s at such way, that it can be found in t as a substring. All the changes should be the following: Leha chooses one position in the string s and replaces the symbol in this position with the question mark "?". The hacker is sure that the question mark in comparison can play the role of an arbitrary symbol. For example, if he gets string s="ab?b" as a result, it will appear in t="aabrbb" as a substring.Guaranteed that the length of the string s doesn't exceed the length of the string t. Help the hacker to replace in s as few symbols as possible so that the result of the replacements can be found in t as a substring. The symbol "?" should be considered equal to any other symbol.
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 of the positions begins from one.
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<lt - ls + 1; i++){ m = 0; cnt = 0; for(j=i;j<i+ls;j++){ if(t[j] == s[m]){ cnt++; //printf("%d ", cnt); } m++; } //printf("%d", cnt); boro[i] = cnt; } /*printf("\n"); for(i=0;i<lt-ls+1;i++){ printf("%d\n", boro[i]); } printf("\n");*/ int max; max = boro[0]; for(i=1;i<lt-ls+1;i++){ if(boro[i] > max){ max = boro[i]; idx = i; } } //if(max == ls) printf("0"); //else{ printf("%d\n", ls - max); //printf("%d\n", idx); int mn = 0; for(i=idx;i<ls+idx;i++){ //printf("%c %c", t[i], s[mn]); if(t[i] != s[mn]) printf("%d ",mn+1); mn++; } //} }
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 task. You are able to do it too, aren't you?Leha has two strings s and t. The hacker wants to change the string s at such way, that it can be found in t as a substring. All the changes should be the following: Leha chooses one position in the string s and replaces the symbol in this position with the question mark "?". The hacker is sure that the question mark in comparison can play the role of an arbitrary symbol. For example, if he gets string s="ab?b" as a result, it will appear in t="aabrbb" as a substring.Guaranteed that the length of the string s doesn't exceed the length of the string t. Help the hacker to replace in s as few symbols as possible so that the result of the replacements can be found in t as a substring. The symbol "?" should be considered equal to any other symbol.
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 of the positions begins from one.
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<lt - ls + 1; i++){ m = 0; cnt = 0; for(j=i;j<i+ls;j++){ if(t[j] == s[m]){ cnt++; //printf("%d ", cnt); } m++; } //printf("%d", cnt); boro[i] = cnt; } /*printf("\n"); for(i=0;i<lt-ls+1;i++){ printf("%d\n", boro[i]); } printf("\n");*/ int max; max = boro[0]; for(i=1;i<lt-ls+1;i++){ if(boro[i] > max){ max = boro[i]; idx = i; } } if(max == ls) printf("0"); else{ printf("%d\n", ls - max); //printf("%d\n", idx); int mn = 0; for(i=idx;i<ls+idx;i++){ //printf("%c %c", t[i], s[mn]); if(t[i] != s[mn]) printf("%d ",mn+1); mn++; } } }
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 task. You are able to do it too, aren't you?Leha has two strings s and t. The hacker wants to change the string s at such way, that it can be found in t as a substring. All the changes should be the following: Leha chooses one position in the string s and replaces the symbol in this position with the question mark "?". The hacker is sure that the question mark in comparison can play the role of an arbitrary symbol. For example, if he gets string s="ab?b" as a result, it will appear in t="aabrbb" as a substring.Guaranteed that the length of the string s doesn't exceed the length of the string t. Help the hacker to replace in s as few symbols as possible so that the result of the replacements can be found in t as a substring. The symbol "?" should be considered equal to any other symbol.
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 of the positions begins from one.
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, st2); for(i = 0; i<=m-n; i++) { c = 0; for(j = 0; j<n; j++) { if(st1[j]==st2[i+j]) { c++; } } if(c>max) {max = c; k = i;} } printf("%d\n", n-max); for(i = 0; i<n; i++) { if(st1[i]!=st2[k]) printf("%d ", i+1); k++; } }
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 task. You are able to do it too, aren't you?Leha has two strings s and t. The hacker wants to change the string s at such way, that it can be found in t as a substring. All the changes should be the following: Leha chooses one position in the string s and replaces the symbol in this position with the question mark "?". The hacker is sure that the question mark in comparison can play the role of an arbitrary symbol. For example, if he gets string s="ab?b" as a result, it will appear in t="aabrbb" as a substring.Guaranteed that the length of the string s doesn't exceed the length of the string t. Help the hacker to replace in s as few symbols as possible so that the result of the replacements can be found in t as a substring. The symbol "?" should be considered equal to any other symbol.
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 of the positions begins from one.
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; for (j=0;j<n;j++) { if (t[i + j] == s[j]) { match++; } } if (match > max) { max = match; pos = i; } } printf("%d\n", n - max); for (i=0;i<n;i++) { if (s[i] != t[i + pos]) { printf("%d ", i + 1); } }printf("\n"); return 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 task. You are able to do it too, aren't you?Leha has two strings s and t. The hacker wants to change the string s at such way, that it can be found in t as a substring. All the changes should be the following: Leha chooses one position in the string s and replaces the symbol in this position with the question mark "?". The hacker is sure that the question mark in comparison can play the role of an arbitrary symbol. For example, if he gets string s="ab?b" as a result, it will appear in t="aabrbb" as a substring.Guaranteed that the length of the string s doesn't exceed the length of the string t. Help the hacker to replace in s as few symbols as possible so that the result of the replacements can be found in t as a substring. The symbol "?" should be considered equal to any other symbol.
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 of the positions begins from one.
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; j++) { if(t[i+j]==s[j]) match++; } if(match>maxmatch) { maxmatch = match; pos = i; } } printf("%d\n",n-maxmatch); for(i=0; i<n; i++) { if(s[i]!=t[i+pos]) printf("%d ",i+1); } printf("\n"); return 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 task. You are able to do it too, aren't you?Leha has two strings s and t. The hacker wants to change the string s at such way, that it can be found in t as a substring. All the changes should be the following: Leha chooses one position in the string s and replaces the symbol in this position with the question mark "?". The hacker is sure that the question mark in comparison can play the role of an arbitrary symbol. For example, if he gets string s="ab?b" as a result, it will appear in t="aabrbb" as a substring.Guaranteed that the length of the string s doesn't exceed the length of the string t. Help the hacker to replace in s as few symbols as possible so that the result of the replacements can be found in t as a substring. The symbol "?" should be considered equal to any other symbol.
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 of the positions begins from one.
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; ni++) { if (t[mi + ni] == s[ni]) { let_rep--; } } if (let_rep < sm_let_rep) { sm_let_rep = let_rep; sm_let = mi; } } printf("%i\n", sm_let_rep); for (mi = sm_let, ni = 0; mi < sm_let + n; mi++, ni++) { if (t[mi] != s[ni]) { printf("%i ", ni + 1); } } return EXIT_SUCCESS; }
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 prophecy says that if the total number of surviving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. If the total number of surviving residents is odd, Stannis wins and everything goes in the completely opposite way.Lord Petyr Baelish wants to know which candidates to the throne he should support, and therefore he wonders, which one of them has a winning strategy. Answer to this question of Lord Baelish and maybe you will become the next Lord of Harrenholl.
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 burns the city with one resident, or vice versa. In any case, the last remaining city will be inhabited by two people, that is, the total sum is even, and hence Daenerys wins.
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; else if (l % 2 == 0) odd = 0; else { m = l / 2; /* l == m * 2 + 1 */ if (e > m + 1 || o > m + 1) odd = 1; else /* e == m + 1 && o == m + 1 */ odd = k % 2; } printf(odd ? "Stannis\n" : "Daenerys\n"); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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]; } } for (i=0;i<n;i++){ for(j=0;j<n;j++){ if(a[M-1][i] > a[j][M-1]) ans ++; } } printf("%i",ans); return 0-0-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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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++) { if(a[j][1]>a[h][0]) { c++; } } } printf("%d", c); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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]) { c++; } } } printf("%d", c); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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++) { for(j=0;j<n;j++) { row[i]=row[i]+G[i][j]; } } for(j=0;j<n;j++) { for(i=0;i<n;i++) { col[j]=col[j]+G[i][j]; } } for(j=0;j<n;j++) { for(i=0;i<n;i++) { if(col[j]>row[i]) { k++; } } } printf("%d",k); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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++){ sum_r=0,sum_c=0; for(j=0; j<n; j++){ sum_r += a[x][j]; } y=0; for(i=0; y<n; i++){ sum_c += a[i][y]; if((n-i)==1){ if(sum_c>sum_r){counter ++;} sum_c=0; i=-1,y++; } } } printf("%d\n",counter); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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+=a[j][i]; } r[i]=x; c[i]=y; } for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(c[i]>r[j]){ count++; } } } printf("%d",count); }
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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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) {s1[x]=0; for(j=0;j<n;j++) { if(x>=0&&x<n){s1[x]=s1[x]+tab[j][i];} if(x>=n&&x<2*n){s1[x]=s1[x]+tab[i][j];} } i++; x++; if(x==n){i=0;} } for(i=0;i<n;i++) { for(j=n;j<2*n;j++) { if(s1[i]>s1[j]) { c++; } } } printf("%d",c); }
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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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) {s1[x]=0; for(j=0;j<n;j++) { if(x>=0&&x<n){s1[x]=s1[x]+tab[j][i];} if(x>=n&&x<2*n){s1[x]=s1[x]+tab[i][j];} } i++; x++; if(x==n){i=0;} } for(i=0;i<n;i++) { for(j=n;j<2*n;j++) { if(s1[i]>s1[j]) { c++; } } } printf("%d",c); }
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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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) {s1[x]=0; for(j=0;j<n;j++) { if(x>=0&&x<n){s1[x]=s1[x]+tab[j][i];} if(x>=n&&x<2*n){s1[x]=s1[x]+tab[i][j];} } i++; x++; if(x==n){i=0;} } for(i=0;i<n;i++) { for(j=n;j<2*n;j++) { if(s1[i]>s1[j]) { c++; } } } printf("%d",c); }
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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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]; } for(j=0;j<t;j++) { sum2=0; for(k=0;k<t;k++) { sum2=sum2+a[k][j]; } if(sum2>sum1) { count++; } } } printf("%d\n", count); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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') { j++; scanf("%d",&ar[i][j]); } } for(l=0;l<n;l++) { for(i=0;i<n;i++) { check = 0 ; for(j=0;j<n;j++) { check=check-ar[i][j]+ar[j][l]; } if(check>0) { a++; } } } printf("%d\n",a); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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++) { sum[i] += input[j][i]; } } int count = 0; for(int i = 0;i<tc;i++) { for(int j = 0;j<tc;j++) { if(total[i] < sum[j]) { count++; } } } printf("%d\n",count); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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[i]) c++; } printf("%d",c); }
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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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[length],colsum[width],step,sum,count=0; step=0; rep (i,0,length) { sum=0; rep (j,0,width) sum+=*((biarr+step)+j); step+=width; rowsum[i]=sum; } rep (j,0,width) { sum=0; step=0; rep (i,0,length) { sum+=*((biarr+step)+j); step+=width; } colsum[j]=sum; } rep (i,0,length) { rep (j,0,width) { if (colsum[j]>rowsum[i]) count++; } } return count; } int main() { int len; scanf("%d\n",&len); int board[len][len]; scan(board,len,len); printf("%d",winning(board,len,len)); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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(sum2>sum1) sum++; } } printf("%d",sum); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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=0;x<n;x++) { rsum+=a[i][x]; csum+=a[x][j]; } if(csum>rsum){c++;} rsum=0;csum=0; } } printf("%d",c); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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]; sumc+=x[j][s]; } if(sumc>sumr) win++; }} printf("%d",win); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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++) { row=row+s[i][k]; } for(k=0;k<n;k++) { col=col+s[k][j]; } if(col>row) { p=p+1; } row=0; col=0; } } printf("%d",p); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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++) { scanf("%d",&a[i][j]); } } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { int p; p=sumofno(i,j,n,a); if(p==1) { s++; //printf("%d ",a[i][j]); } } } printf("%d",s); return 0; } int sumofno(int i,int j,int n,int a[n][n]) { int r=0,c=0; for(int x=0;x<n;x++) { r+=a[i][x]; } for(int x=0;x<n;x++) { c+=a[x][j]; } if(c>r) return 1; else 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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]) { c++; } } } printf("%d", c); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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]; } } for(i=0;i<n;i++){ sumColumn[i]=0; for(j=0;j<n;j++){ sumColumn[i]=sumColumn[i]+board[j][i]; } } int counter=0; for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(sumColumn[i]>sumRow[j]){ counter++; } } } printf("%d",counter); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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(j=0;j<n;j++) { for(l=0,sum1=0;l<n;l++) sum1+=array[l][j]; col[j]=sum1; } } row[k]=sum; k++; } for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(col[j]>row[i]) count++; } } printf("%d\n",count); 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 of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 &gt; 19.
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][row]; } for(int coloumn = 0; coloumn < n; coloumn++){ sumkolom += a[coloumn][j]; } if(sumbaris < sumkolom) cnt++; sumbaris = 0; sumkolom = 0; } } printf("%d", cnt); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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]; } } for( j = 0; j < n; j++) { if(A[j][i] == max) A[j][i] = '0'; } } for( i = 0; i < n; i++) { for( j = 0; j < m; j++) { if(A[i][j] == '0') { c++; break; } } } printf("%d",c); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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++) for(j=0;j<m;j++) if(a[i][j]==b[j]) {k++;break;} printf("%d",k); }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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[j]=ar[i][j]; } } for ( i=0; i<n; i++ ) { for ( j=0; j<m; j++ ) { if ( ar[i][j]==temp[j] ) arr[i]++; } } for ( i=0; i<n; i++ ) { if ( arr[i]>0 ) cnt++; } printf("%d\n", cnt); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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]) max[j]=x; } } for(i=0;i<n;i++) { for(j=0;j<m;j++) { x=ch[i][j]-'0'; if(x==max[j]) { count++; break; } } } printf("%d\n",count); }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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 < n; i++) { scanf("%s", s[i]); suc[i] = 0; } for ( j = 0; j < m; j++) { max = '0'; for (i = 0; i < n; i++) if (s[i][j]>max) max = s[i][j]; for (i = 0; i < n; i++) if (s[i][j] == max) suc[i] = 1; } for (i = 0; i < n; i++) if (suc[i] == 1) c++; printf("%d", c); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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 < n; i++) { scanf("%s", s[i]); suc[i] = 0; } for ( j = 0; j < m; j++) { max = '0'; for (i = 0; i < n; i++) if (s[i][j]>max) max = s[i][j]; for (i = 0; i < n; i++) if (s[i][j] == max) suc[i] = 1; } for (i = 0; i < n; i++) if (suc[i] == 1) c++; printf("%d", c); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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++; break; } } } printf("%d\n", 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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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("%s",kh[i]); } m=0; k=0; for(k=0; k<a; k++) for(i=0; i<b; i++) { l=0; for(j=0; j<a; j++) { if((kh[k][i]-'0')<(kh[j][i]-'0') && j!=k) { l=1; break; } } if( l==0) { m++; break; } } printf("%d",m); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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; ++i){ max = 0; for(int j=0; j<students; ++j){ if(marks[j][i] > max) max = marks[j][i]; } for(int j=0; j<students; ++j){ if(marks[j][i] == max) succesful[j] = 1; } } int sum=0; for(int i=0; i<students; ++i){ if(succesful[i] == 1) ++sum; } printf("%d", sum); } int power(int a, int b){ int result=a; for(int i=0; i<b-1; ++i){ result *= a; } return result; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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; ++i){ max = 0; for(int j=0; j<students; ++j){ if(marks[j][i] > max) max = marks[j][i]; } for(int j=0; j<students; ++j){ if(marks[j][i] == max) succesful[j] = 1; } } int sum=0; for(int i=0; i<students; ++i){ if(succesful[i] == 1) ++sum; } printf("%d", sum); } int power(int a, int b){ int result=a; for(int i=0; i<b-1; ++i){ result *= a; } return result; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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[j]=ar[i][j]; } } for ( i=0; i<n; i++ ) { for ( j=0; j<m; j++ ) { if ( ar[i][j]==temp[j] ) arr[i]++; } } for ( i=0; i<n; i++ ) { if ( arr[i]>0 ) cnt++; } printf("%d\n", cnt); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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]; } for(i=0;i<n;i++) for(j=0;j<m;j++) if(x[i][j]==y[j]) { l++; break; } printf("%d",l); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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++){ if(max < a[i][j]){ max = a[i][j]; } } for(i = 0; i < n; i++){ if(max == a[i][j]) arr[i] = 1; } } for(i = 0; i < n; i++){ sum += arr[i]; } printf("%d\n", sum); return 0; }
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 subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.Your task is to find the number of successful students in the group.
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]; for(j=0;j<n;j++) { if(a[j][i]>max) max=a[j][i]; } for(k=0;k<n;k++) { if(a[k][i]==max){ y[t]=k+1; t++; } } } int q; int c=0; for(q=1;q<=n;q++) { for(int u=1;u<t;u++) { if(y[u]==q) { c++; break; } } } printf("%d",c); }
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 digits from 0 to 9 or as uppercase Latin letters from A to F). Binary representation of each of these numbers denotes next 4 elements of the matrix in the corresponding row. For example, if the number B is given, then the corresponding elements are 1011, and if the number is 5, then the corresponding elements are 0101. Elements are not separated by whitespaces.
["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]) dsu[i]--; dsu[j] = i; } return 1; } int main() { static int aa[M], bb[M], jj[M * 2]; static char cc[M / 4 + 1]; int n, m, h, i, j, ans; scanf("%d%d", &n, &m); memset(dsu, -1, m * 2 * sizeof *dsu); ans = 0; for (i = 0; i < n; i++) { scanf("%s", cc); for (j = 0; j < m / 4; j++) { char c = cc[j]; int b = '0' <= c && c <= '9' ? c - '0' : c - 'A' + 10; for (h = 0; h < 4; h++) bb[j * 4 + h] = b >> 3 - h & 1; } for (j = 0; j < m; j++) if (bb[j] == 1) { ans++; if (aa[j] == 1) ans -= join(j, m + j); if (j > 0 && bb[j - 1] == 1) ans -= join(m + j - 1, m + j); } for (j = 0; j < m; j++) { aa[j] = bb[j]; bb[j] = bb[j] == 0 ? -1 : find(m + j); } memset(dsu, -1, m * 2 * sizeof *dsu); memset(jj, -1, m * 2 * sizeof *jj); for (j = 0; j < m; j++) { int b = bb[j]; if (b != -1) { if (jj[b] != -1) join(jj[b], j); jj[b] = j; } } } printf("%d\n", ans); return 0; }
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 digits from 0 to 9 or as uppercase Latin letters from A to F). Binary representation of each of these numbers denotes next 4 elements of the matrix in the corresponding row. For example, if the number B is given, then the corresponding elements are 1011, and if the number is 5, then the corresponding elements are 0101. Elements are not separated by whitespaces.
["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; return k; } void Release(long p) { right[p]=FPC;FPC=p; } int legal(char ch) { if (isdigit(ch)!=0) { return ch-'0'; } if ((ch>='A')&&(ch<='F')) {return ch+10-'A';} return -1; } void swap(long **num,long **num2) { long *t; t=*num;*num=*num2;*num2=t; } long root(long a) { if (pre[a]>0) {pre[a]=root(pre[a]);return pre[a];} return a; } int join(long a,long b) { long r1,r2; r1=root(a);r2=root(b); if (r1==r2) {return 0;} pre[r1]=r2; return r2; } char str[1000000],*str2; long temp[1000000]; long head=0; void print(long *a,long size) {long i;for (i=0;i<size;i++) {printf("%ld ",a[i]);}printf("%ld\n",a[i]);} int main() { // freopen("in.in","r",stdin); long i,j,k,a,b,c,ans1,ans2,n,m,l,ii; long *num,*num2,*last; scanf("%ld %ld",&n,&m); DynamicAllocation(150000); gets(str);str2=str; num=temp;num2=temp+200000;num[0]=0;num[m+1]=0; memset(num2,0,sizeof(*num2)*(m+2)); ans1=0;ans2=0;head=0; // printf("%ld %ld\n",n,m); for (ii=1;ii<=n;ii++) { for (j=1;j<=m/4;j++) { while (legal(*str2)==-1) {if (*str2=='\0') {gets(str);str2=str;} else {str2+=1;}} l=legal(*str2); for (k=3;k>=0;k--) { ans1+=l&1; num[4*(j-1)+k+1]=l&1; l=l>>1; } str2+=1; } // print(num2,m); // print(num,m); for (i=head,last=&head;i>0;i=*last) { if (left[i]==0) {*last=right[i];Release(i);} else {left[i]=0;last=&right[i];} } for (i=1;i<=m;i++) { a=num2[i]; if (a>0){if (num[i]>0) {num[i]=a;ans2+=1;}} } for (i=1;i<=m;i++) { if (num[i]>0) { if (num[i]==1) { if (num[i-1]==0) {num[i]=Allocate();right[num[i]]=head;head=num[i];} else {num[i]=num[i-1];ans2+=1;} } else { if (num[i-1]>0) {ans2+=(join(num[i-1],num[i])!=0);} } } // print(num,m); } for (i=1;i<=m;i++) { // printf("%ld %ld %ld\n",num[i],i,root(2)); if (num[i]>0) {num[i]=root(num[i]);left[num[i]]=1;} } // print(num,m);printf("%ld %ld\n",ans1,ans2); swap(&num,&num2); } // printf("%ld %ld\n",ans1,ans2); printf("%ld\n",ans1-ans2); return 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 didn't switch the last security system off. On the plus side, he knows the way it works.Every minute the security system calculates the total amount of diamonds for each two adjacent cells (for the cells between whose numbers difference equals 1). As a result of this check we get an n - 1 sums. If at least one of the sums differs from the corresponding sum received during the previous check, then the security system is triggered.Joe can move the diamonds from one cell to another between the security system's checks. He manages to move them no more than m times between two checks. One of the three following operations is regarded as moving a diamond: moving a diamond from any cell to any other one, moving a diamond from any cell to Joe's pocket, moving a diamond from Joe's pocket to any cell. Initially Joe's pocket is empty, and it can carry an unlimited amount of diamonds. It is considered that before all Joe's actions the system performs at least one check.In the morning the bank employees will come, which is why Joe has to leave the bank before that moment. Joe has only k minutes left before morning, and on each of these k minutes he can perform no more than m operations. All that remains in Joe's pocket, is considered his loot.Calculate the largest amount of diamonds Joe can carry with him. Don't forget that the security system shouldn't be triggered (even after Joe leaves the bank) and Joe should leave before morning.
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 and the security system doesn't go off.During the second period Joe moves a diamond from the 3-rd cell to the 2-nd one and puts a diamond from the 1-st cell to his pocket.By the end of the second period the diamonds' positions are 2 3 1. The check finds no difference again and the security system doesn't go off.Now Joe leaves with 2 diamonds in his pocket.
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); return 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 didn't switch the last security system off. On the plus side, he knows the way it works.Every minute the security system calculates the total amount of diamonds for each two adjacent cells (for the cells between whose numbers difference equals 1). As a result of this check we get an n - 1 sums. If at least one of the sums differs from the corresponding sum received during the previous check, then the security system is triggered.Joe can move the diamonds from one cell to another between the security system's checks. He manages to move them no more than m times between two checks. One of the three following operations is regarded as moving a diamond: moving a diamond from any cell to any other one, moving a diamond from any cell to Joe's pocket, moving a diamond from Joe's pocket to any cell. Initially Joe's pocket is empty, and it can carry an unlimited amount of diamonds. It is considered that before all Joe's actions the system performs at least one check.In the morning the bank employees will come, which is why Joe has to leave the bank before that moment. Joe has only k minutes left before morning, and on each of these k minutes he can perform no more than m operations. All that remains in Joe's pocket, is considered his loot.Calculate the largest amount of diamonds Joe can carry with him. Don't forget that the security system shouldn't be triggered (even after Joe leaves the bank) and Joe should leave before morning.
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 and the security system doesn't go off.During the second period Joe moves a diamond from the 3-rd cell to the 2-nd one and puts a diamond from the 1-st cell to his pocket.By the end of the second period the diamonds' positions are 2 3 1. The check finds no difference again and the security system doesn't go off.Now Joe leaves with 2 diamonds in his pocket.
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=(unsigned int *)calloc(n,sizeof(unsigned int)); for(i=0;i<n;i++) scanf("%u",cell+i); for(i=0;i<n;i+=2) if(min>*(cell+i)) min=*(cell+i); m/=(n+1)/2; printf("%u\n",MIN(min,m*k)); free(cell); return 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 didn't switch the last security system off. On the plus side, he knows the way it works.Every minute the security system calculates the total amount of diamonds for each two adjacent cells (for the cells between whose numbers difference equals 1). As a result of this check we get an n - 1 sums. If at least one of the sums differs from the corresponding sum received during the previous check, then the security system is triggered.Joe can move the diamonds from one cell to another between the security system's checks. He manages to move them no more than m times between two checks. One of the three following operations is regarded as moving a diamond: moving a diamond from any cell to any other one, moving a diamond from any cell to Joe's pocket, moving a diamond from Joe's pocket to any cell. Initially Joe's pocket is empty, and it can carry an unlimited amount of diamonds. It is considered that before all Joe's actions the system performs at least one check.In the morning the bank employees will come, which is why Joe has to leave the bank before that moment. Joe has only k minutes left before morning, and on each of these k minutes he can perform no more than m operations. All that remains in Joe's pocket, is considered his loot.Calculate the largest amount of diamonds Joe can carry with him. Don't forget that the security system shouldn't be triggered (even after Joe leaves the bank) and Joe should leave before morning.
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 and the security system doesn't go off.During the second period Joe moves a diamond from the 3-rd cell to the 2-nd one and puts a diamond from the 1-st cell to his pocket.By the end of the second period the diamonds' positions are 2 3 1. The check finds no difference again and the security system doesn't go off.Now Joe leaves with 2 diamonds in his pocket.
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 = a[i]; } if (n % 2 == 0 || (n + 1) / 2 > m) { puts("0"); return 0; } m /= (n + 1) / 2; printf("%I64d\n", min((long long)m * k, p)); return 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 didn't switch the last security system off. On the plus side, he knows the way it works.Every minute the security system calculates the total amount of diamonds for each two adjacent cells (for the cells between whose numbers difference equals 1). As a result of this check we get an n - 1 sums. If at least one of the sums differs from the corresponding sum received during the previous check, then the security system is triggered.Joe can move the diamonds from one cell to another between the security system's checks. He manages to move them no more than m times between two checks. One of the three following operations is regarded as moving a diamond: moving a diamond from any cell to any other one, moving a diamond from any cell to Joe's pocket, moving a diamond from Joe's pocket to any cell. Initially Joe's pocket is empty, and it can carry an unlimited amount of diamonds. It is considered that before all Joe's actions the system performs at least one check.In the morning the bank employees will come, which is why Joe has to leave the bank before that moment. Joe has only k minutes left before morning, and on each of these k minutes he can perform no more than m operations. All that remains in Joe's pocket, is considered his loot.Calculate the largest amount of diamonds Joe can carry with him. Don't forget that the security system shouldn't be triggered (even after Joe leaves the bank) and Joe should leave before morning.
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 and the security system doesn't go off.During the second period Joe moves a diamond from the 3-rd cell to the 2-nd one and puts a diamond from the 1-st cell to his pocket.By the end of the second period the diamonds' positions are 2 3 1. The check finds no difference again and the security system doesn't go off.Now Joe leaves with 2 diamonds in his pocket.
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;i<n;i++) { if(i%2==0) { if(a[i]<y) y=a[i]; } } z=w*k;//total possible removals if(z>=y) printf("%lld",y); else { printf("%lld",z); } } return 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 didn't switch the last security system off. On the plus side, he knows the way it works.Every minute the security system calculates the total amount of diamonds for each two adjacent cells (for the cells between whose numbers difference equals 1). As a result of this check we get an n - 1 sums. If at least one of the sums differs from the corresponding sum received during the previous check, then the security system is triggered.Joe can move the diamonds from one cell to another between the security system's checks. He manages to move them no more than m times between two checks. One of the three following operations is regarded as moving a diamond: moving a diamond from any cell to any other one, moving a diamond from any cell to Joe's pocket, moving a diamond from Joe's pocket to any cell. Initially Joe's pocket is empty, and it can carry an unlimited amount of diamonds. It is considered that before all Joe's actions the system performs at least one check.In the morning the bank employees will come, which is why Joe has to leave the bank before that moment. Joe has only k minutes left before morning, and on each of these k minutes he can perform no more than m operations. All that remains in Joe's pocket, is considered his loot.Calculate the largest amount of diamonds Joe can carry with him. Don't forget that the security system shouldn't be triggered (even after Joe leaves the bank) and Joe should leave before morning.
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 and the security system doesn't go off.During the second period Joe moves a diamond from the 3-rd cell to the 2-nd one and puts a diamond from the 1-st cell to his pocket.By the end of the second period the diamonds' positions are 2 3 1. The check finds no difference again and the security system doesn't go off.Now Joe leaves with 2 diamonds in his pocket.
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; LL p; if (n%2==0) { printf( "0\n" ); return; } p = n/2 + 1; p = (m/p) * k; for (i=0;i<n;++i) if (i%2==0) if (a[i]<p) p = a[i]; printf( "%d\n", (int)p ); } main() { init(); work(); return 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 didn't switch the last security system off. On the plus side, he knows the way it works.Every minute the security system calculates the total amount of diamonds for each two adjacent cells (for the cells between whose numbers difference equals 1). As a result of this check we get an n - 1 sums. If at least one of the sums differs from the corresponding sum received during the previous check, then the security system is triggered.Joe can move the diamonds from one cell to another between the security system's checks. He manages to move them no more than m times between two checks. One of the three following operations is regarded as moving a diamond: moving a diamond from any cell to any other one, moving a diamond from any cell to Joe's pocket, moving a diamond from Joe's pocket to any cell. Initially Joe's pocket is empty, and it can carry an unlimited amount of diamonds. It is considered that before all Joe's actions the system performs at least one check.In the morning the bank employees will come, which is why Joe has to leave the bank before that moment. Joe has only k minutes left before morning, and on each of these k minutes he can perform no more than m operations. All that remains in Joe's pocket, is considered his loot.Calculate the largest amount of diamonds Joe can carry with him. Don't forget that the security system shouldn't be triggered (even after Joe leaves the bank) and Joe should leave before morning.
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 and the security system doesn't go off.During the second period Joe moves a diamond from the 3-rd cell to the 2-nd one and puts a diamond from the 1-st cell to his pocket.By the end of the second period the diamonds' positions are 2 3 1. The check finds no difference again and the security system doesn't go off.Now Joe leaves with 2 diamonds in his pocket.
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; printf("%d\n",ret); return 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 didn't switch the last security system off. On the plus side, he knows the way it works.Every minute the security system calculates the total amount of diamonds for each two adjacent cells (for the cells between whose numbers difference equals 1). As a result of this check we get an n - 1 sums. If at least one of the sums differs from the corresponding sum received during the previous check, then the security system is triggered.Joe can move the diamonds from one cell to another between the security system's checks. He manages to move them no more than m times between two checks. One of the three following operations is regarded as moving a diamond: moving a diamond from any cell to any other one, moving a diamond from any cell to Joe's pocket, moving a diamond from Joe's pocket to any cell. Initially Joe's pocket is empty, and it can carry an unlimited amount of diamonds. It is considered that before all Joe's actions the system performs at least one check.In the morning the bank employees will come, which is why Joe has to leave the bank before that moment. Joe has only k minutes left before morning, and on each of these k minutes he can perform no more than m operations. All that remains in Joe's pocket, is considered his loot.Calculate the largest amount of diamonds Joe can carry with him. Don't forget that the security system shouldn't be triggered (even after Joe leaves the bank) and Joe should leave before morning.
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 and the security system doesn't go off.During the second period Joe moves a diamond from the 3-rd cell to the 2-nd one and puts a diamond from the 1-st cell to his pocket.By the end of the second period the diamonds' positions are 2 3 1. The check finds no difference again and the security system doesn't go off.Now Joe leaves with 2 diamonds in his pocket.
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]<min) min=arr[i]; r=m/(n/2+1); k=r*k; if(min>k) printf("%I64d\n",k); else printf("%I64d\n",min); return 0; }
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 consecutively following vertices are located on the same straight line.Your task is to check whether polygon B is positioned strictly inside polygon A. It means that any point of polygon B should be strictly inside polygon A. "Strictly" means that the vertex of polygon B cannot lie on the side of the polygon A.
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 number of vertices of polygon B. Then following m lines contain pairs of integers xj, yj (|xj|, |yj| ≤ 109) — the coordinates of the j-th vertex of polygon B. The vertices are given in the clockwise order. The coordinates of the polygon's vertices are separated by a single space. It is guaranteed that polygons A and B are non-degenerate, that polygon A is strictly convex, that polygon B has no self-intersections and self-touches and also for each polygon no three consecutively following vertices are located on the same straight line.
["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 abso(double a) { return (a<0)?-a:a; } char verify(int index,int i,int j) { double edge[2]; double point[2]; sub(edge,A[j],A[i]); sub(point,B[index],A[i]); if (cross(point,edge)>EPS) return 1; else return 0; } char binary_search(int index) { double b[2]; double m_b[2]; double m[2]; double m_a[2]; sub(b,B[index],A[0]); int mid; int lo=1,hi=N-1; while(lo<=hi) { mid=lo + (hi-lo)/2; sub(m,A[mid],A[0]); if (mid>0) { sub(m_b,A[mid-1],A[0]); if(abso(cross(b,m))<EPS || abso(cross(b,m_b))<EPS || (cross(b,m)*cross(b,m_b))<0) { if (!verify(index,mid-1,mid)) return 0; else return 1; } } if (mid<N-1) { sub(m_a,A[mid+1],A[0]); if(abso(cross(b,m))<EPS || abso(cross(b,m_a))<EPS || (cross(b,m)*cross(b,m_a))<0) { if (!verify(index,mid,mid+1)) return 0; else return 1; } } if (cross(b,m)<0) hi=mid-1; else lo=mid+1; } /*error*/ return -1; } int main() { int i; scanf("%d",&N); for(i=0;i<N;i++) scanf("%lf %lf",&A[i][0],&A[i][1]); scanf("%d",&M); for(i=0;i<M;i++) scanf("%lf %lf",&B[i][0],&B[i][1]); double tmp[2]; double f[2]; double s[2]; char flag=0; for(i=0;i<M;i++) { sub(tmp,B[i],A[0]); sub(f,A[1],A[0]); sub(s,A[N-1],A[0]); if (cross(tmp,f)<EPS) { flag=1; break; } if (cross(tmp,s)>-EPS) { flag=1; break; } if (!binary_search(i)) { flag=1; break; } } if (flag) printf("NO\n"); else printf("YES\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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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; } } if(b == 1) printf("Conan\n"); else 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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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]) { 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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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{ 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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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("Conan\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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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]=a2[j]; j++; } k++; } while(i<s1) { a[k]=a1[i]; i++;k++; } while(j<s2) { a[k]=a2[j]; j++;k++; } return; } void merge_sorting(int a[],int low,int high) { if(low<high) { int mid=low +(high-low)/2; merge_sorting(a,low,mid); merge_sorting(a,mid+1,high); merging(a,low,mid,high); } return; } int main() { int n,i,a[100005],cnt[100005],max,count=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); /* if(i>0) { if(a[i]==max) { count++; } else if(a[i]>max) { max=a[i]; count=1; } } else { max=a[i]; count++; } */ } merge_sorting(a,0,n-1); int j=0; cnt[0]=1; for(i=1;i<n;i++) { if(a[i]==a[i-1]) { cnt[j]++; } else { j++; cnt[j]++; } } for(i=0;i<=j;i++) { if(cnt[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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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+=2){ if(a[i]==a[i+1]) continue; else{ c=1;break;} } if(c==1) printf("Conan"); else printf("Agasa"); 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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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 result=1; } } if(result==0) printf("Agasa\n"); else printf("Conan"); }
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 cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj &lt; ai.A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.
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 it becomes Conan's turn again.
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"); } return 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, consisting of lowercase English letters and a positive integer k. Your task is to reorder the letters in the string s in such a way that the resulting string is a k-string.
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]; if(comp%k!=0) { flag=1; } for(i=0;i<26;i++) { if((a[i]>0)&&((a[i]%k)!=0)) { flag=1; break; } } if(flag==0) { for(i=0;i<26;i++) { if(a[i]>0) { for(z=0;z<(a[i]/k);z++) { res[j]=i+97; j++; } } } res[j]='\0'; for(i=0;i<k;i++) { printf("%s",res); } } else { printf("-1"); } return 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, consisting of lowercase English letters and a positive integer k. Your task is to reorder the letters in the string s in such a way that the resulting string is a k-string.
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; for(i=1;i<x;i++) {if(s[y]==s[i]) c[j]++; else { if((c[j]+1)%k!=0) { l=-1; printf("%d",l); goto z;} else { m[j]=(c[j]+1)/k; r[j]=s[y]; j=j+1; y=i; }}} if((c[j]+1)%k!=0) { l=-1; printf("%d",l); } else { m[j]=(c[j]+1)/k; r[j]=s[y];} n=j; z: if(l!=-1) for(i=0;i<k;i++) for(j=0;j<=n;j++) for(x=0;x<m[j];x++) printf("%c",r[j]); return 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, consisting of lowercase English letters and a positive integer k. Your task is to reorder the letters in the string s in such a way that the resulting string is a k-string.
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++){ printf("%c",'a'+j); } } } }else printf("-1\n"); }else printf("-1\n"); return 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, consisting of lowercase English letters and a positive integer k. Your task is to reorder the letters in the string s in such a way that the resulting string is a k-string.
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[i]) for(j = 0 ; j < h[i]/k ; j++) h1[l++] = 97 + i; else; h1[l] = '\0'; if(f) while(k--) printf("%s", h1); else printf("-1"); return 0; }