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
There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens.Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought $$$n$$$ packets with inflatable balloons, where $$$i$$$-th of them has exactly $$$a_i$$$ bal...
If it's impossible to divide the balloons satisfying the conditions above, print $$$-1$$$. Otherwise, print an integer $$$k$$$Β β€” the number of packets to give to Grigory followed by $$$k$$$ distinct integers from $$$1$$$ to $$$n$$$Β β€” the indices of those. The order of packets doesn't matter. If there are multiple ways ...
C
2b55012c899645bac8d293e85e73148f
a7aea6a4ec58e03524ea88db6d7fec1a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation" ]
1530453900
["3\n1 2 1", "2\n5 5", "1\n10"]
NoteIn the first test Grigory gets $$$3$$$ balloons in total while Andrey gets $$$1$$$.In the second test there's only one way to divide the packets which leads to equal numbers of balloons.In the third test one of the boys won't get a packet at all.
PASSED
1,000
standard input
1 second
The first line of input contains a single integer $$$n$$$ ($$$1 \le n \le 10$$$)Β β€” the number of packets with balloons. The second line contains $$$n$$$ integers: $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_n$$$ ($$$1 \le a_i \le 1000$$$)Β β€” the number of balloons inside the corresponding packet.
["2\n1 2", "-1", "-1"]
#include <stdio.h> #include <stdlib.h> int at_least_one_diff(int *tab, int packets_number) { int i = 0, j; if (packets_number > 2) return (1); while (i < packets_number) { j = i + 1; while (j < packets_number) { if (tab[i] != tab[j]) return (1...
There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens.Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought $$$n$$$ packets with inflatable balloons, where $$$i$$$-th of them has exactly $$$a_i$$$ bal...
If it's impossible to divide the balloons satisfying the conditions above, print $$$-1$$$. Otherwise, print an integer $$$k$$$Β β€” the number of packets to give to Grigory followed by $$$k$$$ distinct integers from $$$1$$$ to $$$n$$$Β β€” the indices of those. The order of packets doesn't matter. If there are multiple ways ...
C
2b55012c899645bac8d293e85e73148f
c9224564d8b3a3621e830d79e666c647
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation" ]
1530453900
["3\n1 2 1", "2\n5 5", "1\n10"]
NoteIn the first test Grigory gets $$$3$$$ balloons in total while Andrey gets $$$1$$$.In the second test there's only one way to divide the packets which leads to equal numbers of balloons.In the third test one of the boys won't get a packet at all.
PASSED
1,000
standard input
1 second
The first line of input contains a single integer $$$n$$$ ($$$1 \le n \le 10$$$)Β β€” the number of packets with balloons. The second line contains $$$n$$$ integers: $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_n$$$ ($$$1 \le a_i \le 1000$$$)Β β€” the number of balloons inside the corresponding packet.
["2\n1 2", "-1", "-1"]
#include <stdio.h> int a[1005]; int main() { int n,sum=0,min=0xfffffff,t; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); sum+=a[i]; if(min>a[i]){ min=a[i],t=i;}} if(n==1) printf("-1\n"); else{ if(min==(sum-min)) printf("-1\n"); else{ printf("1\n%d\n",...
There are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.During one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the current size of pile i, and pile i stops existing. The cost of the adding operation equals the size of t...
Print q whitespace-separated integers β€” the answers to the queries in the order, in which the queries are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
87045c4df69110642122f2c114476947
fc9c78b75a346b9f6ac1cf43f1cee1d3
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1348500600
["5\n2 3 4 1 1\n2\n2 3"]
NoteIn the first sample one way to get the optimal answer goes like this: we add in turns the 4-th and the 5-th piles to the 2-nd one; then we add the 1-st pile to the 3-rd one; we add the 2-nd pile to the 3-rd one. The first two operations cost 1 each; the third one costs 2, the fourth one costs 5 (the size of the 2-n...
PASSED
1,900
standard input
2 seconds
The first line contains integer n (1 ≀ n ≀ 105) β€” the number of stone piles. The second line contains n space-separated integers: a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the initial sizes of the stone piles. The third line contains integer q (1 ≀ q ≀ 105) β€” the number of queries. The last line contains q space-separated inte...
["9 8"]
#include<stdio.h> #include<stdlib.h> int cmp(long long int *a1,long long int *a2) {return(*a1-*a2);} int main() {long long int i,j,n,q,x,k,t,a[100005]={0},s[100005]={0},d[100005]={0}; scanf("%I64d",&n); for(i=1;i<=n;i++) scanf("%I64d",&a[i]); qsort(a+1,n,sizeof(long long int),cmp); s[1]=a[1]; for(i=1;i<=n;i++) s[i]=s[i...
There are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.During one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the current size of pile i, and pile i stops existing. The cost of the adding operation equals the size of t...
Print q whitespace-separated integers β€” the answers to the queries in the order, in which the queries are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
87045c4df69110642122f2c114476947
31524535760c734751df1212f7fbd608
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1348500600
["5\n2 3 4 1 1\n2\n2 3"]
NoteIn the first sample one way to get the optimal answer goes like this: we add in turns the 4-th and the 5-th piles to the 2-nd one; then we add the 1-st pile to the 3-rd one; we add the 2-nd pile to the 3-rd one. The first two operations cost 1 each; the third one costs 2, the fourth one costs 5 (the size of the 2-n...
PASSED
1,900
standard input
2 seconds
The first line contains integer n (1 ≀ n ≀ 105) β€” the number of stone piles. The second line contains n space-separated integers: a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the initial sizes of the stone piles. The third line contains integer q (1 ≀ q ≀ 105) β€” the number of queries. The last line contains q space-separated inte...
["9 8"]
#include <stdio.h> #include <stdlib.h> int cmp(int*a,int*b){return*b-*a;} int n,a[100001],q,p; long long s[100001],memo[100001]; int main(){ int i; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",a+i); qsort(a+1,n,4,cmp); s[1] = a[1]; for(i=2;i<=n;i++) s[i] = s[i-1] + a[i]; scanf("%d",&q); ...
There are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.During one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the current size of pile i, and pile i stops existing. The cost of the adding operation equals the size of t...
Print q whitespace-separated integers β€” the answers to the queries in the order, in which the queries are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
87045c4df69110642122f2c114476947
b8029c61a3fc1579371de9c0e88b39f5
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1348500600
["5\n2 3 4 1 1\n2\n2 3"]
NoteIn the first sample one way to get the optimal answer goes like this: we add in turns the 4-th and the 5-th piles to the 2-nd one; then we add the 1-st pile to the 3-rd one; we add the 2-nd pile to the 3-rd one. The first two operations cost 1 each; the third one costs 2, the fourth one costs 5 (the size of the 2-n...
PASSED
1,900
standard input
2 seconds
The first line contains integer n (1 ≀ n ≀ 105) β€” the number of stone piles. The second line contains n space-separated integers: a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the initial sizes of the stone piles. The third line contains integer q (1 ≀ q ≀ 105) β€” the number of queries. The last line contains q space-separated inte...
["9 8"]
#include<stdio.h> #define F(a,b)for(i=a;b;i++) int n,i,q,k;long long P[100000],R[100000],j,t;int c(long long*a,long long*b){return*a-*b;}int main(){scanf("%d",&n);F(0,i<n)scanf("%I64d",&P[i]);qsort(P,n,8,c);F(1,i<n)P[i]+=P[i-1];F(1,i<=n){j=n-2;t=i;while(j>=0){R[i-1]+=P[j];j-=t;t*=i;}}scanf("%d",&q);F(0,i<q){scanf("%d",...
There are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.During one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the current size of pile i, and pile i stops existing. The cost of the adding operation equals the size of t...
Print q whitespace-separated integers β€” the answers to the queries in the order, in which the queries are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
87045c4df69110642122f2c114476947
32cbe60dc29a2dd3bd95e4f9856d97e1
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1348500600
["5\n2 3 4 1 1\n2\n2 3"]
NoteIn the first sample one way to get the optimal answer goes like this: we add in turns the 4-th and the 5-th piles to the 2-nd one; then we add the 1-st pile to the 3-rd one; we add the 2-nd pile to the 3-rd one. The first two operations cost 1 each; the third one costs 2, the fourth one costs 5 (the size of the 2-n...
PASSED
1,900
standard input
2 seconds
The first line contains integer n (1 ≀ n ≀ 105) β€” the number of stone piles. The second line contains n space-separated integers: a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the initial sizes of the stone piles. The third line contains integer q (1 ≀ q ≀ 105) β€” the number of queries. The last line contains q space-separated inte...
["9 8"]
#include <stdio.h> #include <stdint.h> uint64_t P[100000], R[100000]; int compare(const void *a, const void *b) { return *(uint64_t*)a - *(uint64_t*)b; } int main(){ int n, i, q; scanf("%d", &n); for(i = 0; i < n; i++) { scanf("%I64d", &P[i]); } qsort(P, n, sizeof(uint64_t), compare);...
There are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.During one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the current size of pile i, and pile i stops existing. The cost of the adding operation equals the size of t...
Print q whitespace-separated integers β€” the answers to the queries in the order, in which the queries are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
87045c4df69110642122f2c114476947
dfa7b69b61b5adc07d3b5dee1b0c4bf0
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1348500600
["5\n2 3 4 1 1\n2\n2 3"]
NoteIn the first sample one way to get the optimal answer goes like this: we add in turns the 4-th and the 5-th piles to the 2-nd one; then we add the 1-st pile to the 3-rd one; we add the 2-nd pile to the 3-rd one. The first two operations cost 1 each; the third one costs 2, the fourth one costs 5 (the size of the 2-n...
PASSED
1,900
standard input
2 seconds
The first line contains integer n (1 ≀ n ≀ 105) β€” the number of stone piles. The second line contains n space-separated integers: a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the initial sizes of the stone piles. The third line contains integer q (1 ≀ q ≀ 105) β€” the number of queries. The last line contains q space-separated inte...
["9 8"]
#include <stdio.h> #include <stdint.h> uint64_t A[100000], P[100000], R[100000]; int compare(const void *a, const void *b) { return *(uint64_t*)a - *(uint64_t*)b; } int main(){ int n, i, q; scanf("%d", &n); for(i = 0; i < n; i++) { scanf("%I64d", &A[i]); } qsort(A, n, sizeof(uint64_t)...
PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree.There is exactly one relative living in each vertex of each tree, they have unique ids from 1 to n. For eac...
You should output the number of trees in the forest where PolandBall lives.
C
6d940cb4b54f63a7aaa82f21e4c5b994
3d8998314933ed820187c6466c2f7150
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "graphs", "dsu", "interactive", "dfs and similar", "trees" ]
1484499900
["5\n2 1 5 3 3", "1\n1"]
NoteIn the first sample testcase, possible forest is: 1-2 3-4-5. There are 2 trees overall.In the second sample testcase, the only possible graph is one vertex and no edges. Therefore, there is only one tree.
PASSED
1,300
standard input
1 second
The first line contains single integer n (1 ≀ n ≀ 104)Β β€” the number of Balls living in the forest. The second line contains a sequence p1, p2, ..., pn of length n, where (1 ≀ pi ≀ n) holds and pi denotes the most distant from Ball i relative living on the same tree. If there are several most distant relatives living on...
["2", "1"]
#include<stdio.h> #include<string.h> int main(){ int n,i,j,fcount,check; scanf("%d",&n); int p[n]; int visited[n]; memset(visited,0,n*sizeof(int)); for(i=0;i<n;i++){ scanf("%d",&p[i]); } fcount=0; check = 1; for(i=0;i<n;i++){ if(visited[i]==0){ visit...
PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree.There is exactly one relative living in each vertex of each tree, they have unique ids from 1 to n. For eac...
You should output the number of trees in the forest where PolandBall lives.
C
6d940cb4b54f63a7aaa82f21e4c5b994
bca0dff5cd98c4706548a973cd015c1d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "graphs", "dsu", "interactive", "dfs and similar", "trees" ]
1484499900
["5\n2 1 5 3 3", "1\n1"]
NoteIn the first sample testcase, possible forest is: 1-2 3-4-5. There are 2 trees overall.In the second sample testcase, the only possible graph is one vertex and no edges. Therefore, there is only one tree.
PASSED
1,300
standard input
1 second
The first line contains single integer n (1 ≀ n ≀ 104)Β β€” the number of Balls living in the forest. The second line contains a sequence p1, p2, ..., pn of length n, where (1 ≀ pi ≀ n) holds and pi denotes the most distant from Ball i relative living on the same tree. If there are several most distant relatives living on...
["2", "1"]
#include <stdio.h> #include <string.h> #define N 10000 int dsu[N]; int find(int i) { return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i])); } void join(int i, int j) { i = find(i); j = find(j); if (i == j) return; if (dsu[i] > dsu[j]) dsu[i] = j; else { if (dsu[i] == dsu[j]) dsu[i]--; dsu[j] = i; } } i...
PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree.There is exactly one relative living in each vertex of each tree, they have unique ids from 1 to n. For eac...
You should output the number of trees in the forest where PolandBall lives.
C
6d940cb4b54f63a7aaa82f21e4c5b994
036007b8be347b4d8f15171531526175
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "graphs", "dsu", "interactive", "dfs and similar", "trees" ]
1484499900
["5\n2 1 5 3 3", "1\n1"]
NoteIn the first sample testcase, possible forest is: 1-2 3-4-5. There are 2 trees overall.In the second sample testcase, the only possible graph is one vertex and no edges. Therefore, there is only one tree.
PASSED
1,300
standard input
1 second
The first line contains single integer n (1 ≀ n ≀ 104)Β β€” the number of Balls living in the forest. The second line contains a sequence p1, p2, ..., pn of length n, where (1 ≀ pi ≀ n) holds and pi denotes the most distant from Ball i relative living on the same tree. If there are several most distant relatives living on...
["2", "1"]
#include <stdio.h> #include <string.h> #define MAXV 10001 typedef struct { int to; int next; } Edge_t; Edge_t E[MAXV << 1]; int Adj[MAXV]; int Size; char Visit[MAXV]; int Queue[MAXV]; void Init(int N) { memset(Adj, -1, sizeof(Adj)); Size = 0; } void Add_Edge(int u, int v) { E[Size].to = v; ...
PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree.There is exactly one relative living in each vertex of each tree, they have unique ids from 1 to n. For eac...
You should output the number of trees in the forest where PolandBall lives.
C
6d940cb4b54f63a7aaa82f21e4c5b994
bf77b386c8fd6ba8fd75140af555006b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "graphs", "dsu", "interactive", "dfs and similar", "trees" ]
1484499900
["5\n2 1 5 3 3", "1\n1"]
NoteIn the first sample testcase, possible forest is: 1-2 3-4-5. There are 2 trees overall.In the second sample testcase, the only possible graph is one vertex and no edges. Therefore, there is only one tree.
PASSED
1,300
standard input
1 second
The first line contains single integer n (1 ≀ n ≀ 104)Β β€” the number of Balls living in the forest. The second line contains a sequence p1, p2, ..., pn of length n, where (1 ≀ pi ≀ n) holds and pi denotes the most distant from Ball i relative living on the same tree. If there are several most distant relatives living on...
["2", "1"]
#include <stdio.h> #include <stdlib.h> #include <mem.h> #define __for(a, b, k) for(int k = a; k < b; k++) int n; int forest[10001]; int trees_count; int dsu_find(int a){ if(forest[a] != a) forest[a] = dsu_find(forest[a]); return forest[a]; } void dsu_union(int a, int b){ int ap = dsu_find(a); int bp...
PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree.There is exactly one relative living in each vertex of each tree, they have unique ids from 1 to n. For eac...
You should output the number of trees in the forest where PolandBall lives.
C
6d940cb4b54f63a7aaa82f21e4c5b994
76a2c106cd55ff7a6b0ceee3a553ba6c
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "graphs", "dsu", "interactive", "dfs and similar", "trees" ]
1484499900
["5\n2 1 5 3 3", "1\n1"]
NoteIn the first sample testcase, possible forest is: 1-2 3-4-5. There are 2 trees overall.In the second sample testcase, the only possible graph is one vertex and no edges. Therefore, there is only one tree.
PASSED
1,300
standard input
1 second
The first line contains single integer n (1 ≀ n ≀ 104)Β β€” the number of Balls living in the forest. The second line contains a sequence p1, p2, ..., pn of length n, where (1 ≀ pi ≀ n) holds and pi denotes the most distant from Ball i relative living on the same tree. If there are several most distant relatives living on...
["2", "1"]
#include<stdio.h> int main() { int n, num, end = 0, label = 0; int gg[10010]; int cheak[10010]; scanf("%d", &n); int i, j; for (i = 0; i < n; i++)gg[i] = i; for (i = 0; i < n; i++) { scanf("%d", &num); for (int j = 0; j < i; j++) { if (gg[j] == gg[i])gg[j] = gg[num - 1]; } gg[i] = gg[num - 1];...
PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is a valid tree.There is exactly one relative living in each vertex of each tree, they have unique ids from 1 to n. For eac...
You should output the number of trees in the forest where PolandBall lives.
C
6d940cb4b54f63a7aaa82f21e4c5b994
15625fe77e6535ec6b5e035fff291836
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "graphs", "dsu", "interactive", "dfs and similar", "trees" ]
1484499900
["5\n2 1 5 3 3", "1\n1"]
NoteIn the first sample testcase, possible forest is: 1-2 3-4-5. There are 2 trees overall.In the second sample testcase, the only possible graph is one vertex and no edges. Therefore, there is only one tree.
PASSED
1,300
standard input
1 second
The first line contains single integer n (1 ≀ n ≀ 104)Β β€” the number of Balls living in the forest. The second line contains a sequence p1, p2, ..., pn of length n, where (1 ≀ pi ≀ n) holds and pi denotes the most distant from Ball i relative living on the same tree. If there are several most distant relatives living on...
["2", "1"]
#include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 11111 typedef struct _list{ int v; struct _list *next; } list; list *g[N]; int cnt, n, a, b; bool vis[N]; void pushg(int u, int v){ list *ptr=(list *) malloc(sizeof(list)); ptr->v=v; ptr->ne...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
ae0eb3984e197d99e9d6b7f3ebe56cb9
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> #include<string.h> int main() { char num1[100010]={0},num2[100010]={0}; long long n,i,count=0,a=0,b=0,c=0,d=0; scanf("%lld",&n); scanf("%s",num1); scanf("%s",num2); for(i=0;i<n;i++) { if(num1[i]=='1' && num2[i]=='1') a++; else if(num1[i]=='0' &&...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
6bc4082542f2f7904cc336b8e35af1e8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> int main(){ int n; scanf("%d",&n); char o,a[n+1],b[n+1]; int i; scanf("%c",&o); gets(a); gets(b); long long int y=0,z=0,yx=0,zx=0; for(i=0;i<n;i++){ if(a[i]=='0'){ y++; if(b[i]=='0') yx++; } else{ z++; if(b[i]=='0') zx++; } } printf("%I64d",yx*z+z...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
44f7d466e43f175642d93a1a3815b560
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> int fun() { char c = getchar(); while(c != '0' && c != '1') { c = getchar(); } return (c-'0'); } int main() { long long a=0, b=0, c=0, d=0; int arr[100003]; int num; scanf("%d", &num); for (int i = 0; i < num; i++) { arr[i] = ...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
51cfe03627e8ffd3bf1c1b5be7f2e562
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> #define ll long long int main() { ll n, z = 0, o = 0, res = 0, i, cnt = 0; scanf("%lld", &n); char a[n+2], b[n+2]; scanf("%s %s", a, b); for(i = 0; i < strlen(b); i++) { if(a[i] == '1')o++; else z++; } for(i = 0; i < n; i++) { if(b[i] == '0...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
987c395348fcd3d8e3fe06a4b78c39fc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> int main() { long long int n, z = 0, o = 0, res = 0, i, cnt = 0; scanf("%lld", &n); char a[n+2], b[n+2]; scanf("%s %s", a, b); for(i = 0; i < strlen(b); i++) { if(a[i] == '1')o++; else z++; } for(i = 0; i < n; i++) { if(b[i] == '0' && a[i] ...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
ac4091c7d85fd94197e5438d97f62aff
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> #include<stdlib.h> int main() { long long int i, T = 0, l1= 0, l2 = 0, l3 =0, l4 = 0, sum ; scanf("%lld", &T); char s1[110000], s2[110000]; scanf("%s %s", s1, s2); for(i = 0; i < T; i++) { if(s1[i] == '1') ++l1; if(s2[i] == '0') ++l2; i...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
a686fb40225ff3a50a3b4db2605a7755
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> #include<stdlib.h> #include<string.h> int main(int argc, char const *argv[]) { long long int n; scanf("%lld",&n); char m[n+1],p[n+1]; long int a[n+2],b[n+2]; long long int c=0,d=0,e=0,f=0,g=0,h=0,swp=0 ; getchar(); for (int i = 1; i <=n ;i++) { scanf("%c",&m[i]); a[i] = (( long int)m...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
4485c3fb8d19c2c55cafd5676b0a4c3e
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> #include<string.h> int main() { long long int n,a1=0,a2=0,a3=0,a4=0;int i; scanf("%lld",&n); char a[1000000],b[1000000]; scanf("%s",a); scanf("%s",b); for(i=0; i<n; i++) { if(a[i]=='1')a1++; } for(i=0; i<n; i++) { if(a[i]=='0'&&b[i]=='0')a2++; ...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
0c1b64fceab2ddb5c562b8869eca64fb
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> #include<string.h> int main() { long long int n,a1=0,a2=0,a3=0,a4=0;int i; scanf("%lld",&n); char a[1000000],b[1000000]; scanf("%s",a); scanf("%s",b); for(i=0; i<n; i++) { if(a[i]=='0'&&b[i]=='0')a1++; if(a[i]=='0'&&b[i]=='1')a2++; if(a[i]=='1'&&b[i]=='0'...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
2d9840703c0858e5d9a911a56d77e91f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> int main() { int n, cntA0, cntA1, cntB0, cntAll0; char strA[100001]; char strB[100001]; long long ans = 0; scanf("%d %s %s", &n, strA, strB); cntA0 = cntA1 = cntB0 = cntAll0 = 0; for(int i = 0; i < n; ++i) { if(strA[i] == '0') { if(strB[i] == '0') { ...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
789bf73c25e62081bfd125e7b7c6c990
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> int main(){ char b[1000000], c[1000000]; long long a, zero = 0,one = 0,zerozero = 0,onezero = 0, result = 0; scanf("%lld%s%s", &a,b,c); for(int i = 0; i < a; i++){ if(b[i] == '0') zero++; if(b[i] == '0' && c[i] == '0') zerozero++; if(b[...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
9cac43b72c7a19747d3040bbe996d653
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> #include<stdlib.h> int main() { int n; char lda,ldb; long long one=0,zero=0,ones=0,zeros=0; scanf("%d",&n); char* a=(char*)malloc((n+1)*sizeof(char)); char* b=(char*)malloc((n+1)*sizeof(char)); scanf("%s",a); scanf("%s",b); int i=0; while(a[i]!='\0') ...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
c8318afaa7a836326d0a94fc9efed644
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> int main(void) { long long int n1=0,n0=0,ans=0; int n,i,pos[100000],k=0,ex=0; scanf("%i ",&n); char a[n+5],b[n+5]; gets(a); gets(b); for(i=0;i<n;i++) { if(b[i]=='0'){pos[k]=i;k++;} if(a[i]=='0')n0++; else n1++; if(b[i]=='0'&&a[i]=='0')e...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
ef2396dcd17990b06b30237f08e9ec27
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> int main() { int n; scanf("%d\n", &n); int i; int a[123450], b[123450]; long long int cone = 0, czero = 0; for (i = 0; i < n; ++i) { a[i] = getchar() - '0'; if (a[i]) ++cone; else ++czero; } getchar(); // '\n' long long int eone = 0, ezero = 0; for (i = 0;...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
2b58e5fceb737254369345739efcc13b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> long long int n,j; long long t1=0,t0=0,s1=0,s0=0,sum=0,i; char a[100005]; char b[100005]; int main() { scanf ("%lld",&n); scanf ("%s",a); scanf ("%s",b); for (i=0;i<n;i++) { if (a[i]=='0'&&b[i]=='0') t1++; else if (a[i]=='1'&&b[i...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
17ab13b098f3234d7ec4a75836bc33a1
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> typedef long long ll; ll nc2(ll x) { return (x*(x-1))/2; } int main() { ll n; scanf("%lld",&n); char s1[n+1],s2[n+1]; scanf("%s %s",s1,s2); ll cnt_1,cnt_0,sum; cnt_1=cnt_0=sum=0; for(ll i=0;i<n;i++) { if(s1[i]=='1') cnt_1++; if(s1[i]=='0'...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
88d135cc51ebf27546bf3e7f98e9e533
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> int main(){ unsigned comb[2][2] = { {0,0}, {0,0} },n,i; scanf("%i",&n); char a[n+1],b[n+1]; int ia,ib; scanf("%s %s",a,b); for(i = 0; i < n; i++){ ia = a[i] - '0'; ib = b[i] - '0'; comb[ia][ib]++; } printf("%u",comb[0][0]*comb[1][0]+comb[0][0]*comb[1][1]+comb[0][1]*comb[1][0])...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
aa3f3dcbd6b4124e1e7536fd379e48a2
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> int main() { long long int i,j,k,n,l=0,m=0,o=0,p=0; scanf("%lld",&n); char a[n+1],b[n+1]; scanf("%s",a); scanf("%s",b); for(i=0;i<n;i++){ if(a[i]=='0'&&b[i]=='0') l++; else if(a[i]=='1'&& b[i]=='0') m++; else if(a[i]=='0'&& b[i...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
0fba64e64579b4299787199b4da269bc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> int main() { unsigned long n,i,count0=0,count1=0,c1=0,c0=0; scanf("%lu",&n); char a[n+1],b[n+1]; scanf("%s%s",a,b); for (i=n;i>0;i--) { if (b[i-1]=='1') (a[i-1]=='0')?count0++:count1++; else (a[i-1]=='1')?c1++:c0++; } printf("%lu...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
59ca62bbb4e2e03809280b18a7bd6e8d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> int main() { int n; scanf("%d",&n); long long zeroone=0,onezero=0,zz=0,one=0; char a[n+1],b[n+1]; scanf("%s%s",a,b); a[n]='\0'; b[n]='\0'; for(int i=0;i<n;i++) { if(a[i]=='0'&&b[i]=='1') zeroone++; if(a[i]=='1'&&b[i]=='0') onezero++; if(a[i]=='0...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
af18f17820e1e658ea196f55cc9a889a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main () { int n; scanf ("%d", &n); char a[100000] = {0}, b[100000] = {0}; scanf ("%s%s", a, b); long long d = 0; long long z00 = 0, z01 = 0, z10 = 0, z11 = 0; for (int i = 0; i < n; i++) { if (a[i] - '0') { if...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
df759f83b11e2e8a4e6e97124646be60
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include<stdio.h> int main() { long long int i,s=0,m=0,k=0,l=0,n,num=0; scanf("%lld",&num); char a[100050],b[100050]; scanf("%s%s",&a,&b); for(i=0;i<num;i++) { if(a[i]=='1') ++s; if(b[i]=='0') ++m; if(a[i]=='0'&&b[i]=='0') ++k; if(a[i]=='1'&&b[...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
fbc277259a07aa81eb44f0df6eba43f8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> #include <stdlib.h> int main() { unsigned long n; scanf("%lu",&n); char a[n+1],b[n+1]; scanf("%s",a); scanf("%s",b); unsigned long a0=0,a1=0,b0c=0,b1c=0; for(unsigned long i=0;i<n;i++){ (a[i]=='0')?a0++:a1++; if(b[i]=='0'){ (a[i]=='0')?b0c++:b1...
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In...
Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.
C
621c82478be3dadcf60c383ba078a49e
8af5d848e836a8b9b3dc91eaa5d81e33
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "math" ]
1533737100
["5\n01011\n11001", "6\n011000\n010011"]
NoteIn the first sample, you can swap bits that have indexes $$$(1, 4)$$$, $$$(2, 3)$$$, $$$(3, 4)$$$, and $$$(3, 5)$$$.In the second example, you can swap bits that have indexes $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 4)$$$, $$$(3, 4)$$$, $$$(3, 5)$$$, and $$$(3, 6)$$$.
PASSED
1,200
standard input
2 seconds
The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$)Β β€” the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.
["4", "6"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int x,y,z; long long sum,fr[4],n,i; char a[100001],b[100001]; int main() { scanf("%d %s %s",&n,a,b); for(i=0;i<n;i++) { x=a[i]-'0'; y=b[i]-'0'; if(x==0 && y==1) z=-1; else z=x+y; fr[z+1]++; } sum=fr[0]*fr[2]+fr[1]*fr[2...
After Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her castle. Taro's response to her was a string s, and she tried to remember the string s correctly.However, Ciel feels...
Output in the first line two space-separated integers len and pos: the length of the longest contiguous substring of s that does not contain any bi, and the first position of the substring (0-indexed). The position pos must be between 0 and |s| - len inclusive, where |s| is the length of string s. If there are several ...
C
b5f5fc50e36b2afa3b5f16dacdf5710b
0241f74cd04ce7bd329b13a345e4f6a3
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dp", "hashing", "greedy", "two pointers", "data structures", "strings" ]
1304175600
["Go_straight_along_this_street\n5\nstr\nlong\ntree\nbiginteger\nellipse", "IhaveNoIdea\n9\nI\nh\na\nv\ne\nN\no\nI\nd", "unagioisii\n2\nioi\nunagi"]
NoteIn the first sample, the solution is traight_alon.In the second sample, the solution is an empty string, so the output can be Β«0 0Β», Β«0 1Β», Β«0 2Β», and so on.In the third sample, the solution is either nagio or oisii.
PASSED
1,800
standard input
2 seconds
In the first line there is a string s. The length of s will be between 1 and 105, inclusive. In the second line there is a single integer n (1 ≀ n ≀ 10). Next n lines, there is a string bi (1 ≀ i ≀ n). Each length of bi will be between 1 and 10, inclusive. Each character of the given strings will be either a English a...
["12 4", "0 0", "5 5"]
#include <stdio.h> #include <string.h> #include <stdlib.h> #define MAXN 100055 #define MAXM 15 struct node { char s[MAXM]; int len; }; int main () { static char s[MAXN]; memset(s,0,sizeof(s)); scanf("%s\n",s); int N = strlen(s); int M; scanf("%d\n",&M); static struct node data[MAXM]; int i; for (i = 0; i <...
After Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her castle. Taro's response to her was a string s, and she tried to remember the string s correctly.However, Ciel feels...
Output in the first line two space-separated integers len and pos: the length of the longest contiguous substring of s that does not contain any bi, and the first position of the substring (0-indexed). The position pos must be between 0 and |s| - len inclusive, where |s| is the length of string s. If there are several ...
C
b5f5fc50e36b2afa3b5f16dacdf5710b
ce17f8aa1ad9f619221ff360be4e63b4
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dp", "hashing", "greedy", "two pointers", "data structures", "strings" ]
1304175600
["Go_straight_along_this_street\n5\nstr\nlong\ntree\nbiginteger\nellipse", "IhaveNoIdea\n9\nI\nh\na\nv\ne\nN\no\nI\nd", "unagioisii\n2\nioi\nunagi"]
NoteIn the first sample, the solution is traight_alon.In the second sample, the solution is an empty string, so the output can be Β«0 0Β», Β«0 1Β», Β«0 2Β», and so on.In the third sample, the solution is either nagio or oisii.
PASSED
1,800
standard input
2 seconds
In the first line there is a string s. The length of s will be between 1 and 105, inclusive. In the second line there is a single integer n (1 ≀ n ≀ 10). Next n lines, there is a string bi (1 ≀ i ≀ n). Each length of bi will be between 1 and 10, inclusive. Each character of the given strings will be either a English a...
["12 4", "0 0", "5 5"]
#include <stdio.h> #include <string.h> int max(int a, int b) { if (a > b) { return a; } else { return b; } } int main() { int n, l = 0, p = 0, m = 0, i, j, k; char s[100001], b[10][11]; int c[10]; scanf("%s", s); scanf("%d", &n); for (i = 0; i < n; i++) scanf("%s",...
After Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her castle. Taro's response to her was a string s, and she tried to remember the string s correctly.However, Ciel feels...
Output in the first line two space-separated integers len and pos: the length of the longest contiguous substring of s that does not contain any bi, and the first position of the substring (0-indexed). The position pos must be between 0 and |s| - len inclusive, where |s| is the length of string s. If there are several ...
C
b5f5fc50e36b2afa3b5f16dacdf5710b
d92a25f9dbbde539cfd0d1ca89137b5a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dp", "hashing", "greedy", "two pointers", "data structures", "strings" ]
1304175600
["Go_straight_along_this_street\n5\nstr\nlong\ntree\nbiginteger\nellipse", "IhaveNoIdea\n9\nI\nh\na\nv\ne\nN\no\nI\nd", "unagioisii\n2\nioi\nunagi"]
NoteIn the first sample, the solution is traight_alon.In the second sample, the solution is an empty string, so the output can be Β«0 0Β», Β«0 1Β», Β«0 2Β», and so on.In the third sample, the solution is either nagio or oisii.
PASSED
1,800
standard input
2 seconds
In the first line there is a string s. The length of s will be between 1 and 105, inclusive. In the second line there is a single integer n (1 ≀ n ≀ 10). Next n lines, there is a string bi (1 ≀ i ≀ n). Each length of bi will be between 1 and 10, inclusive. Each character of the given strings will be either a English a...
["12 4", "0 0", "5 5"]
#include<stdio.h> #include<string.h> #define MAX 100032 int main(void){ char str[MAX],c,hate[16]; int i,j,k,n,lstr,pstr,maxlen=0,len,maxp,p,sub,count,check[MAX]={0}; fgets(str,sizeof(str)/sizeof(char),stdin); lstr=strlen(str); //printf("%d\n",lstr); scanf("%d",&n); for(i=0;i<n;i++){ scanf("%s%*c",hate...
After Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her castle. Taro's response to her was a string s, and she tried to remember the string s correctly.However, Ciel feels...
Output in the first line two space-separated integers len and pos: the length of the longest contiguous substring of s that does not contain any bi, and the first position of the substring (0-indexed). The position pos must be between 0 and |s| - len inclusive, where |s| is the length of string s. If there are several ...
C
b5f5fc50e36b2afa3b5f16dacdf5710b
3806278cf593afbde707928e781b53c5
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dp", "hashing", "greedy", "two pointers", "data structures", "strings" ]
1304175600
["Go_straight_along_this_street\n5\nstr\nlong\ntree\nbiginteger\nellipse", "IhaveNoIdea\n9\nI\nh\na\nv\ne\nN\no\nI\nd", "unagioisii\n2\nioi\nunagi"]
NoteIn the first sample, the solution is traight_alon.In the second sample, the solution is an empty string, so the output can be Β«0 0Β», Β«0 1Β», Β«0 2Β», and so on.In the third sample, the solution is either nagio or oisii.
PASSED
1,800
standard input
2 seconds
In the first line there is a string s. The length of s will be between 1 and 105, inclusive. In the second line there is a single integer n (1 ≀ n ≀ 10). Next n lines, there is a string bi (1 ≀ i ≀ n). Each length of bi will be between 1 and 10, inclusive. Each character of the given strings will be either a English a...
["12 4", "0 0", "5 5"]
#include<stdio.h> #include<stdlib.h> #include<math.h> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) int get_len(char a[]){ int i; for(i=0;;i++) if(a[i]<' ') break; return i; } int is_same(char a[],char b[],int len){ int i; rep(i,len) if(a[i]!=b[i]) return 0; return 1; } int n; char in[1...
After Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her castle. Taro's response to her was a string s, and she tried to remember the string s correctly.However, Ciel feels...
Output in the first line two space-separated integers len and pos: the length of the longest contiguous substring of s that does not contain any bi, and the first position of the substring (0-indexed). The position pos must be between 0 and |s| - len inclusive, where |s| is the length of string s. If there are several ...
C
b5f5fc50e36b2afa3b5f16dacdf5710b
f1b390bf1d489aa0f8637344418094ad
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dp", "hashing", "greedy", "two pointers", "data structures", "strings" ]
1304175600
["Go_straight_along_this_street\n5\nstr\nlong\ntree\nbiginteger\nellipse", "IhaveNoIdea\n9\nI\nh\na\nv\ne\nN\no\nI\nd", "unagioisii\n2\nioi\nunagi"]
NoteIn the first sample, the solution is traight_alon.In the second sample, the solution is an empty string, so the output can be Β«0 0Β», Β«0 1Β», Β«0 2Β», and so on.In the third sample, the solution is either nagio or oisii.
PASSED
1,800
standard input
2 seconds
In the first line there is a string s. The length of s will be between 1 and 105, inclusive. In the second line there is a single integer n (1 ≀ n ≀ 10). Next n lines, there is a string bi (1 ≀ i ≀ n). Each length of bi will be between 1 and 10, inclusive. Each character of the given strings will be either a English a...
["12 4", "0 0", "5 5"]
#include <stdio.h> #define MAX 100010 int match[MAX], n, m, l, i, j, ok, len, pos; char str[MAX], buf[11]; int main() { scanf( "%s%d", str, &m ); while(str[n]) n++; while(m--) { scanf( "%s", buf ); for( l = 0; buf[l]; l++ ); for( i = 0; i + l <= n; i++ ) { ok = 1; for( j = 0; j < l; j++ ) if( str[i...
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the world.There is at most one edg...
Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.
C
6cf43241b14e4d41ad5b36572f3b3663
816bdde9031eeecdb278ffbd26cd02ed
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "dfs and similar", "graphs" ]
1481992500
["4 1 2\n1 3\n1 2", "3 3 1\n2\n1 2\n1 3\n2 3"]
NoteFor the first sample test, the graph looks like this: Vertices 1 and 3 are special. The optimal solution is to connect vertex 4 to vertices 1 and 2. This adds a total of 2 edges. We cannot add any more edges, since vertices 1 and 3 cannot have any path between them.For the second sample test, the graph looks lik...
PASSED
1,500
standard input
2 seconds
The first line of input will contain three integers n, m and k (1 ≀ n ≀ 1 000, 0 ≀ m ≀ 100 000, 1 ≀ k ≀ n)Β β€” the number of vertices and edges in the graph, and the number of vertices that are homes of the government. The next line of input will contain k integers c1, c2, ..., ck (1 ≀ ci ≀ n). These integers will be pa...
["2", "0"]
#include <stdio.h> #include <string.h> int c[1005], p[1005], sz[1005], gov[1005]; int find_parent(int n) { if (p[n] == n) return n; return p[n] = find_parent(p[n]); } int get_full_size(int n) { return n * (n-1) / 2; } int main(int argc, char** argv) { int i, n, m, k, u, v, max_size, total_fr...
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the world.There is at most one edg...
Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.
C
6cf43241b14e4d41ad5b36572f3b3663
b51b1b60e2dd2a316e999a54b257725b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dfs and similar", "graphs" ]
1481992500
["4 1 2\n1 3\n1 2", "3 3 1\n2\n1 2\n1 3\n2 3"]
NoteFor the first sample test, the graph looks like this: Vertices 1 and 3 are special. The optimal solution is to connect vertex 4 to vertices 1 and 2. This adds a total of 2 edges. We cannot add any more edges, since vertices 1 and 3 cannot have any path between them.For the second sample test, the graph looks lik...
PASSED
1,500
standard input
2 seconds
The first line of input will contain three integers n, m and k (1 ≀ n ≀ 1 000, 0 ≀ m ≀ 100 000, 1 ≀ k ≀ n)Β β€” the number of vertices and edges in the graph, and the number of vertices that are homes of the government. The next line of input will contain k integers c1, c2, ..., ck (1 ≀ ci ≀ n). These integers will be pa...
["2", "0"]
#include<stdio.h> typedef long long unsigned llu; typedef unsigned u; u G[1111][1111],Gi[1111],V[1111],S[1111]; u D(u n) { if(V[n])return 0;u i,j=V[n]=1; for(i=Gi[n];i--;)j+=D(G[n][i]); return j; } int main() { u n,q,x,i=-1,j,k,e=0; for(scanf("%u%u%u",&n,&q,&x);++i<x;)scanf("%u",S+i); for(i=-1;++i<q;) { scanf(...
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the world.There is at most one edg...
Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.
C
6cf43241b14e4d41ad5b36572f3b3663
f75aac374b0dd7589c7e5913f3eadee0
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dfs and similar", "graphs" ]
1481992500
["4 1 2\n1 3\n1 2", "3 3 1\n2\n1 2\n1 3\n2 3"]
NoteFor the first sample test, the graph looks like this: Vertices 1 and 3 are special. The optimal solution is to connect vertex 4 to vertices 1 and 2. This adds a total of 2 edges. We cannot add any more edges, since vertices 1 and 3 cannot have any path between them.For the second sample test, the graph looks lik...
PASSED
1,500
standard input
2 seconds
The first line of input will contain three integers n, m and k (1 ≀ n ≀ 1 000, 0 ≀ m ≀ 100 000, 1 ≀ k ≀ n)Β β€” the number of vertices and edges in the graph, and the number of vertices that are homes of the government. The next line of input will contain k integers c1, c2, ..., ck (1 ≀ ci ≀ n). These integers will be pa...
["2", "0"]
#ifdef ONLINE_JUDGE #define NDEBUG 1 #endif #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <limits.h> #include <string.h> #ifndef __cplusplus typedef int8_t bool; #define true 1 #define false 0 #endif #define long int64_t #define fore(i,k,n) for (int _k = (k), ...
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the world.There is at most one edg...
Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.
C
6cf43241b14e4d41ad5b36572f3b3663
ae2a5431b429a8bba259a09a5356fc8a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dfs and similar", "graphs" ]
1481992500
["4 1 2\n1 3\n1 2", "3 3 1\n2\n1 2\n1 3\n2 3"]
NoteFor the first sample test, the graph looks like this: Vertices 1 and 3 are special. The optimal solution is to connect vertex 4 to vertices 1 and 2. This adds a total of 2 edges. We cannot add any more edges, since vertices 1 and 3 cannot have any path between them.For the second sample test, the graph looks lik...
PASSED
1,500
standard input
2 seconds
The first line of input will contain three integers n, m and k (1 ≀ n ≀ 1 000, 0 ≀ m ≀ 100 000, 1 ≀ k ≀ n)Β β€” the number of vertices and edges in the graph, and the number of vertices that are homes of the government. The next line of input will contain k integers c1, c2, ..., ck (1 ≀ ci ≀ n). These integers will be pa...
["2", "0"]
#include<stdio.h> int parentOf(int parent[],int root) { if(parent[root]==-1) return root; else return parentOf(parent,parent[root]); } int max(int size[],int i,int j) { if(size[i]>size[j]) return i; else return j; } int main() { int n,m,k; scanf("%d %d %d",&n,&m,&k); in...
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the world.There is at most one edg...
Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.
C
6cf43241b14e4d41ad5b36572f3b3663
b2561f27643d81c0d2a395a237d4ee0c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dfs and similar", "graphs" ]
1481992500
["4 1 2\n1 3\n1 2", "3 3 1\n2\n1 2\n1 3\n2 3"]
NoteFor the first sample test, the graph looks like this: Vertices 1 and 3 are special. The optimal solution is to connect vertex 4 to vertices 1 and 2. This adds a total of 2 edges. We cannot add any more edges, since vertices 1 and 3 cannot have any path between them.For the second sample test, the graph looks lik...
PASSED
1,500
standard input
2 seconds
The first line of input will contain three integers n, m and k (1 ≀ n ≀ 1 000, 0 ≀ m ≀ 100 000, 1 ≀ k ≀ n)Β β€” the number of vertices and edges in the graph, and the number of vertices that are homes of the government. The next line of input will contain k integers c1, c2, ..., ck (1 ≀ ci ≀ n). These integers will be pa...
["2", "0"]
#include <stdio.h> #include <string.h> int n,m,k,sv[1010],se[1010],c[1010],vis[1010],map[1010][1010],d[1010]; void dfs(int u,int *sumv,int *sume); int main(void) { //freopen("nation.in","r",stdin); //freopen("nation.out","w",stdout); scanf("%d%d%d",&n,&m,&k); int i; for(i=1;i<=k;i++) scanf...
Offering the ABBYY Cup participants a problem written by the Smart Beaver is becoming a tradition. He proposed the following problem.You are given a monochrome image, that is, an image that is composed of two colors (black and white). The image is given in raster form, that is, as a matrix of pixels' colors, and the ma...
Print exactly two integers, separated by a single space β€” the number of circles and the number of squares in the given image, correspondingly.
C
06c7699523a9f8036330857660c0687e
ee23c39cdc2d96f13b62a994683f1a59
GNU C
standard output
256 megabytes
train_001.jsonl
[]
1335614400
[]
NoteYou are given a sample of original data for each difficulty level. The samples are available at http://codeforces.ru/static/materials/contests/178/e-samples.zip .
PASSED
1,900
standard input
5 seconds
The first input line contains a single integer n (1000 ≀ n ≀ 2000), which is the length and the width of the original image. Next n lines describe the matrix of colors of the image pixels. The i-th line contains exactly n integers aij (0 ≀ aij ≀ 1), separated by spaces. Value of aij = 0 corresponds to a white pixel an...
[]
#include <stdio.h> int a[2002][2002]; void dfs(int x, int y) { if (a[x][y] == 0) return; a[x][y] = 0; dfs(x, y + 1); dfs(x, y - 1); dfs(x + 1, y); } int main() { int n, b = 0, c = 0, i, j; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) {...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
c318ab0f1d4d8c322b29eb770b8e153e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include <stdio.h> int main(void) { int i,ac=0,bc=0; char a[1005],b[1005]; gets(a); gets(b); i=0; while(a[i]!=NULL) { if(a[i]=='1') ac++; i++; } i=0; while(b[i]!=NULL) { if(b[i]=='1') bc++; i++; } if((ac>=bc)||(ac%2!=0&...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
55254c29ff1116a8088ba03f1a6de09e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include<stdio.h> #include<string.h> main() { char a[1001],b[1001]; scanf("%s%s",a,b); int no_one=0,no_of_one=0,i; for(i=0;i<strlen(a);i++) { if(a[i]=='1') no_of_one++; } for(i=0;i<strlen(b);i++) { if(b[i]=='1') no_one++; } if(no_of_one%2==...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
5dbad053a07a2412e9971708a897e619
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include <stdio.h> #include <string.h> #include <math.h> int main (){ char a[10000], b[10000]; int m=0, n=0, i; scanf ("%s %s", a, b); for (i=0;a[i]!='\0';i++) { if (a[i]==49){ m++; } } for (i=0;b[i]!='\0';i++) { if (b[i]==49){ n++; } } if...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
11f6c0e6f179b4ab34daa27561841cda
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include<stdio.h> #define MAX_L 1005 char iput[MAX_L], oput[MAX_L]; int main () { int i, nri, nro; scanf("%s", &iput); scanf("%s", &oput); i = 0; nri = 0; while(iput[i] != 0) { if(iput[i] - '0' == 1) { nri++; } //printf("%d", iput[i] -...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
f93cc32f484f22bdc47c34c8aefe037b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include<stdio.h> int main() { int i,cnta=0,cntb=0; char a[1001],b[1001]; scanf("%s%s",a,b); for(i=0;a[i]!='\0';i++) if(a[i]=='1')cnta++; for(i=0;b[i]!='\0';i++) if(b[i]=='1')cntb++; if(cnta&1) { if(cntb<=cnta+1) printf("YES"); else printf("NO"); } else { if(cntb<=cnta)printf("YES"); else printf("NO"); } return 0; }
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
fab82049c18485d9608bca971252c5a6
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include<stdio.h> #include<string.h> char a[1100]; char b[1100]; int main() { scanf("%s", a); scanf("%s", b); int alen = strlen(a); int blen = strlen(b); int aone = 0, bone = 0; int i; for(i = 0; i < alen; i++) { if(a[i] == '1') aone ++; } for(i = 0; i < blen; i++) { if(b[i] == '1'...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
d18a0bd850852ef39a6073b6a1c0ed93
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include<stdio.h> #include<string.h> int main() { int i,q1,q2; char a[1100],b[1100]; scanf("%s",a); scanf("%s",b); q1=0;q2=0; for(i=0;a[i]!=0;i++) if(a[i]=='1') q1++; for(i=0;b[i]!=0;i++) if(b[i]=='1') q2++; if(q1%2==1) q1++; if(q1<q2) printf("NO\n"); else printf("YES\n"); re...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
6b9121bfd813adb2d025154830287e49
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include<stdio.h> #include<string.h> main() { char a[1002],b[1002]; int i,aone=0,bone=0; scanf("%s",a); scanf("%s",b); for(i=0;i<strlen(a);i++) if(a[i]=='1') aone++; for(i=0;i<strlen(b);i++) if(b[i]=='1') bone++; if(aone%2) ...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
8114deb04667b921308bde8e09faba88
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include<stdio.h> #include<string.h> int main() { char str[1001]={'\0'},str2[1001]={'\0'}; gets(str); gets(str2); int i,a=0,b=0; for(i=0;str[i]!='\0';i++) { if(str[i]=='1') a++; } for(i=0;str2[i]!='\0';i++) { if(str2[i]=='1') b++; } if...
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations: Write parity(a) to...
Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.
C
cf86add6c92fa8a72b8e23efbdb38613
e357ab67f9079e08886a22272646345a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms" ]
1366385400
["01011\n0110", "0011\n1110"]
NoteIn the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110
PASSED
1,700
standard input
1 second
The first line contains the string a and the second line contains the string b (1 ≀ |a|, |b| ≀ 1000). Both strings contain only the characters "0" and "1". Here |x| denotes the length of the string x.
["YES", "NO"]
#include<stdio.h> #include<string.h> int main() { char str[1001]={'\0'},str2[1001]={'\0'}; gets(str); gets(str2); int i,a=0,b=0; for(i=0;str[i]!='\0';i++) { if(str[i]=='1') a++; } for(i=0;str2[i]!='\0';i++) { if(str2[i]=='1') b++; } a=...
ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1.When ZS the Coder is at level k, he can : Press the ' + ' ...
Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed tha...
C
6264405c66b2690ada9f8cc6cff55f0b
fd87fc2d888f87b14e9f0df5ce16e2ce
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "math" ]
1474119900
["3", "2", "4"]
NoteIn the first sample case:On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14Β·1 = 16. Then, ZS the Coder pressed the '' button, and the number became . After that, on the second level, ZS pressed the ' + ' button 16 times, so the n...
PASSED
1,600
standard input
2 seconds
The first and only line of the input contains a single integer n (1 ≀ n ≀ 100 000), denoting that ZS the Coder wants to reach level n + 1.
["14\n16\n46", "999999999999999998\n44500000000", "2\n17\n46\n97"]
#include<stdio.h> #include<math.h> int main() { long long level, i; scanf("%I64d",&level); printf("2\n"); if(level == 1) return 0; for(i=2; i<=level; i++) printf("%I64d\n", (i*(i+1)*(i+1))-i+1); return 0; }
ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1.When ZS the Coder is at level k, he can : Press the ' + ' ...
Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed tha...
C
6264405c66b2690ada9f8cc6cff55f0b
e903aebeac6dbb667b8b5a4d1b6960b6
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "math" ]
1474119900
["3", "2", "4"]
NoteIn the first sample case:On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14Β·1 = 16. Then, ZS the Coder pressed the '' button, and the number became . After that, on the second level, ZS pressed the ' + ' button 16 times, so the n...
PASSED
1,600
standard input
2 seconds
The first and only line of the input contains a single integer n (1 ≀ n ≀ 100 000), denoting that ZS the Coder wants to reach level n + 1.
["14\n16\n46", "999999999999999998\n44500000000", "2\n17\n46\n97"]
#include<stdio.h> #include<math.h> int main() { long long int level, i, k; scanf("%I64d",&level); printf("2"); if(level == 1) return 0; puts(""); for(i=2; i<level; i++) { k = i*(i+1)*(i+1)-i+1; printf("%I64d\n", k); } if(level == 1000000) k = 1000001000002; else k = i*(i+1)*(i+1)-i+1; printf("%I64d", k);...
ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1.When ZS the Coder is at level k, he can : Press the ' + ' ...
Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed tha...
C
6264405c66b2690ada9f8cc6cff55f0b
41f8abe4e05f9b7354177af5f6a63b2f
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "math" ]
1474119900
["3", "2", "4"]
NoteIn the first sample case:On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14Β·1 = 16. Then, ZS the Coder pressed the '' button, and the number became . After that, on the second level, ZS pressed the ' + ' button 16 times, so the n...
PASSED
1,600
standard input
2 seconds
The first and only line of the input contains a single integer n (1 ≀ n ≀ 100 000), denoting that ZS the Coder wants to reach level n + 1.
["14\n16\n46", "999999999999999998\n44500000000", "2\n17\n46\n97"]
#include<stdio.h> int main(void){ long long f=2,n,i,j,k,calc; scanf("%I64d",&n); for(i=1;i<=n;i++){ calc=i*(i+1)*(i+1)-f/i; printf("%I64d\n",calc); f=i*(i+1); } return 0; }
ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1.When ZS the Coder is at level k, he can : Press the ' + ' ...
Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed tha...
C
6264405c66b2690ada9f8cc6cff55f0b
9e77a28ff5efc50a8c1e7eea13591b77
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "math" ]
1474119900
["3", "2", "4"]
NoteIn the first sample case:On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14Β·1 = 16. Then, ZS the Coder pressed the '' button, and the number became . After that, on the second level, ZS pressed the ' + ' button 16 times, so the n...
PASSED
1,600
standard input
2 seconds
The first and only line of the input contains a single integer n (1 ≀ n ≀ 100 000), denoting that ZS the Coder wants to reach level n + 1.
["14\n16\n46", "999999999999999998\n44500000000", "2\n17\n46\n97"]
#include<stdio.h> int main() { int n; unsigned long long int i,m=2,gmd; scanf("%d",&n); printf("2\n"); for(i=2;i<=n;i++) printf("%I64d\n",i*(i+1)*(i+1)-i+1); return 0; }
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya has sequence a consisting of n integers.The subsequence of the sequence a is such subsequence ...
On the single line print the single number β€” the answer to the problem modulo prime number 1000000007 (109 + 7).
C
c421f47149e70240a02903d9d47de429
d43975959d7ad6357c93533e4b21ac50
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dp", "combinatorics" ]
1327215600
["3 2\n10 10 10", "4 2\n4 4 7 7"]
NoteIn the first sample all 3 subsequences of the needed length are considered lucky.In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.
PASSED
2,100
standard input
2 seconds
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n integers ai (1 ≀ ai ≀ 109) β€” the sequence a.
["3", "4"]
#include <stdio.h> #include <stdlib.h> int a[100000], b[50000], c[100000]; int dp[100001]; int cmp(const void *a, const void *b) { return *((int *)a) - *((int *)b); } int lucky(int n) { while (n) { if (n % 10 != 4 && n % 10 != 7) { return 0; } n /= 10; } return 1; } int extgcd...
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya has sequence a consisting of n integers.The subsequence of the sequence a is such subsequence ...
On the single line print the single number β€” the answer to the problem modulo prime number 1000000007 (109 + 7).
C
c421f47149e70240a02903d9d47de429
59c0aca6ac38670c9ee24d78e6c05133
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dp", "combinatorics" ]
1327215600
["3 2\n10 10 10", "4 2\n4 4 7 7"]
NoteIn the first sample all 3 subsequences of the needed length are considered lucky.In the second sample there are 4 lucky subsequences. For them the sets of indexes equal (the indexation starts from 1): {1, 3}, {1, 4}, {2, 3} and {2, 4}.
PASSED
2,100
standard input
2 seconds
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n integers ai (1 ≀ ai ≀ 109) β€” the sequence a.
["3", "4"]
#include <stdio.h> #define maxn 100070 #define prime 10007 #define mod 1000000007 typedef long long int64; int cast[prime + maxn]; int key[prime + maxn]; int next[prime + maxn]; int a[maxn]; int64 b[maxn]; int is_lucky (int t) { for (; t; t /= 10) if (t % 10 != 4 && t % 10 != 7) return 0; return 1; } ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
2f5de0af42d43d5c56098258bf46cd70
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main(){ int n,val,five=0,zero=0,i,j,flag=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&val); if( val==5) five+=1; if(val==0) zero+=1; } if(zero==0){ ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
95f4744eb58556b3563385bdd6be85ca
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include <stdio.h> int main(int argc, char ** argv) { int nZeros = 0, nFives = 0, n, i = 0; scanf("%i", &n); for (; i < n; ++i) { int a; scanf("%i", &a); if (a) { ++nFives; } else { ++nZeros; } } if ((nFives >= 9) && nZeros) { for (i = 0; i < nFives / 9; ++i) { printf(...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
ae45c09abe5e643b9ea37dc140146530
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include <stdio.h> #include <stdlib.h> int main() { int n; scanf("%d",&n); int arr[n]; int i; int noF=0; int noZ=0; for(i=0;i<n;i++){ scanf("%d",&arr[i]); if(arr[i]==5) noF++; if(arr[i]==0) noZ++; } if(noZ<1){ printf("-1"); ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
fc66cf8befa67eda78cf2afaeede91ea
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> #include<conio.h> int main() { int no; int i; int no_of_five=0; int no_of_zero=0; int nooftimes; scanf("%d",&nooftimes); for(i=0;i<nooftimes;i++) { scanf("%d",&no); if(no==5) no_of_five++; else no_of_zero++; } if(no_of_zero==0) { printf("-1"); return 0; } if(no_of_five<9...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
75b5254ff2465881aa6f7273e52ae462
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() { int a,sum=0,count=0,p,i,j; scanf("%d",&a); int arr[a]; for(i=0;i<a;i++) scanf("%d",&arr[i]); for(i=0;i<a;i++) { if(arr[i]==5) count++; if(arr[i]==0) sum++; } if(count==0&&sum!=0) { printf("0"); return 0; } if(sum==0) { printf("-1"); return 0; } if(count<9) { ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
4ba70ef0dbb776e85e8907868c737f7b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> #include<math.h> #define getchar getchar//_unlocked #define M 1000000007 int getint () { int n=0; char ch=getchar(); while(ch<'0' || ch>'9') ch=getchar(); while(ch>='0' && ch<='9') { n=n*10+ch-'0'; ch=getchar(); ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
41440d33553127d862b27538955c8af3
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() { int n,ct1=0,ct2=0,ct3=0,i; scanf("%d",&n); int a[n]; for(i=0;i<n;++i) { scanf("%d",&a[i]); if(a[i]==5) ct1++; else ct2++; } ct3=ct1/9; if(ct2==0) printf("-1"); else if(ct3==0 && ct2!=0) printf("0"); ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
bb1e95fa9a6002bcb26de8f2adb2db65
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int n,i,j,b,s; int main() { scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&j); if(!j) s++; else b++; } if(!s) printf("-1"); else { for(i=1;i<=(b/9)*9;i++) printf("5"); for(i=0;i<s && (b/9 || !i);i++) printf("0"); } return 0; }
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
4fd7021985d52a001762f21e3502bece
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() { int n,i,dig,zero,five,val; scanf("%d",&n); zero = five = 0; for (i = 0; i < n; i++) { scanf("%d",&dig); if (dig == 0) { zero++; } else { five++; } } if (zero == 0) { printf("-1\n"); return 0; } val = five / 9; if (val == 0) { printf("0\n"); return 0; } for...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
d0e7a5374e62db3fdff79c14f425c405
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() {int n,count1=0,count2=0,i,count3=0,a; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a); if(a==5) count1++; if(a==0) count2++; } count3=count1*5; if(count3>=45 && count2>0 ) { while(count3%9!=0) { count3-=5; count1--; } for(i=0;i<count1;i++) printf("5"); for(i=0;i<count2;i+...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
1ed4731a88b924cff525d94c94235067
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() {int n,count1=0,count2=0,i,count3=0,a; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a); if(a==5) count1++; if(a==0) count2++; } count3=count1*5; if(count3>=45 && count2>0 ) { count3-=count3%45; count1=count3/5; for(i=0;i<count1;i++) printf("5"); for(i=0;i<count2;i++) printf("0"); } e...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
19cd77c2cf17be7bb6989d57dba40ed2
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include <stdio.h> #include <string.h> int main() { int i,j,k,n,p=0,q=0,f; scanf("%d",&n); int ara[n]; for(i=0;i<n;i++) { scanf("%d",&ara[i]); } for(i=0;i<n;i++) { if(ara[i]==5) p=p+1; else q=q+1; } if(q==0) printf("-1"); ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
d97753d279a3efc86bbe184501f91b0b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include <stdio.h> #include <string.h> int main() { int i,j,k,n,p=0,q=0; scanf("%d",&n); int ara[n]; for(i=0;i<n;i++) { scanf("%d",&ara[i]); } for(i=0;i<n;i++) { if(ara[i]==5) p=p+1; else q=q+1; } if(q==0) printf("-1"); ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
ba3c7c4eb6348f27415964a9b86d1f6e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() { int n,a[100000]; scanf("%d",&n); int i; for(i=0;i<n;i++) scanf("%d",&a[i]); int c=0; for(i=0;i<n;i++) if(a[i]==5) c++; int d; d=n-c; c=c/9; c=c*9; if(d==0) printf("-1"); else if(c==0) printf("0"); ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
0ac57b1ace6bd826e1c8932612700659
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> #include<string.h> int main() { int n,a[1010],i,c5=0,c0=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]==5) c5++; else c0++; } if(c0==0) printf("-1"); else { for(i=1;i<=c5/9;i++) { printf("555555555"); } if(c5<9) printf("0"); else for(i=1;i<=c0...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
401b29f59abe4e00a482c7ce131a5538
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() { int n,c5,c0,i,temp; c5=0; c0=0; scanf("%d",&n); for(i=0;i<n;i++) {scanf("%d",&temp); (temp==0?c0++:c5++);} if((c5>=9)&&(c0!=0)) {for(i=0;i<(c5-c5%9);i++) printf("%d",5); for(i=0;i<c0;i++) printf("%d",0);} else if(c0==0) printf("-1"); else printf("%d",0); return 0; }
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
37749f7edaeb6cca700eea8a9f5d562d
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include <stdio.h> typedef int card[1001]; typedef struct { card kartu; int byk; } kkartu; void cek (kkartu X); int main() { kkartu X; int i; scanf ("%d", &X.byk); for (i = 1; i <= X.byk; i++) { scanf ("%d", &X.kartu[i]); } cek (X); return 0; } v...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
d11c4d513b8f99166d8adaa88b68df49
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() { int n,count5,count0,i,t; while(scanf("%d",&n)!=EOF) { count5=0; count0=0; for(i=0;i<n;i++) { scanf("%d",&t); if(t==5) count5++; else count0++; } if(count0==0) { printf("-1\n...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
7d85eb1390aa494ff7a2bffc2d301612
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main(){ int five=0,zero=0; int i,n,aux; int times; scanf("%d",&n); for(i=0; i<n; i++){ scanf("%d",&aux); if(aux==5) five++; else zero++; } if(five>=9 && zero>0) { times = (five/9)*9; for(i=0; i<tim...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
83893cc4ca7fad36db4aa40846961a96
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> long long int Power(long long int a, long long int b) { long long int x=a,y=b,p=1; while(y--) p=p*x; return p; } int main() { long long int i,n,z=0,temp=0,ans=0,t=1; long long int A[1000]; scanf("%lld", &n); for(i=0;i<n;i++) { scanf("%lld", &A[i]); if(A[i]==5) temp++; ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
2efecc185c2c3b5fb967b084879b5914
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() { unsigned short int n,count5=0,count0=0,dig; scanf("%hd",&n); while(n--) { scanf("%hd",&dig); if(dig==5) count5++; else count0++; } count5/=9; count5*=9; if(count5==0&&count0!=0) printf("0"); else if(count5==0&&count0==0||count5!=0&&count0==0) printf("-1"); else ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
67c00253851cd0846cedae3154d81e5a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include<stdio.h> int main() { int n,i,c0=0,c5=0; scanf("%d",&n); int a[n]; for(i=0;i<n;i++) {scanf("%d",&a[i]); if(a[i]==0) c0++; else c5++;} if(c5<9){ if(c0>0) printf("0"); else printf("-1"); } else {if(c0==0) printf("-1"); else{ for(i=0;i<c5-c5%9;i++) printf("5"); for(i=0;i<c0;i++) printf("0");}} return 0;}
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
57ece96d50b262af755e221a68dc66f2
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include <stdio.h> int main() { int a,b,zero=0,five=0,c,n,s[10001]; scanf("%d",&n); for(a=1;a<=n;a++){ scanf("%d",&s[a]); if(s[a]==0) zero++; else five++; } if(zero==0) printf("-1"); else if(five<9) printf("0"); else{ ...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
899071e7c74d38f4228c45fb4ac2fa9e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include <stdio.h> int main() { int n; scanf("%d",&n); int f=0,o=0,i,x; for(i=0;i<n;i++) { scanf("%d",&x); if(x==5) f++; else o++; } if(f<9 && o >0) printf("0\n"); else if(f>=9 && o>=1) { for(i=0;i<(f/9)*9;i++) printf("5"); for(i=0;i<o;i++) printf("0"); } else printf("-1\n"); retu...
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 ...
In a single line print the answer to the problem β€” the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.
C
409b27044d5ec97b5315c92d4112376f
6af1fa01b5d1cee9808f5ac45d8f19f5
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1380900600
["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5"]
NoteIn the first test you can make only one number that is a multiple of 90 β€” 0.In the second test you can make number 5555555550, it is a multiple of 90.
PASSED
1,000
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.
["0", "5555555550"]
#include <stdio.h> #include <string.h> int main () { int i, n, a[1100], c5 = 0, c0 = 0; scanf ("%d", &n); for (i=1; i<=n; i++) { scanf ("%d", &a[i]); if (a[i] == 5) { c5 += 1; } else { c0 += 1; } } c5 = c5 / 9; if (c0 == 0) { printf ("-1"); return 0; } if (c5 == 0) { c0 = 1; } for (i=1...
Consider some set of distinct characters $$$A$$$ and some string $$$S$$$, consisting of exactly $$$n$$$ characters, where each character is present in $$$A$$$.You are given an array of $$$m$$$ integers $$$b$$$ ($$$b_1 &lt; b_2 &lt; \dots &lt; b_m$$$). You are allowed to perform the following move on the string $$$S$$$:...
Print a single integer β€” the number of distinct strings of length $$$n$$$ with characters from set $$$A$$$ modulo $$$998244353$$$.
C
385ac4db5b0e7613b03fb4f1044367dd
a8f06a6f0c7264ba66e610e0a4368b5d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "combinatorics", "strings" ]
1539269400
["3 1 2\n1", "9 2 26\n2 3", "12 3 1\n2 5 6"]
NoteHere are all the distinct strings for the first example. The chosen letters 'a' and 'b' are there just to show that the characters in $$$A$$$ are different. "aaa" "aab" = "baa" "aba" "abb" = "bba" "bab" "bbb"
PASSED
2,300
standard input
2 seconds
The first line contains three integers $$$n$$$, $$$m$$$ and $$$|A|$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le m \le min(\frac n 2, 2 \cdot 10^5)$$$, $$$1 \le |A| \le 10^9$$$) β€” the length of the strings, the size of the array $$$b$$$ and the size of the set $$$A$$$, respectively. The second line contains $$$m$$$ integers $$$...
["6", "150352234", "1"]
#include <stdio.h> #define mod 998244353 int n,m,k,z,i,ans=1,a[200005]; int fastpow(int x,int y) { int v=1; while (y) { if (y&1) v=1LL*v*x%mod; x=1LL*x*x%mod; y>>=1; } return v; } int main() { register int i; scanf("%d%d%d",&n,&m,&k); for (i=1;i<=m;i++) { scanf("%d",a+i); z=fastpow(k,a[i]-a[i-1]); ...
Consider some set of distinct characters $$$A$$$ and some string $$$S$$$, consisting of exactly $$$n$$$ characters, where each character is present in $$$A$$$.You are given an array of $$$m$$$ integers $$$b$$$ ($$$b_1 &lt; b_2 &lt; \dots &lt; b_m$$$). You are allowed to perform the following move on the string $$$S$$$:...
Print a single integer β€” the number of distinct strings of length $$$n$$$ with characters from set $$$A$$$ modulo $$$998244353$$$.
C
385ac4db5b0e7613b03fb4f1044367dd
b7f978bf4100cfa5a8971d0cd12a4670
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "combinatorics", "strings" ]
1539269400
["3 1 2\n1", "9 2 26\n2 3", "12 3 1\n2 5 6"]
NoteHere are all the distinct strings for the first example. The chosen letters 'a' and 'b' are there just to show that the characters in $$$A$$$ are different. "aaa" "aab" = "baa" "aba" "abb" = "bba" "bab" "bbb"
PASSED
2,300
standard input
2 seconds
The first line contains three integers $$$n$$$, $$$m$$$ and $$$|A|$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le m \le min(\frac n 2, 2 \cdot 10^5)$$$, $$$1 \le |A| \le 10^9$$$) β€” the length of the strings, the size of the array $$$b$$$ and the size of the set $$$A$$$, respectively. The second line contains $$$m$$$ integers $$$...
["6", "150352234", "1"]
/** * Code by Van Linh */ #include <stdio.h> #include <stdint.h> #include <inttypes.h> // Modul #define MODULA 998244353 // Dau vao uint64_t n, m, A; uint64_t b[200001]; uint64_t powi(uint64_t a, uint64_t b) { uint64_t i, ret; if(b == 0) return 1; ret = powi(a, b/2); ret = (ret*ret) % MODULA; if(b % 2...
Consider some set of distinct characters $$$A$$$ and some string $$$S$$$, consisting of exactly $$$n$$$ characters, where each character is present in $$$A$$$.You are given an array of $$$m$$$ integers $$$b$$$ ($$$b_1 &lt; b_2 &lt; \dots &lt; b_m$$$). You are allowed to perform the following move on the string $$$S$$$:...
Print a single integer β€” the number of distinct strings of length $$$n$$$ with characters from set $$$A$$$ modulo $$$998244353$$$.
C
385ac4db5b0e7613b03fb4f1044367dd
0edd540006765b1e7625904d74c74a1b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "combinatorics", "strings" ]
1539269400
["3 1 2\n1", "9 2 26\n2 3", "12 3 1\n2 5 6"]
NoteHere are all the distinct strings for the first example. The chosen letters 'a' and 'b' are there just to show that the characters in $$$A$$$ are different. "aaa" "aab" = "baa" "aba" "abb" = "bba" "bab" "bbb"
PASSED
2,300
standard input
2 seconds
The first line contains three integers $$$n$$$, $$$m$$$ and $$$|A|$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le m \le min(\frac n 2, 2 \cdot 10^5)$$$, $$$1 \le |A| \le 10^9$$$) β€” the length of the strings, the size of the array $$$b$$$ and the size of the set $$$A$$$, respectively. The second line contains $$$m$$$ integers $$$...
["6", "150352234", "1"]
#include <stdio.h> #define M 200000 #define MD 998244353 long long power(int a, int b) { long long p; if (b == 0) return 1; p = power(a, b / 2); p = p * p % MD; if (b % 2 == 1) p = p * a % MD; return p; } int main() { int n, m, a, b_, b; long long ans; scanf("%d%d%d", &n, &m, &a); ans = 1; b_ = 0; ...
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned ov...
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
C
3fc0ac711b113fa98f41740536dad44f
31d2af4a5761992894dc906c5d6fe535
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1432053000
["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1"]
null
PASSED
900
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 100) β€” the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is...
["2\n1 3", "0"]
#include <stdio.h> #include <stdlib.h> int main () { int n, **a, i, j, co = 0, ch = 1, *b, k = 0; scanf("%d", &n); a = (int **)malloc(n * sizeof(int*)); b = (int *)malloc(n * sizeof(int)); for (i = 0; i < n; i++) a[i] = (int *)malloc(n * sizeof(int)); for(i = 0; i< n; i++) for(j...
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned ov...
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
C
3fc0ac711b113fa98f41740536dad44f
a32698eebcb36ba681b48448cdeefe22
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1432053000
["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1"]
null
PASSED
900
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 100) β€” the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is...
["2\n1 3", "0"]
#include <stdio.h> int main(){ int n, a, good[100000], pass[100000] = {0}; int i, j, count; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%d", &a); if (a == 0 || a == 2) { pass[i] += 1; } } } count = 0; for (i = 0; i < n; i++) { if (pass[i] == ...
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned ov...
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
C
3fc0ac711b113fa98f41740536dad44f
8a874df0d1407f5897e3d7e622f63100
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1432053000
["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1"]
null
PASSED
900
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 100) β€” the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is...
["2\n1 3", "0"]
#include <stdio.h> #include <stdlib.h> int main(){ int n, x, count = 0; scanf("%d", &n); int** matrix = (int**) malloc(sizeof(int*)*n); int* bool = (int*) malloc(sizeof(int)*n); for(int i=0; i<n; i++){ matrix[i] = (int*) malloc(sizeof(int)*n); bool[i] = 0; for(int j=0; j<n...
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned ov...
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
C
3fc0ac711b113fa98f41740536dad44f
d07f7307a60861ab532f488e3da41ab5
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1432053000
["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1"]
null
PASSED
900
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 100) β€” the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is...
["2\n1 3", "0"]
#include <stdio.h> int n, i, j, a, cars[101], res = 0; int main() { scanf("%d", &n); for(i = 1; i <= n; ++i) for(j = 1; j <= n; ++j) { scanf("%d", &a); switch(a) { case 1: ++cars[i]; break; case 2: ++cars[j]; break; case 3: ++cars[i]; ++cars[j]; break; } } for(i = 1; i <= n; ++i...
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned ov...
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
C
3fc0ac711b113fa98f41740536dad44f
06f07856264cf1f6660d5788e55d0829
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1432053000
["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1"]
null
PASSED
900
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 100) β€” the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is...
["2\n1 3", "0"]
#include <stdbool.h> #include <stdio.h> int main(void) { unsigned short cars; scanf("%hu", &cars); bool car_states[cars]; for (unsigned short i = 0; i < cars; ++i) car_states[i] = true; unsigned short counter = cars; for (unsigned short i = 0; i < cars; ++i) { for (unsigned short j = 0; j < ca...
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned ov...
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
C
3fc0ac711b113fa98f41740536dad44f
dd5ed64af295e993bc4ed6cd3b22b750
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1432053000
["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1"]
null
PASSED
900
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 100) β€” the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is...
["2\n1 3", "0"]
#include<stdio.h> int main() { int n,r,c,check=1,i=0; scanf("%d",&n); int a[n][n],save[n]; for(r=0;r<n;++r) { check=1; for(c=0;c<n;++c) { scanf("%d",&a[r][c]); if(a[r][c]==1||a[r][c]==3) check=0; } if(check==1) { save[i]=r+1; ++i; } } printf("%d\n",i); for(r=0;r<i;++r) printf("%d "...
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned ov...
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
C
3fc0ac711b113fa98f41740536dad44f
f28e1014421f03f5cf244126c744b73f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1432053000
["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1"]
null
PASSED
900
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 100) β€” the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is...
["2\n1 3", "0"]
#include <stdio.h> int main() { int n, i, j, m=0, k=0, p; int arr[103][103], arr2[103]; scanf("%d", &n); for(i=0; i<n; i++) { p=1; for(j=0; j<n; j++){ scanf("%d", &arr[i][j]); if(arr[i][j]==1 || arr[i][j]==3){ p=0; } } ...
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned ov...
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
C
3fc0ac711b113fa98f41740536dad44f
da1db6b25d81d2623b7e8c8410cf3091
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1432053000
["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1"]
null
PASSED
900
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 100) β€” the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is...
["2\n1 3", "0"]
#include<stdio.h> int ara2[101]; int main () { int n,i,j,count=0,p; scanf("%d",&n); int ara[n+1][n+1]; for(i=1; i<=n; i++) { for(j=1; j<=n; j++) { scanf("%d",&ara[i][j]); if(ara[i][j]==3) ara2[i]=ara2[j]=1; else if(ara[i][j]==1) ...