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
Polycarp has created his own training plan to prepare for the programming contests. He will train for $$$n$$$ days, all days are numbered from $$$1$$$ to $$$n$$$, beginning from the first.On the $$$i$$$-th day Polycarp will necessarily solve $$$a_i$$$ problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.Determine the index of day when Polycarp will celebrate the equator.
Print the index of the day when Polycarp will celebrate the equator.
C
241157c465fe5dd96acd514010904321
18ef1ff60604257a22449efc3cf29cbe
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1523370900
["4\n1 3 2 1", "6\n2 2 2 2 2 2"]
NoteIn the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve $$$4$$$ out of $$$7$$$ scheduled problems on four days of the training.In the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve $$$6$$$ out of $$$12$$$ scheduled problems on six days of the training.
PASSED
1,300
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) β€” the number of days to prepare for the programming contests. The second line contains a sequence $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10\,000$$$), where $$$a_i$$$ equals to the number of problems, which Polycarp will solve on the $$$i$$$-th day.
["2", "3"]
#include<stdio.h> #include<math.h> int main() { int i,cases; scanf("%d",&cases); int ara[cases]; int sum = 0; int sum2 = 0; for (i = 0; i < cases; i++) { scanf("%d", &ara[i]); sum += ara[i]; } sum = ceil(sum * 0.5); for (i = 0; sum2 < sum; i++) { sum2 += ara[i]; } printf("%d\n", i); return 0; }
Polycarp has created his own training plan to prepare for the programming contests. He will train for $$$n$$$ days, all days are numbered from $$$1$$$ to $$$n$$$, beginning from the first.On the $$$i$$$-th day Polycarp will necessarily solve $$$a_i$$$ problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.Determine the index of day when Polycarp will celebrate the equator.
Print the index of the day when Polycarp will celebrate the equator.
C
241157c465fe5dd96acd514010904321
0339a06657907a7c92a56d579a23a3a4
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1523370900
["4\n1 3 2 1", "6\n2 2 2 2 2 2"]
NoteIn the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve $$$4$$$ out of $$$7$$$ scheduled problems on four days of the training.In the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve $$$6$$$ out of $$$12$$$ scheduled problems on six days of the training.
PASSED
1,300
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) β€” the number of days to prepare for the programming contests. The second line contains a sequence $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10\,000$$$), where $$$a_i$$$ equals to the number of problems, which Polycarp will solve on the $$$i$$$-th day.
["2", "3"]
#include<stdio.h> int main() { int i,n,sum = 0; scanf("%d",&n); int a[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); sum = sum + a[i]; } if(sum%2 != 0) sum++; n = (sum/2); i = 0; sum = 0; while(sum<n) { sum = sum + a[i]; i++; } printf("%d",i); return 0; }
Polycarp has created his own training plan to prepare for the programming contests. He will train for $$$n$$$ days, all days are numbered from $$$1$$$ to $$$n$$$, beginning from the first.On the $$$i$$$-th day Polycarp will necessarily solve $$$a_i$$$ problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.Determine the index of day when Polycarp will celebrate the equator.
Print the index of the day when Polycarp will celebrate the equator.
C
241157c465fe5dd96acd514010904321
7da23d41ad40b33d7b15c6453a9805c6
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1523370900
["4\n1 3 2 1", "6\n2 2 2 2 2 2"]
NoteIn the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve $$$4$$$ out of $$$7$$$ scheduled problems on four days of the training.In the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve $$$6$$$ out of $$$12$$$ scheduled problems on six days of the training.
PASSED
1,300
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) β€” the number of days to prepare for the programming contests. The second line contains a sequence $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10\,000$$$), where $$$a_i$$$ equals to the number of problems, which Polycarp will solve on the $$$i$$$-th day.
["2", "3"]
#include<stdio.h> int main() { int n; scanf("%d",&n); int i,ara[n]; for(i=0;i<n;i++) { scanf("%d",&ara[i]); } int sum=0; for(i=0;i<n;i++) { sum+=ara[i]; } int count=0; int count1=0; if(n==1) { printf("%d",1); } else if(sum%2==0) { for(i=0;i<n;i++) { count+=ara[i]; if(count>=sum/2) { printf("%d",i+1); break; } } } else { for(i=0;i<n;i++) { count1+=ara[i]; if(count1>sum/2) { printf("%d",i+1); break; } } } return 0; }
Polycarp has created his own training plan to prepare for the programming contests. He will train for $$$n$$$ days, all days are numbered from $$$1$$$ to $$$n$$$, beginning from the first.On the $$$i$$$-th day Polycarp will necessarily solve $$$a_i$$$ problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.Determine the index of day when Polycarp will celebrate the equator.
Print the index of the day when Polycarp will celebrate the equator.
C
241157c465fe5dd96acd514010904321
0ecd1ba096d3ebe1874fe302529bb460
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1523370900
["4\n1 3 2 1", "6\n2 2 2 2 2 2"]
NoteIn the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve $$$4$$$ out of $$$7$$$ scheduled problems on four days of the training.In the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve $$$6$$$ out of $$$12$$$ scheduled problems on six days of the training.
PASSED
1,300
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) β€” the number of days to prepare for the programming contests. The second line contains a sequence $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10\,000$$$), where $$$a_i$$$ equals to the number of problems, which Polycarp will solve on the $$$i$$$-th day.
["2", "3"]
#include<stdio.h> int main() { int n; scanf("%d",&n); int a[n], i, sum=0, sum1=0; for(i=0;i<n;i++) { scanf("%d",&a[i]); sum+=a[i]; } for(i=0;i<n;i++) { sum1+=a[i]; if(sum1>=(0.5*sum)) break; } printf("%d",i+1); }
Polycarp has created his own training plan to prepare for the programming contests. He will train for $$$n$$$ days, all days are numbered from $$$1$$$ to $$$n$$$, beginning from the first.On the $$$i$$$-th day Polycarp will necessarily solve $$$a_i$$$ problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.Determine the index of day when Polycarp will celebrate the equator.
Print the index of the day when Polycarp will celebrate the equator.
C
241157c465fe5dd96acd514010904321
1474b5f0df8f4a388d1a8d6327900a39
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1523370900
["4\n1 3 2 1", "6\n2 2 2 2 2 2"]
NoteIn the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve $$$4$$$ out of $$$7$$$ scheduled problems on four days of the training.In the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve $$$6$$$ out of $$$12$$$ scheduled problems on six days of the training.
PASSED
1,300
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) β€” the number of days to prepare for the programming contests. The second line contains a sequence $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10\,000$$$), where $$$a_i$$$ equals to the number of problems, which Polycarp will solve on the $$$i$$$-th day.
["2", "3"]
#include<stdio.h> main() { int n,i,s=0,x=0; scanf("%d",&n); int a[n]; for(i=1;i<=n;i++) { scanf("%d",&a[i]); s=(s+a[i]); } i=0; if(s%2==0){ s=s/2; st: { x=a[i+1]+x; i++; if(x<s) goto st; }} else { s=s/2; s: { x=a[i+1]+x; i++; if(x<=s) goto s; } } printf("%d",i); }
Polycarp has created his own training plan to prepare for the programming contests. He will train for $$$n$$$ days, all days are numbered from $$$1$$$ to $$$n$$$, beginning from the first.On the $$$i$$$-th day Polycarp will necessarily solve $$$a_i$$$ problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.Determine the index of day when Polycarp will celebrate the equator.
Print the index of the day when Polycarp will celebrate the equator.
C
241157c465fe5dd96acd514010904321
86bb132c1d6363e017b236020eda3690
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1523370900
["4\n1 3 2 1", "6\n2 2 2 2 2 2"]
NoteIn the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve $$$4$$$ out of $$$7$$$ scheduled problems on four days of the training.In the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve $$$6$$$ out of $$$12$$$ scheduled problems on six days of the training.
PASSED
1,300
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) β€” the number of days to prepare for the programming contests. The second line contains a sequence $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10\,000$$$), where $$$a_i$$$ equals to the number of problems, which Polycarp will solve on the $$$i$$$-th day.
["2", "3"]
#include <stdio.h> int main() { long long int n; while(scanf("%lld",&n)!=EOF) { long long int i,a[200005],t=0,sum=0; for(i=0;i<n;i++) {scanf("%lld",&a[i]); sum=sum+a[i]; } for(i=0;i<n;i++) { t=t+a[i]; if(sum%2==0) { if(t>=sum/2) break; } if(sum%2==1) { if(t>=(sum/2+1)) break; } } printf("%lld\n",i+1); } return 0; }
It is winter now, and Max decided it's about time he watered the garden.The garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed xi), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed xi is turned on, then after one second has passed, the bed xi will be watered; after two seconds have passed, the beds from the segment [xi - 1, xi + 1] will be watered (if they exist); after j seconds have passed (j is an integer number), the beds from the segment [xi - (j - 1), xi + (j - 1)] will be watered (if they exist). Nothing changes during the seconds, so, for example, we can't say that the segment [xi - 2.5, xi + 2.5] will be watered after 2.5 seconds have passed; only the segment [xi - 2, xi + 2] will be watered at that moment. The garden from test 1. White colour denotes a garden bed without a tap, red colour β€” a garden bed with a tap. The garden from test 1 after 2 seconds have passed after turning on the tap. White colour denotes an unwatered garden bed, blue colour β€” a watered bed. Max wants to turn on all the water taps at the same moment, and now he wonders, what is the minimum number of seconds that have to pass after he turns on some taps until the whole garden is watered. Help him to find the answer!
For each test case print one integer β€” the minimum number of seconds that have to pass after Max turns on some of the water taps, until the whole garden is watered.
C
5de25068af66273c83cc7914910c4c84
fae328b949dc1ff8a8057dbd1630d38a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1517582100
["3\n5 1\n3\n3 3\n1 2 3\n4 1\n1"]
NoteThe first example consists of 3 tests: There are 5 garden beds, and a water tap in the bed 3. If we turn it on, then after 1 second passes, only bed 3 will be watered; after 2 seconds pass, beds [1, 3] will be watered, and after 3 seconds pass, everything will be watered. There are 3 garden beds, and there is a water tap in each one. If we turn all of them on, then everything will be watered after 1 second passes. There are 4 garden beds, and only one tap in the bed 1. It will take 4 seconds to water, for example, bed 4.
PASSED
1,000
standard input
1 second
The first line contains one integer t β€” the number of test cases to solve (1 ≀ t ≀ 200). Then t test cases follow. The first line of each test case contains two integers n and k (1 ≀ n ≀ 200, 1 ≀ k ≀ n) β€” the number of garden beds and water taps, respectively. Next line contains k integers xi (1 ≀ xi ≀ n) β€” the location of i-th water tap. It is guaranteed that for each condition xi - 1 &lt; xi holds. It is guaranteed that the sum of n over all test cases doesn't exceed 200. Note that in hacks you have to set t = 1.
["3\n1\n4"]
#include <stdio.h> int max (int a, int b) { int m = (a > b) ? a : b; return m; } int main () { int t; scanf ("%d", &t); while (t--) { int n, k, i, j; int x = 0, y, z; scanf ("%d%d", &n, &k); int tap [k]; for (i = 0; i < k; i++) scanf ("%d", &tap [i]); for (i = 1; i < k; i++) { for (j = 0; j < k-i; j++) { if (tap [j] > tap [j+1]) { int temp = tap [j]; tap [j] = tap [j+1]; tap [j+1] = temp; } } } for (i = 0; i < k-1; i++) { if (tap [i+1] - tap [i] > x) { x = tap [i+1] - tap [i]; } } x = (x+2)/2; y = tap [0]; z = n - tap [k-1] +1; int ans = max (y, z); ans = max (ans, x); printf ("%d\n", ans); } return 0; }
It is winter now, and Max decided it's about time he watered the garden.The garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed xi), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed xi is turned on, then after one second has passed, the bed xi will be watered; after two seconds have passed, the beds from the segment [xi - 1, xi + 1] will be watered (if they exist); after j seconds have passed (j is an integer number), the beds from the segment [xi - (j - 1), xi + (j - 1)] will be watered (if they exist). Nothing changes during the seconds, so, for example, we can't say that the segment [xi - 2.5, xi + 2.5] will be watered after 2.5 seconds have passed; only the segment [xi - 2, xi + 2] will be watered at that moment. The garden from test 1. White colour denotes a garden bed without a tap, red colour β€” a garden bed with a tap. The garden from test 1 after 2 seconds have passed after turning on the tap. White colour denotes an unwatered garden bed, blue colour β€” a watered bed. Max wants to turn on all the water taps at the same moment, and now he wonders, what is the minimum number of seconds that have to pass after he turns on some taps until the whole garden is watered. Help him to find the answer!
For each test case print one integer β€” the minimum number of seconds that have to pass after Max turns on some of the water taps, until the whole garden is watered.
C
5de25068af66273c83cc7914910c4c84
382a50f3ebf80abc50bfe81d58ef85b9
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1517582100
["3\n5 1\n3\n3 3\n1 2 3\n4 1\n1"]
NoteThe first example consists of 3 tests: There are 5 garden beds, and a water tap in the bed 3. If we turn it on, then after 1 second passes, only bed 3 will be watered; after 2 seconds pass, beds [1, 3] will be watered, and after 3 seconds pass, everything will be watered. There are 3 garden beds, and there is a water tap in each one. If we turn all of them on, then everything will be watered after 1 second passes. There are 4 garden beds, and only one tap in the bed 1. It will take 4 seconds to water, for example, bed 4.
PASSED
1,000
standard input
1 second
The first line contains one integer t β€” the number of test cases to solve (1 ≀ t ≀ 200). Then t test cases follow. The first line of each test case contains two integers n and k (1 ≀ n ≀ 200, 1 ≀ k ≀ n) β€” the number of garden beds and water taps, respectively. Next line contains k integers xi (1 ≀ xi ≀ n) β€” the location of i-th water tap. It is guaranteed that for each condition xi - 1 &lt; xi holds. It is guaranteed that the sum of n over all test cases doesn't exceed 200. Note that in hacks you have to set t = 1.
["3\n1\n4"]
p,m,t;main(n,k,a){for(scanf("%*d");~scanf("%d%d%d",&n,&k,&a);printf("%d ",(n-=--a)>m?n:m))for(p=m=a;--k;(t=a-p+2>>1)>m?m=t:0,p=a)scanf("%d",&a);}
It is winter now, and Max decided it's about time he watered the garden.The garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed xi), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed xi is turned on, then after one second has passed, the bed xi will be watered; after two seconds have passed, the beds from the segment [xi - 1, xi + 1] will be watered (if they exist); after j seconds have passed (j is an integer number), the beds from the segment [xi - (j - 1), xi + (j - 1)] will be watered (if they exist). Nothing changes during the seconds, so, for example, we can't say that the segment [xi - 2.5, xi + 2.5] will be watered after 2.5 seconds have passed; only the segment [xi - 2, xi + 2] will be watered at that moment. The garden from test 1. White colour denotes a garden bed without a tap, red colour β€” a garden bed with a tap. The garden from test 1 after 2 seconds have passed after turning on the tap. White colour denotes an unwatered garden bed, blue colour β€” a watered bed. Max wants to turn on all the water taps at the same moment, and now he wonders, what is the minimum number of seconds that have to pass after he turns on some taps until the whole garden is watered. Help him to find the answer!
For each test case print one integer β€” the minimum number of seconds that have to pass after Max turns on some of the water taps, until the whole garden is watered.
C
5de25068af66273c83cc7914910c4c84
66c83a5f5e9ccae67774499a599cc2bb
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1517582100
["3\n5 1\n3\n3 3\n1 2 3\n4 1\n1"]
NoteThe first example consists of 3 tests: There are 5 garden beds, and a water tap in the bed 3. If we turn it on, then after 1 second passes, only bed 3 will be watered; after 2 seconds pass, beds [1, 3] will be watered, and after 3 seconds pass, everything will be watered. There are 3 garden beds, and there is a water tap in each one. If we turn all of them on, then everything will be watered after 1 second passes. There are 4 garden beds, and only one tap in the bed 1. It will take 4 seconds to water, for example, bed 4.
PASSED
1,000
standard input
1 second
The first line contains one integer t β€” the number of test cases to solve (1 ≀ t ≀ 200). Then t test cases follow. The first line of each test case contains two integers n and k (1 ≀ n ≀ 200, 1 ≀ k ≀ n) β€” the number of garden beds and water taps, respectively. Next line contains k integers xi (1 ≀ xi ≀ n) β€” the location of i-th water tap. It is guaranteed that for each condition xi - 1 &lt; xi holds. It is guaranteed that the sum of n over all test cases doesn't exceed 200. Note that in hacks you have to set t = 1.
["3\n1\n4"]
#include<stdio.h> int maximum(int a,int b) { int d; if (a>b) d=a; else d=b; return d; } int main(){ int test; scanf("%d",&test); for(int i=0;i<test;i++) { int n,k; scanf("%d%d",&n,&k); int a[k]; for(int j=0;j<k;j++) scanf("%d",&a[j]); int max=0; for(int j=0;j<k-1;j++) { if(a[j+1]-a[j]>max) max=a[j+1]-a[j]; } int d=maximum(a[0],n-a[k-1]+1); int e=maximum(d,(max/2)+1); printf("%d\n",e); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
add73c5180a7ca7512925049684dfa2e
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n; scanf("%d",&n); if(n%2==0) { printf("%d\n",n*n/2); } else { printf("%d\n",(n*n+1)/2); } int i,j; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i%2==0) { if(j%2==0) { printf("C"); } else { printf("."); } } else { if(j%2==0) { printf("."); } else { printf("C"); } } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
871f34f638e49482c7ce0bbb759470e6
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> #include<string.h> int main () { int i,n,a; scanf("%d",&n); char string1[n+1],string2[n+1]; a=ceil((n*n)/2.0); printf("%ld\n",a); for(i=0; i<n; i++) { if(i%2==0) { string1[i]='C'; string2[i]='.'; } else if(i%2==1) { string1[i]='.'; string2[i]='C'; } } string1[n]='\0'; string2[n]='\0'; for(i=1; i<=n; i++) { if(i%2==1) printf("%s\n",string1); else if(i%2==0) printf("%s\n",string2); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
89e8cc3864437cb992a08d74c75fc984
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() {int n,res=0; char t[1000][1000]; scanf("%d",&n); for(int i=0;i<n;i++) { for (int j=0;j<n;j++) t[i][j]='.'; } int i=0,j=0,a=0; while (a<n) { while (i<n) { t[i][j]='C'; t[j][i]='C'; i++; j++; res+=2; } a+=2; i=a; j=0; } printf("%d\n",res-n); for(int i=0;i<n;i++) { for (int j=0;j<n;j++) printf("%c",t[i][j]); printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
546c6b93e56fd0008a1dd724d676c58f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> int main() { int n,i,j,x,y; scanf("%d",&n); if(n==1){ printf("1\nC"); } else if(n%2==0){ x=n/2; y=n*x; printf("%d\n",y); for(i=1;i<=n;i++){ if(i%2!=0){ for(j=1;j<=n;j++){ if((i+j)%2==0){ printf("C"); } else { printf("."); } } printf("\n"); } else { for(j=1;j<=n;j++){ if((i+j)%2==0){ printf("C"); } else { printf("."); } } printf("\n"); } } } else { x=n/2; y=(x+1)*(x+1)+(x*x); printf("%d\n",y); for(i=1;i<=n;i++){ if(i%2!=0){ for(j=1;j<=n;j++){ if((i+j)%2==0){ printf("C"); } else { printf("."); } } printf("\n"); } else { for(j=1;j<=n;j++){ if((i+j)%2==0){ printf("C"); } else { printf("."); } } printf("\n"); } } } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
803e3e4594257049b610b56d3f045790
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n,i,j,count=0,k=1,a,b; scanf("%d",&n); if(n%2==0) { printf("%d",n*(n/2)); printf("\n"); } else { a=((n/2)+1)*((n/2)+1); b=(n/2)*(n/2); printf("%d",a+b); printf("\n"); } for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(k%2!=0) { printf("C"); count++; if(count==n) { printf("\n"); break; } printf("."); count++; if(count==n) { printf("\n"); break; } } else { printf("."); count++; if(count==n) { printf("\n"); break; } printf("C"); count++; if(count==n) { printf("\n"); break; } } } k++; count=0; } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
92faea770e35d1b0653b0b4105171e30
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> #include <stdlib.h> int main() { int i=0,n,j=0; scanf("%d",&n); if(n%2==0) { printf("%d\n",n*n/2); } else { printf("%d\n",(n*n/2)+1); } while(i!=n) { if(j==i||(j%2==0&&i%2==0)||(j%2==1&&i%2==1)) { printf("C"); } else { printf("."); } ++j; if(j==n&&i!=n) { ++i; j=0; printf("\n"); } } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
30d6ad00e44eb5cdf00c2613e5fa486a
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> #include <stdlib.h> int main() { int i=0,n,j=0,c=0; scanf("%d",&n); if(n%2==0) { printf("%d\n",n*n/2); } else { printf("%d\n",(n*n/2)+1); } for(i=0;i<n;++i) { for(j=0;j<n;++j) { if(j==i||(j%2==0&&i%2==0)||(j%2==1&&i%2==1)) { printf("C"); } else { printf("."); } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
d922031fab688428f1b9ebb99f0cf8c3
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n,i,j,ans; scanf("%d",&n); ans = (n/2)*(n/2) + ((n+1)/2)*((n+1)/2) ; printf("%d\n",ans); for(j=0;j<n;j++) { for(i=0;i<n;i++) { if(j%2!=i%2) printf("."); else printf("C"); } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
30e8cc1db7e66b2e31893c025b87ad82
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n,i,j,t1,t2,ans; scanf("%d",&n); t1= n/2; t2= (n+1)/2; //ceil(n/2) ans= t1*t1 + t2*t2; printf("%d\n",ans); if(!(n&1)) { //n is not odd for(j=0;j<t1;j++) { for(i=0;i<t1;i++) printf("C."); printf("\n"); for(i=0;i<t1;i++) printf(".C"); printf("\n"); } } else { printf("C"); for(i=0;i<t1;i++) printf(".C"); printf("\n"); for(j=0;j<t1;j++) { printf("."); for(i=0;i<t1;i++) printf("C."); printf("\n"); printf("C"); for(i=0;i<t1;i++) printf(".C"); printf("\n"); } } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
eed1bce303c2b85e0364bb2066690ceb
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> void print(int n) { int i,j; for(i=1;i<=n;i++) { if(i%2==1) for(j=1;j<=n;j++) { if(j%2==1) printf("C"); else printf("."); } else for(j=1;j<=n;j++) { if(j%2==1) printf("."); else printf("C"); } printf("\n"); } } int main() { int n,i,j,a,b; scanf("%d",&n); if(n%2==0) { printf("%d\n",n*n/2); print(n); } else { a= (n+1)/2; b= (n-1)/2; printf("%d\n",a*a+b*b); print(n); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
3bf566f7de95ada3baa9706e47080d5c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> int main(){ int n = 0; scanf("%d", &n); printf("%d\n", (n * n + 1) / 2); int row = 0, col = 0; for(row = 0; row < n; row++){ for(col = 0; col < n; col++){ if((row + col)%2){ printf("."); } else{ printf("C"); } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
f2e914ad93d2734124914d87746a7764
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> int main() { int k,n,nb = 0; scanf("%d",&n); for(int i =0;i<n;i++) { k=0; if(i%2==0) { for(int j=0;j<n;j++) { if(k%2 == 0) { // printf("C"); k++; nb++; } else { // printf("."); k++; } } } else { for(int j=0;j<n;j++) { if(k%2 == 0) { // printf("."); k++; } else { // printf("C"); k++; nb++; } } } //printf("\n"); } printf("%d\n",nb); for(int i =0;i<n;i++) { k=0; if(i%2==0) { for(int j=0;j<n;j++) { if(k%2 == 0) { printf("C"); k++; nb++; } else { printf("."); k++; } } } else { for(int j=0;j<n;j++) { if(k%2 == 0) { printf("."); k++; } else { printf("C"); k++; nb++; } } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
6adec6aadb59b59f11452b07d2157c49
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main(){ int n,i,j,c; scanf("%d",&n); if(n%2==0) c=n*n/2; else c=(n*n+1)/2; printf("%d\n",c); for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ if(i%2!=0){ if(j%2!=0) printf("C"); else printf("."); } else{ if(j%2!=0) printf("."); else printf("C"); } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
b554c28db0ec81a4a23d327e5af382ff
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n,p,r,s,i,j,k; scanf("%d",&n); if(n==1) { printf("1\nC"); } else if(n%2==0) { r=1; s=1; p=(n/2)-1; for(i=1;i<=p;i++) { r=r+2; s=s+r; } printf("%d\n", s+s); for(j=1;j<=n;j++) { if(j==1 || j%2!=0) { for(k=1;k<=(n/2);k++) { printf("C."); } printf("\n"); } else { for(k=1;k<=(n/2);k++) { printf(".C"); } printf("\n"); } } } else { r=1; s=1; p=((n-1)/2)-1; for(i=1;i<=p;i++) { r=r+2; s=s+r; } printf("%d\n", n+s+s); for(j=1;j<=n;j++) { if(j==1 || j%2!=0) { for(k=1;k<=(n-1)/2;k++) { printf("C."); } printf("C\n"); } else { for(k=1;k<=(n-1)/2;k++) { printf(".C"); } printf(".\n"); } } } }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
25519dac395300d59065ad9ced3244be
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main(){ int i, j, n, num ; char a[1004], b[1004]; scanf("%d", &n); num = n*n; if(num%2==1) printf("%d\n", num/2+1); else printf("%d\n", num/2); for( i=0 ; i<1004 ; i+=2 ){ a[i] = b[i+1] = 'C'; a[i+1] = b[i] = '.'; } for( i=0 ; i<n ; i++ ){ for( j=0 ; j<n ; j++ ) printf("%c", a[j]); printf("\n"); i++; if(i==n) break; for( j=0 ; j<n ; j++ ) printf("%c", b[j]); printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
5b7dac6a409a10e53456319164f79972
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> char a[10000][10000]; int main() { int i,j,n,f=0; scanf("%d",&n); if(n==2) { a[1][0]='.'; a[0][1]='.'; a[1][1]='C'; a[0][0]='C'; a[0][2]='\0'; a[1][2]='\0'; printf("2\n"); for(i=0;i<2;i++) printf("%s\n",a[i]); goto x; } else { for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i][j]!='C'&&a[i+1][j]!='C'&&a[i][j+1]!='C'&&a[i-1][j]!='C'&&a[i][j-1]!='C') { a[i][j]='C'; f++; } else a[i][j]='.'; } a[i][n]='\0'; } } printf("%d\n",f); for(i=0;i<n;i++) printf("%s\n",a[i]); x: return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
683b8d3e43d8cc38d3691b430ed82326
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n,x,i,j,c; scanf("%d",&n); j=n*n; j++; j=j/2; printf("%d\n",j); for(i=0;i<n;i++) { for(j=0;j<n;j++) { if((i%2==0 && j%2==0) || (i%2==1 && j%2==1)) { printf("C"); } else printf("."); } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
930c95f60b2c9e060810da2a03055a14
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> #include<string.h> int main(){ int i,j,x; scanf("%d",&x); if(x&1) printf("%d\n",x*x/2+1); else printf("%d\n",x*x/2); for(i=0;i<x;i++) { for(j=0;j<x;j++) { if(i&1) { if(j&1) printf("C"); else printf("."); } else { if(j&1) printf("."); else printf("C"); } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
f850cdcfbadc8143677b482b40a4969f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> int main(void) { int n, ans, i, j, c[2] = {'C', '.'}; scanf("%d", &n); if ((n & 1) == 0) { ans = n * n/2; } else { ans = (n * n + 1) / 2; } printf("%d\n", ans); for (i = 0; i < n; ++i) { int x = i & 1, s = c[x]; for (j = 0; j < n; ++j) { putchar(s); x = 1-x; s = c[x]; } putchar('\n'); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
0d1c5ac23ad4b90cf5aad5dc38fb1d83
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> #include <stdlib.h> int main() { int n,i,j,count=1,f=2; char b[1000],c[1000]; scanf("%d",&n); b[0]='C'; c[1]='C'; for(i=1;i<n;i++) { if(b[i+1]!='C' && b[i-1]!='C'){b[i]='C';count++;} if(c[f+1]!='C' && c[f-1]!='C'){c[f]='C';} f++; } if(n==2){printf("2\n");} else if(n==1){printf("1\n");} else if(n%2==0){ printf("%d\n",2*count*(n/2)); } else if(n%2!=0){ printf("%d\n",count*(n/2)+(count-1)*(n/2)+count);} for(i=0;i<n;i++){ for(j=0;j<n;j++) { if(i%2==0) { if(b[j]!='C'){printf(".");} else{printf("%c",b[j]);} } else { if(c[j]!='C'){printf(".");} else{printf("%c",c[j]);} } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
c90d9005fc8d69d6889df082693a5626
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { int n,i,j,nb=0; char chaine[1000][1000]; scanf("%d",&n); if(n%2==0) printf("%d\n",n*n/2); else printf("%d\n",(n*n/2)+1); for(i=0;i<n;i++) { for(j=0;j<n;j++) { if((i%2==0)&&(j%2==0)) { printf("C"); } else if ((i%2==0)&&(j%2==1)) printf("."); else if((i%2==1)&&(j%2==1)) { printf("C"); } else if((i%2==1)&&(j%2==0)) printf("."); } printf("\n"); } return (EXIT_SUCCESS); }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
86f3c84968e7c85858c6d3fae1e6a988
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> main() { int n,i,j,cnt=0; scanf("%d",&n); int ans=(n/2)*(n/2)+((n/2)+1)*((n/2)+1); if(n%2==0) printf("%d\n",(n*n)/2); else printf("%d\n",ans); for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(i%2!=0 && j%2!=0) printf("C"); else if(i%2!=0 && j%2==0) printf("."); else if(i%2==0 && j%2!=0) printf("."); else if(i%2==0 && j%2==0) printf("C"); } printf("\n"); } }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
be9ed93fbe398b1e82fa8578435b65bb
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
# include <stdio.h> main () { int n; int i, j; scanf("%d", &n); if (n%2 == 0) printf("%d\n", n*n/2); else printf("%d\n", n*n/2+1); for (i=0; i<n; i++){ for(j=0; j<n; j++) { if(i%2 == 0){ if (j%2 == 0) printf("C"); else printf("."); } else { if (j%2 == 1) printf("C"); else printf("."); } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
864bcb4b4099d83c159462ca30994446
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> #include<math.h> int main(){ int n,i; scanf("%d",&n); if(n%2==0) printf("%ld\n",(n*n)/2); else printf("%ld\n",((n*n)+1)/2); int j; for(i=1;i<=n;i++){ if(i%2!=0){ for(j=1;j<=n;j++){ if(j%2!=0) printf("C"); else printf("."); } printf("\n"); } else{ for(j=1;j<=n;j++){ if(j%2!=0) printf("."); else printf("C"); } printf("\n"); } } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
892d6d5bce2257ad3f0bb9a3ac6bbe9c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> int main() { int n; int i,j,tt,pp,qq; while(scanf("%d",&n)!=EOF) { if(n&1){qq = (n/2+1)*(n/2+1)+(n/2)*(n/2);} else qq= (n/2)*(n); printf("%d\n",qq); tt=0; for(i=0;i<n;i++) { tt++; pp=0; for(j=0;j<n;j++) { if(tt%2==1&&j==0)pp=1; if(pp%2==1){printf("C");} else printf("."); pp++; } puts(""); } } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
4a62625f3cdf87a9b9ac69fe9e98654f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> int main() { long int n,i,m; scanf("%ld",&n); char ara[10000]; if(n%2==0) printf("%d\n",n*n/2); else printf("%d\n",n*n/2+1); for(m=0;m<n;m++){ if(m%2==0){ for(i=0;i<n;i++){ if(i%2==1) { ara[i]='.'; } else { ara[i]='C'; } } printf("%s\n",ara); } else{ for(i=0;i<n;i++){ if(i%2==1) { ara[i]='C'; } else { ara[i]='.'; } } printf("%s\n",ara); } } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
c40669086be5f6ad2c7f23d43803730e
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n,count=0; scanf("%d",&n); int i,j; if(n%2==0) count=(n*n)/2; else count=((n*n)+1)/2; printf("%d\n",count); for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i%2==0) { if(j%2==0) printf("C"); else printf("."); } else { if(j%2==0) printf("."); else printf("C"); } } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
359812f7b11b23b7f945045684719ab7
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n, r, c; scanf("%d",&n); if( n%2 == 0 ) printf("%d\n",(n*n)/2); else printf("%d\n",( n*n + 1)/2); for ( r = 1; r <= n; r++) { for( c=1; c <= n; c++) { if ( (r+c)%2 == 0 ) printf("C"); else printf("."); } printf("\n"); } }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
c69e408e066e3f274790de04ab0b81c8
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main(){ int a,b,c,m,n,i,j,k; while(scanf("%d",&n)==1){ k=0; for(i=0;i<n;i++) for(j=0;j<n;j++) ((i+j)%2)?0:k++; printf("%d\n",k); for(i=0;i<n;i++){ for(j=0;j<n;j++)printf("%c",((i+j)%2)?'.':'C'); printf("\n"); } } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
d099d44e18f3d5c17eb14b534368f489
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> char a[1002][1002]; int main() { int b,i,j; long int c=0; scanf("%d",&b); if(b%2==0) { for(i=0;i<b;i++) { for(j=0;j<b;j++) { if((i+j)%2!=0) { a[i][j]='C'; } else { a[i][j]='.'; } } } } else if(b%2!=0) { for(i=0;i<b;i++) { for(j=0;j<b;j++) { if((i+j)%2==0) { a[i][j]='C'; } else { a[i][j]='.'; } } } } for(i=0;i<b;i++) { for(j=0;j<b;j++) { if(a[i][j]=='C') { c++; } } } printf("%ld\n",c); for(i=0;i<b;i++) { for(j=0;j<b;j++) { printf("%c",a[i][j]); } printf("\n"); } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
c7bc5d1245f4bc4165e270e8554f641f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include<stdio.h> int main() { int n,j,i; while(scanf("%d",&n)!=EOF) { if(n%2==0) printf("%d\n",n*n/2); else printf("%d\n",n*n/2+1); for(i=0;i<n;i++) { for(j=0;j<n;j++) { if((i+j)%2==0) { printf("C"); }else{ printf("."); } } printf("\n"); } } return 0; }
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.
C
1aede54b41d6fad3e74f24a6592198eb
03e1db27cad7a4e482388e1367c8cb4c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1390231800
["2"]
null
PASSED
800
standard input
1 second
The first line contains an integer n (1 ≀ n ≀ 1000).
["2\nC.\n.C"]
#include <stdio.h> #include<string.h> int main() { int n,ans,i,j; scanf("%d",&n); if ( n%2==0) { ans = (n*n); ans = ans/2; } if (n%2!=0) { ans = ((n*n)+1); ans = ans /2; } printf("%d\n",ans); for ( i=0;i<n;i++) {for (j=0;j<n;j++) { if ( (i+j)%2==0) { printf("C"); } else { printf("."); } } printf("\n"); } return 0; }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
6a7a740fc3f59c55d7ce67e98538d166
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include <stdio.h> int main() { int t,x,y,a,b,c,d,ans,ans1; scanf("%d",&t); while(t--){ scanf("%d%d%d%d",&a,&b,&x,&y); c=a-x; d=b-y; if(x<c) x=c-1; if(y<d) y=d-1; ans=a*y; ans1=b*x; printf("%d\n",(ans>ans1)?ans:ans1); } }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
5a7255d1c7ded8a9aedcdbd41a24559f
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include<stdio.h> #include<math.h> #define ll unsigned long long int ll main(){ ll a, b, x, y, t, max_area, i; ll arr[4]; scanf("%llu", &t); while(t--) { scanf("%llu %llu %llu %llu", &a, &b, &x, &y); max_area = a * y; arr[1] = (a-x -1)*b; arr[2] = a*(b-y-1); arr[3] = b*x; for(i = 1; i <= 3; i++) { if(arr[i] > max_area) max_area = arr[i]; } printf("%llu\n", max_area); } }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
0440052eeedb7b3e1766d4a24e1d77f1
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include <stdio.h> int main() { int t,x,y,a,b,c,d,ans,ans1; scanf("%d",&t); while(t--){ scanf("%d%d%d%d",&a,&b,&x,&y); c=a-x; d=b-y; if(x<c) x=c-1; if(y<d) y=d-1; ans=a*y; ans1=b*x; printf("%d\n",(ans>ans1)?ans:ans1); } }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
af2e0e2765f0aad37c197ea85098efc5
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include<stdio.h> int main() { int t,a,b,x,y,i,a1,a2,a3,a4,m1,m2,m; scanf("%d",&t); for(i=1;i<=t;i++) { scanf("%d%d%d%d",&a,&b,&x,&y); a1=(x)*b; a2=(y)*a; a3=(a-(x+1))*b; a4=(b-(y+1))*a; if(a1>a2) { m1=a1; } else { m1=a2; } if(a3>a4) { m2=a3; } else { m2=a4; } if(m1>m2) { m=m1; } else { m=m2; } printf("%d\n",m); } return 0; }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
008b7f9edebc0dcfb6c71ac71fc1e3d7
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int a, b, x, y, n; int new_a, new_b; scanf("%d\n", &n); while (n > 0){ scanf("%d %d %d %d", &a, &b, &x, &y); new_a = ((a - 1 - x) > x) ? (a - 1 - x) : x; new_b = ((b - 1 - y) > y) ? (b - 1 - y) : y; if (new_a * b > new_b * a) printf("%d\n", new_a * b); else printf("%d\n", new_b * a); n--; } }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
17450d7d0c6c0a9d3ae8906bfd26dc5a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include <stdio.h> int t, x1, x2, y1, y2, d, pix, i; int main() { scanf("%d", &t); for(i=1; i<=t; i++) { scanf("%d %d %d %d", &x1, &y1, &x2, &y2); d=x2; pix=d*y1; d=x1-x2-1; if(d*y1>pix) pix=d*y1; d=y2; if(d*x1>pix) pix=d*x1; d=y1-y2-1; if(d*x1>pix) pix=d*x1; printf("%d\n", pix); } return 0; }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
a116ef0b2f7cd593895cf417f3e98a34
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include<stdio.h> int max(int a, int b) { return a > b ? a : b; } int main(void) { int t; scanf("%d", &t); int a, b, x, y; int ans1, ans2; while (t--) { ans1 = 0; ans2 = 0; scanf("%d %d %d %d", &a, &b, &x, &y); x += 1; y += 1; ans1 = (y-1) * a; if ((b - y) * a > ans1) ans1 = (b - y) * a; ans2 = (x - 1) * b; if ((a - x) * b > ans2) ans2 = (a - x) * b; printf("%d\n",max(ans1, ans2)); } return 0; }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
ea86c63d7ad9070c11e832cf1064e32d
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include <stdio.h> unsigned get_max(unsigned a, unsigned b) { if (a > b) return a; else return b; } int main() { unsigned t, a, b, x, y, s1, s2, s; scanf("%u\n", &t); for (unsigned i = 0; i < t; i++) { scanf("%u %u %u %u\n", &a, &b, &x, &y); if ((x == 0)||(y == 0)||(x == a-1)||(y == b-1)) { if (((x == 0)&&(y == 0))||((x == a-1)&&(y == 0))||((x == 0)&&(y == b-1))||((x == a-1)&&(y == b-1))) s = get_max((a-1)*b, (b-1)*a); else { if ((x == 0)||(x == a-1)) s = get_max((a-1)*b, get_max(y*a, (b-y-1)*a)); if ((y == 0)||(y == b-1)) s = get_max((b-1)*a, get_max(x*b, (a-x-1)*b)); } printf("%u\n", s); } else { s = get_max(get_max(x*b, (a-x-1)*b), get_max(y*a, (b-y-1)*a)); printf("%u\n", s); } } return 0; }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
da7b2b40e1474909f4a4ed704481644c
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include <stdio.h> int main(){ int t; scanf("%d", &t); int cima=0, baixo=0, dir=0, esq=0; int a, b, x, y; for(int i =0; i<t; ++i){ scanf("%d %d %d %d", &x, &y, &a, &b); baixo=(y-1-b)*x; cima= b*x; //baixo= b*x; //cima=(y-1-b)*x; dir=(x-1-a)*y; esq= a*y ; /* printf("%d\n", baixo); printf("%d\n", cima); printf("%d\n", dir); printf("%d\n", esq); */ if ((cima >= baixo) && (cima >= dir) && (cima >= esq)) printf("%d\n", cima); else if ((baixo >= cima) && (baixo >= dir) && (baixo >= esq)) printf("%d\n", baixo); else if ((dir >= cima) && (dir >= baixo) && (dir >= esq)) printf("%d\n", dir); else if ((esq >= baixo) && (esq >= cima) && (esq >= dir)) printf("%d\n", esq); } return 0; }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
144374d8846e203d3659c401fd7fb8ad
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
//Problema 1315A do CodeForces #include <stdio.h> #include <stdlib.h> int main(){ int t; scanf("%d", &t); int a, b, x, y; int ac = 0, ab = 0, esq = 0, dir = 0; for (int i = 0; i < t; ++i){ scanf("%d %d %d %d", &a, &b, &x, &y); ac = x * b; ab = (a-x-1) * b; esq = a * y; dir = a * (b-y-1); /* acima = x * b abaixo = (a-x-1) * b Γ  esquerda = a * y Γ  direita = a * (b-y-1) */ if(ac >= ab && ac >= esq && ac >= dir) printf("%d\n", ac); else if (ab >= ac && ab >= esq && ab >= dir) printf("%d\n", ab); else if(esq >= ab && esq >= ab && esq >= dir) printf("%d\n", esq); else if(dir >= ab && dir >= ac && dir >= esq) printf("%d\n", dir); } return 0; }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
9d1f425e67b767b68e643bef8c4e090a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include<stdio.h> int main(){ int t,a[10000][4],j,i,m,n,k,p; scanf("%d",&t); for(i=0;i<t;i++){ for(j=0;j<4;j++){ scanf("%d",&a[i][j]); } printf("\n");} for(i=0;i<t;i++){ m=(a[i][0]-a[i][2]-1)*a[i][1]; n=a[i][0]*a[i][3]; k=a[i][1]*a[i][2]; p=a[i][0]*(a[i][1]-a[i][3]-1); if(m>=n&&m>=k&&m>=p){printf("%d\n",m);} else if(n>=m&&n>=k&&n>=p){printf("%d\n",n);} else if(k>=n&&k>=m&&k>=p){printf("%d\n",k);} else{printf("%d\n",p);} } return 0;}
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
d6554f9d3d4aabf40450ff79abf0e955
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include<stdio.h> int main() { int a,b,x,y,t,i,m,n; int s1,s2,s3,s4; scanf("%d",&t); while(t--) { scanf("%d %d %d %d",&a,&b,&x,&y); s1=a*y; s2=b*x; s3=a*(b-y-1); s4=b*(a-x-1); if(s1==s2) m=s1; if(s1>s2) m=s1; if(s1<s2) m=s2; if(s3==s4) n=s3; if(s3>s4) n=s3; if(s3<s4) n=s4; if(m>n) printf("%d\n",m); if(m<n) printf("%d\n",n); if(m==n) printf("%d\n",m); } return 0; }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
09751f50ed55b958f355f475c0fe2786
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include <stdio.h> int main() { int x,y,a,b; int n; scanf("%d", &n); int arr[n]; for(int i = 0; i < n; i++) { scanf("%d%d%d%d", &a, &b, &x, &y); int Smax1, Smax2; if(x > (a-x-1)) Smax1 = b*x; else Smax1 = (a-x-1)*b; if((b-y-1) > y) Smax2 = (b-y-1)*a; else Smax2 = a*y; if(Smax1 > Smax2) arr[i] = Smax1; else arr[i] = Smax2; } for(int i = 0; i < n; i++) printf("%d\n", arr[i]); }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
d01a5230c779ae9ace9f8c31f0fd15ca
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include<stdio.h> int main() { int t , a , b , x , y , m ; scanf("%d",&t); for(int i=0;i<t;i++) { scanf("%d%d%d%d",&a,&b,&x,&y); x=(x>(a-x-1))?x:(a-x-1) ; y=(y>(b-y-1))?y:(b-y-1) ; m= (x*b>y*a)?x*b:y*a ; printf("%d\n",m) ; } }
Screen resolution of Polycarp's monitor is $$$a \times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \le x &lt; a, 0 \le y &lt; b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rowsΒ β€” from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Print $$$t$$$ integersΒ β€” the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
C
ccb7b8c0c389ea771f666c236c1cba5f
8bf82375a9cf4db9ff3cd763d4da122e
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1582473900
["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"]
NoteIn the first test case, the screen resolution is $$$8 \times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
PASSED
800
standard input
1 second
In the first line you are given an integer $$$t$$$ ($$$1 \le t \le 10^4$$$)Β β€” the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \le a, b \le 10^4$$$; $$$0 \le x &lt; a$$$; $$$0 \le y &lt; b$$$)Β β€” the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b&gt;2$$$ (e.g. $$$a=b=1$$$ is impossible).
["56\n6\n442\n1\n45\n80"]
#include <stdio.h> int main() { int t,x,y,a,b,c,d,ans,ans1; scanf("%d",&t); while(t--){ scanf("%d%d%d%d",&a,&b,&x,&y); c=a-x; d=b-y; if(x<c) x=c-1; if(y<d) y=d-1; ans=a*y; ans1=b*x; printf("%d\n",(ans>ans1)?ans:ans1); } }
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≀ a ≀ n - 1, 0 ≀ b ≀ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
415cd50795e259372c7aa288ae12ea56
GNU C
standard output
256 megabytes
train_000.jsonl
[ "greedy", "constructive algorithms", "sortings", "data structures", "trees" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal β€” as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≀ degreei ≀ n - 1, 0 ≀ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include<stdio.h> #include<stdlib.h> struct node{ int d, x; }m[1000000], ans[1000000]; int n, k, one[1000000], q, none[1000000]; int main(){ scanf("%d", &n); int i; for(i = 0; i < n; i++){ scanf("%d%d", &m[i].d, &m[i].x); if(m[i].d == 1) one[k++] = i; } while(k){ int nk = 0; for(i = 0; i < k; i++){ int fr = one[i], to = m[fr].x; if(m[fr].d != 1) continue; ans[q].d = fr; ans[q++].x = to; // printf("(%d, %d)\n", fr, to); --m[fr].d; --m[to].d; m[to].x ^= fr; } for(i = 0; i < k; i++){ int fr = one[i], to = m[fr].x; if(m[to].d == 1) none[nk++] = to; } //printf("nk = %d\n", nk); for(i = 0; i < nk; i++) one[i] = none[i]; k = nk; } printf("%d\n", q); for(i = 0; i < q; i++) printf("%d %d\n", ans[i].d, ans[i].x); }
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≀ a ≀ n - 1, 0 ≀ b ≀ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
e8d5d6332e7a1060306d12ec6c4771f9
GNU C
standard output
256 megabytes
train_000.jsonl
[ "greedy", "constructive algorithms", "sortings", "data structures", "trees" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal β€” as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≀ degreei ≀ n - 1, 0 ≀ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include<stdio.h> #include<stdlib.h> typedef struct{ int number; int value; int xor; } node; //int comp(const void *p1,const void *p2); void RouteDetect(int pos); int count=0,*start,*goal; node *vertex; int main(void){ int n,i,j; scanf("%d",&n); vertex=(node *)calloc(n,sizeof(node)); start=(int *)calloc(n,sizeof(int)); goal=(int *)calloc(n,sizeof(int)); for(i=0;i<n;i++){ vertex[i].number=i; scanf("%d%d",&vertex[i].value,&vertex[i].xor); } //qsort(vertex,n,sizeof(node),comp); /*for(i=0;i<n;i++){ printf("%d %d %d\n",vertex[i].number,vertex[i].value,vertex[i].xor); }//*/ for(i=0;i<n;i++) if(vertex[i].value==1) RouteDetect(i); printf("%d\n",count); for(i=0;i<count;i++) printf("%d %d\n",start[i],goal[i]); free(vertex); free(start); free(goal); return 0; } /* int comp(const void *p1,const void *p2){ const node *n1,*n2; n1= (const node *)p1; n2= (const node *)p2; if(n1->value == n2->value) return n1->number-n2->number; else return n1->value-n2->value; }//*/ void RouteDetect(int pos){ int tmp; if(vertex[pos].value==1){ vertex[pos].value--; tmp=vertex[pos].xor; // printf("%d ^ %d = %d\n", vertex[pos].xor,vertex[pos].number,tmp); vertex[tmp].value--; vertex[tmp].xor^=vertex[pos].number; start[count]=pos; goal[count]=tmp; count++; RouteDetect(tmp); } }
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≀ a ≀ n - 1, 0 ≀ b ≀ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
9b572e1e00e8ab3f4e9bc6c303c06762
GNU C
standard output
256 megabytes
train_000.jsonl
[ "greedy", "constructive algorithms", "sortings", "data structures", "trees" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal β€” as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≀ degreei ≀ n - 1, 0 ≀ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include<stdio.h> int main() { int n,i,x[100000],y[100000],e=0,q[100000],s=0,a,b,c=0,count[100000][2]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d",&x[i],&y[i]); if(x[i]==1) { q[e]=i; e++; } } while(s!=e) { b=q[s]; if(x[b]==1) { a=y[b]; count[c][1]=a; count[c][0]=b; c++; x[a]--; y[a]=b^y[a]; if(x[a]==1) { q[e]=a; e++; } } s++; } printf("%d\n",c); for(i=0;i<c;i++) printf("%d %d\n",count[i][0],count[i][1]); return 0; }
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≀ a ≀ n - 1, 0 ≀ b ≀ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
c6fae4993f75ac954c9c66bfba4ac364
GNU C
standard output
256 megabytes
train_000.jsonl
[ "greedy", "constructive algorithms", "sortings", "data structures", "trees" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal β€” as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≀ degreei ≀ n - 1, 0 ≀ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include<stdio.h> int main() { int n,vertex[100000][2],ans[100000][2],cnt,i,single[100000],tot; scanf("%d",&n); cnt=0; for(i=0;i<n;i++) { scanf("%d %d",&vertex[i][0],&vertex[i][1]); if(vertex[i][0]==1)//at least one vertex will have degree 1, its a forest { single[cnt]=i; cnt++; } } tot=0; while(cnt>0) { if(vertex[single[cnt-1]][0]==1) {int index=single[cnt-1]; int neighbor_index=vertex[index][1];//since its the only neighbor ,degree is 1, hence XOR value = index of neighbor ans[tot][0]=single[cnt-1]; ans[tot][1]=vertex[single[cnt-1]][1]; tot++; cnt--; vertex[neighbor_index][0]--;//reduce degree of neighbor,since we have taken into account one of its neighbors vertex[neighbor_index][1]=vertex[neighbor_index][1]^index;//XOR prev XOR sum with this index to fetch you XOR sum due to other vertices if(vertex[neighbor_index][0]==1)//check if now neighbor also has degree 1 { single[cnt]=neighbor_index;//single[cnt] no longer holds i but the neighbor's index,rev dirn reading cnt++; } } else cnt--; } printf("%d\n",tot); for(i=0;i<tot;i++) printf("%d %d\n",ans[i][0],ans[i][1]); return 0; }
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≀ a ≀ n - 1, 0 ≀ b ≀ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
dc5ca70df89192872dd819d77da2a357
GNU C
standard output
256 megabytes
train_000.jsonl
[ "greedy", "constructive algorithms", "sortings", "data structures", "trees" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal β€” as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≀ degreei ≀ n - 1, 0 ≀ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include <stdio.h> int queue[1000000],top=0,bottom=0; struct d{ int sum,deg; } arr[100000]; int main(void) { int i,j,k,m,n,x,y,z,ans=0; scanf("%d",&n); for(i=0;i<n;++i){ scanf("%d %d",&arr[i].deg,&arr[i].sum); if(arr[i].deg==1) queue[bottom++]=i; ans+=arr[i].deg; } printf("%d\n",ans/2); while(top<bottom){ if(arr[queue[top]].deg!=1) {top++; continue;} printf("%d %d\n",queue[top],arr[queue[top]].sum); arr[arr[queue[top]].sum].sum=arr[arr[queue[top]].sum].sum ^ queue[top]; arr[arr[queue[top]].sum].deg--; if( arr[arr[queue[top]].sum].deg==1) queue[bottom++]=arr[queue[top]].sum; top++; } return 0; }
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≀ a ≀ n - 1, 0 ≀ b ≀ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
1cc9772f3cbe624b16a9385752b4f4c7
GNU C
standard output
256 megabytes
train_000.jsonl
[ "greedy", "constructive algorithms", "sortings", "data structures", "trees" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal β€” as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≀ degreei ≀ n - 1, 0 ≀ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include <stdio.h> #include <stdlib.h> typedef long long unsigned ll; struct noeud { ll d,s; }; int main() { ll n,i,k; scanf("%llu",&n); struct noeud t[n]; for(i=0;i<n;i++) { scanf("%llu%llu",&t[i].d,&t[i].s); } ll ans=0,L[n][2]; for (i=0;i<n;i++) { if (t[i].d==1) { k=i; while (t[k].d==1) {ans++; L[ans][0]=k; L[ans][1]=t[k].s; t[t[k].s].s^=k; t[t[k].s].d--; t[k].d--; k=t[k].s; } } } printf("%llu\n",ans); for(i=1;i<=ans;i++) printf("%llu %llu\n",L[i][0],L[i][1]); return 0; }
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.
In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≀ a ≀ n - 1, 0 ≀ b ≀ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.
C
14ad30e33bf8cad492e665b0a486008e
ed36af367a542caa8f6b000a6cb66a63
GNU C
standard output
256 megabytes
train_000.jsonl
[ "greedy", "constructive algorithms", "sortings", "data structures", "trees" ]
1421053200
["3\n2 3\n1 0\n1 0", "2\n1 1\n1 0"]
NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal β€” as "xor".
PASSED
1,500
standard input
1 second
The first line contains integer n (1 ≀ n ≀ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≀ degreei ≀ n - 1, 0 ≀ si &lt; 216), separated by a space.
["2\n1 0\n2 0", "1\n0 1"]
#include<stdio.h> #include<stdlib.h> struct vertex{ int deg; int xor; }; struct node{ int id; struct node *next; }; void pushint(int); struct node *end; int main(){ struct node *head; struct vertex *ar; int n,i,edges; head=(struct node *)malloc(sizeof(struct node)); head->next=NULL; end=head; scanf("%d",&n); ar=(struct vertex *)malloc(sizeof(struct vertex)*n); for(i=0,edges=0;i<n;i++){ scanf("%d %d",&ar[i].deg,&ar[i].xor); if(ar[i].deg==1){ pushint(i); } edges+=ar[i].deg; } edges>>=1; printf("%d\n",edges); while(edges>0){ i=head->next->id; if(ar[i].deg==0){ } else if(ar[i].deg==1){ printf("%d %d\n",i,ar[i].xor); ar[ar[i].xor].deg--; ar[ar[i].xor].xor^=i; edges--; if(ar[ar[i].xor].deg==1){ pushint(ar[i].xor); } } else{ printf("ERROR!\nDegree is %d\n",ar[i].deg); } head=head->next; } return 0; } void pushint(int i){ end->next=(struct node *)malloc(sizeof(struct node)); end=end->next; end->id=i; end->next=NULL; }
It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin.We can think Central Perk as coordinate plane. There are n bottles on the ground, the i-th bottle is located at position (xi, yi). Both Adil and Bera can carry only one bottle at once each. For both Adil and Bera the process looks as follows: Choose to stop or to continue to collect bottles. If the choice was to continue then choose some bottle and walk towards it. Pick this bottle and walk to the recycling bin. Go to step 1. Adil and Bera may move independently. They are allowed to pick bottles simultaneously, all bottles may be picked by any of the two, it's allowed that one of them stays still while the other one continues to pick bottles.They want to organize the process such that the total distance they walk (the sum of distance walked by Adil and distance walked by Bera) is minimum possible. Of course, at the end all bottles should lie in the recycling bin.
Print one real numberΒ β€” the minimum possible total distance Adil and Bera need to walk in order to put all bottles into recycling bin. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct if .
C
ae8687ed3cb5df080fb6ee79b040cef1
1e9672e32c4fd755f12601c6cce7f494
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "geometry", "greedy", "brute force" ]
1462984500
["3 1 1 2 0 0\n3\n1 1\n2 1\n2 3", "5 0 4 2 2 0\n5\n5 2\n3 0\n5 5\n3 5\n3 3"]
NoteConsider the first sample.Adil will use the following path: .Bera will use the following path: .Adil's path will be units long, while Bera's path will be units long.
PASSED
1,800
standard input
2 seconds
First line of the input contains six integers ax, ay, bx, by, tx and ty (0 ≀ ax, ay, bx, by, tx, ty ≀ 109)Β β€” initial positions of Adil, Bera and recycling bin respectively. The second line contains a single integer n (1 ≀ n ≀ 100 000)Β β€” the number of bottles on the ground. Then follow n lines, each of them contains two integers xi and yi (0 ≀ xi, yi ≀ 109)Β β€” position of the i-th bottle. It's guaranteed that positions of Adil, Bera, recycling bin and all bottles are distinct.
["11.084259940083", "33.121375178000"]
#include <stdio.h> #include <math.h> int ax,ay,bx,by,tx,ty; long double distt(long,long); long double dista(long,long); long double distb(long,long); long double max(long double, long double); main() { extern int ax,ay,bx,by,tx,ty; int i,x,y, ai, bi; long n, asave, bsave; scanf("%d %d %d %d %d %d",&ax,&ay,&bx,&by,&tx,&ty); long double total, tdist, asv, bsv, asvmax, bsvmax, asvmax2, bsvmax2, maxsave; total = 0; scanf("%ld", &n); /* 1st bottle */ scanf("%d %d",&x,&y); tdist = distt(x,y); total += tdist; asvmax = tdist - dista(x,y); ai = 0; bsvmax = tdist - distb(x,y); bi = 0; asvmax2 = -1000; bsvmax2 = -1000; /* the rest of the bottles */ for (i = 1; i < n; i++) { scanf("%d %d",&x,&y); tdist = distt(x,y); total += tdist; asv = tdist - dista(x,y); bsv = tdist - distb(x,y); if (asv>asvmax) { asvmax2 = asvmax; asvmax = asv; ai = i; } else if (asv>asvmax2) { asvmax2 = asv; } if (bsv>bsvmax) { bsvmax2 = bsvmax; bsvmax = bsv; bi = i; } else if (bsv>bsvmax2) { bsvmax2 = bsv; } } // end of for loop if (ai == bi) { maxsave = max(max(asvmax+bsvmax2, asvmax2+bsvmax),max(asvmax,bsvmax)); } else { maxsave = max(asvmax+bsvmax,max(asvmax,bsvmax)); } printf("%.15Lf\n",total*2 - maxsave); } long double dista(long x,long y) { return sqrt(pow(x-ax,2)+pow(y-ay,2)); } long double distb(long x,long y) { return sqrt(pow(x-bx,2)+pow(y-by,2)); } long double distt(long x,long y) { return sqrt(pow(x-tx,2)+pow(y-ty,2)); } long double max(long double a, long double b) { return a>b? a:b; }
It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin.We can think Central Perk as coordinate plane. There are n bottles on the ground, the i-th bottle is located at position (xi, yi). Both Adil and Bera can carry only one bottle at once each. For both Adil and Bera the process looks as follows: Choose to stop or to continue to collect bottles. If the choice was to continue then choose some bottle and walk towards it. Pick this bottle and walk to the recycling bin. Go to step 1. Adil and Bera may move independently. They are allowed to pick bottles simultaneously, all bottles may be picked by any of the two, it's allowed that one of them stays still while the other one continues to pick bottles.They want to organize the process such that the total distance they walk (the sum of distance walked by Adil and distance walked by Bera) is minimum possible. Of course, at the end all bottles should lie in the recycling bin.
Print one real numberΒ β€” the minimum possible total distance Adil and Bera need to walk in order to put all bottles into recycling bin. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct if .
C
ae8687ed3cb5df080fb6ee79b040cef1
138edc4ff19431a356f8bbc897b9a69f
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "geometry", "greedy", "brute force" ]
1462984500
["3 1 1 2 0 0\n3\n1 1\n2 1\n2 3", "5 0 4 2 2 0\n5\n5 2\n3 0\n5 5\n3 5\n3 3"]
NoteConsider the first sample.Adil will use the following path: .Bera will use the following path: .Adil's path will be units long, while Bera's path will be units long.
PASSED
1,800
standard input
2 seconds
First line of the input contains six integers ax, ay, bx, by, tx and ty (0 ≀ ax, ay, bx, by, tx, ty ≀ 109)Β β€” initial positions of Adil, Bera and recycling bin respectively. The second line contains a single integer n (1 ≀ n ≀ 100 000)Β β€” the number of bottles on the ground. Then follow n lines, each of them contains two integers xi and yi (0 ≀ xi, yi ≀ 109)Β β€” position of the i-th bottle. It's guaranteed that positions of Adil, Bera, recycling bin and all bottles are distinct.
["11.084259940083", "33.121375178000"]
#include <stdio.h> #include <math.h> #define N 100000 typedef long long ll; ll x[N], y[N]; double dist(ll x1, ll y1, ll x2, ll y2) { return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); } double min(double x, double y) { return x < y ? x : y; } int main(int argc, char* argv[]) { int i, n, aid, bid; ll ax, ay, bx, by, tx, ty; double total = 0, ans = 1e60; double ad1, ad2, bd1, bd2; scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &ax, &ay, &bx, &by, &tx, &ty); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%I64d%I64d", &x[i], &y[i]); total += 2 * dist(x[i], y[i], tx, ty); } ad1 = ad2 = 1e60; for (i = 0; i < n; i++) { double diff = dist(x[i], y[i], ax, ay) - dist(x[i], y[i], tx, ty); double local_ans = total + diff; ans = min(ans, local_ans); if (diff < ad1) { aid = i; ad2 = ad1; ad1 = diff; } else if (diff < ad2) ad2 = diff; } bd1 = bd2 = 1e60; for (i = 0; i < n; i++) { double diff = dist(x[i], y[i], bx, by) - dist(x[i], y[i], tx, ty); double local_ans = total + diff; ans = min(ans, local_ans); if (diff < bd1) { bid = i; bd2 = bd1; bd1 = diff; } else if (diff < bd2) bd2 = diff; } if (aid == bid) { ans = min(ans, total + ad1 + bd2); ans = min(ans, total + ad2 + bd1); } else ans = min(ans, total + ad1 + bd1); printf("%.12f\n", ans); return 0; }
Acacius is studying strings theory. Today he came with the following problem.You are given a string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once?Each question mark should be replaced with exactly one lowercase English letter. For example, string "a?b?c" can be transformed into strings "aabbc" and "azbzc", but can't be transformed into strings "aabc", "a?bbc" and "babbc".Occurrence of a string $$$t$$$ of length $$$m$$$ in the string $$$s$$$ of length $$$n$$$ as a substring is a index $$$i$$$ ($$$1 \leq i \leq n - m + 1$$$) such that string $$$s[i..i+m-1]$$$ consisting of $$$m$$$ consecutive symbols of $$$s$$$ starting from $$$i$$$-th equals to string $$$t$$$. For example string "ababa" has two occurrences of a string "aba" as a substring with $$$i = 1$$$ and $$$i = 3$$$, but there are no occurrences of a string "aba" in the string "acba" as a substring.Please help Acacius to check if it is possible to replace all question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once.
For each test case output an answer for it. In case if there is no way to replace question marks in string $$$s$$$ with a lowercase English letters in such a way that there is exactly one occurrence of a string "abacaba" in the resulting string as a substring output "No". Otherwise output "Yes" and in the next line output a resulting string consisting of $$$n$$$ lowercase English letters. If there are multiple possible strings, output any. You may print every letter in "Yes" and "No" in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answer).
C
f6b7ad10382135b293bd3f2f3257d4d3
ef263807094fd351abdcb47df3870a9d
GNU C11
standard output
512 megabytes
train_000.jsonl
[ "implementation", "brute force", "strings" ]
1595149200
["6\n7\nabacaba\n7\n???????\n11\naba?abacaba\n11\nabacaba?aba\n15\nasdf???f???qwer\n11\nabacabacaba"]
NoteIn first example there is exactly one occurrence of a string "abacaba" in the string "abacaba" as a substring.In second example seven question marks can be replaced with any seven lowercase English letters and with "abacaba" in particular.In sixth example there are two occurrences of a string "abacaba" as a substring.
PASSED
1,500
standard input
1 second
First line of input contains an integer $$$T$$$ ($$$1 \leq T \leq 5000$$$), number of test cases. $$$T$$$ pairs of lines with test case descriptions follow. The first line of a test case description contains a single integer $$$n$$$ ($$$7 \leq n \leq 50$$$), length of a string $$$s$$$. The second line of a test case description contains string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters and question marks.
["Yes\nabacaba\nYes\nabacaba\nYes\nabadabacaba\nYes\nabacabadaba\nNo\nNo"]
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { char s[51], c[8]={"abacaba"}; int n, i, t, h, j, p; scanf("%d", &t); while(t--) { scanf("%d %s", &n, s); int r=0, u=0, f=0; char a[51]={'\0'}; for(p=0; p<n-6; p++) { for(j=0; j<n; j++){ a[j]=s[j]; } for(h=0; h<7; h++) { if(s[p+h]!=c[h] && s[p+h]!='?') { r=1; break; } a[p+h]=c[h]; } if(r==0) { for(i=3; i<n-3; i++) { if(a[i]=='c') { if(a[i-1]=='a' && a[i+1]=='a' && a[i-2]=='b' && a[i+2]=='b' && a[i-3]=='a' && a[i+3]=='a') { u++; } } } } else{ r=0; } if(u==1) { for(i=0; i<n; i++) { if(a[i]=='?'){ a[i]='s'; } } printf("YES\n%s\n", a); f=1; break; } else{ u=0; } } if(f==0){ printf("NO\n"); } } return 0; }
Acacius is studying strings theory. Today he came with the following problem.You are given a string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once?Each question mark should be replaced with exactly one lowercase English letter. For example, string "a?b?c" can be transformed into strings "aabbc" and "azbzc", but can't be transformed into strings "aabc", "a?bbc" and "babbc".Occurrence of a string $$$t$$$ of length $$$m$$$ in the string $$$s$$$ of length $$$n$$$ as a substring is a index $$$i$$$ ($$$1 \leq i \leq n - m + 1$$$) such that string $$$s[i..i+m-1]$$$ consisting of $$$m$$$ consecutive symbols of $$$s$$$ starting from $$$i$$$-th equals to string $$$t$$$. For example string "ababa" has two occurrences of a string "aba" as a substring with $$$i = 1$$$ and $$$i = 3$$$, but there are no occurrences of a string "aba" in the string "acba" as a substring.Please help Acacius to check if it is possible to replace all question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once.
For each test case output an answer for it. In case if there is no way to replace question marks in string $$$s$$$ with a lowercase English letters in such a way that there is exactly one occurrence of a string "abacaba" in the resulting string as a substring output "No". Otherwise output "Yes" and in the next line output a resulting string consisting of $$$n$$$ lowercase English letters. If there are multiple possible strings, output any. You may print every letter in "Yes" and "No" in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answer).
C
f6b7ad10382135b293bd3f2f3257d4d3
3d8fae20de46c21b3a2b2bb266b7e2fe
GNU C11
standard output
512 megabytes
train_000.jsonl
[ "implementation", "brute force", "strings" ]
1595149200
["6\n7\nabacaba\n7\n???????\n11\naba?abacaba\n11\nabacaba?aba\n15\nasdf???f???qwer\n11\nabacabacaba"]
NoteIn first example there is exactly one occurrence of a string "abacaba" in the string "abacaba" as a substring.In second example seven question marks can be replaced with any seven lowercase English letters and with "abacaba" in particular.In sixth example there are two occurrences of a string "abacaba" as a substring.
PASSED
1,500
standard input
1 second
First line of input contains an integer $$$T$$$ ($$$1 \leq T \leq 5000$$$), number of test cases. $$$T$$$ pairs of lines with test case descriptions follow. The first line of a test case description contains a single integer $$$n$$$ ($$$7 \leq n \leq 50$$$), length of a string $$$s$$$. The second line of a test case description contains string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters and question marks.
["Yes\nabacaba\nYes\nabacaba\nYes\nabadabacaba\nYes\nabacabadaba\nNo\nNo"]
#include <stdio.h> #include <stdlib.h> #include <string.h> char *target = "abacaba"; const int target_len = 7; int string_match(char *a, char *b) { int match = 1; for (; *b != '\0'; a++, b++) { if (*a != *b) { match = 0; break; } } return match; } int main(void) { int t; scanf("%d", &t); for (; t > 0; t--) { int n; scanf("%d", &n); char *s = malloc((n + 1) * sizeof(*s)); scanf("%s", s); char *tmp = malloc((n + 1) * sizeof(*tmp)); int success = 0; // brute force for (int i = 0; i < n; i++) { char c = s[i]; if (c == 'a' || c == '?') { strcpy(tmp, s); int target_exists = 1; // set ? before c to d // try to finish abacaba // after abacaba, set all ? to d for (int j = 0; j < n; j++) { if ((j < i || j >= i + target_len)) { if (tmp[j] == '?') { tmp[j] = 'd'; } } else { if (tmp[j] == '?') { tmp[j] = target[j - i]; } if (tmp[j] != target[j - i]) { target_exists = 0; break; } } } // if unable to create abacaba starting at i, look for another answer if (!target_exists) { continue; } // count abacaba instances int count_match = 0; for (int j = 0; j < n; j++) { if (tmp[j] == 'a') { if (string_match(&tmp[j], target)) { count_match++; } } } // if multiple exists, continue looking for an answer if (count_match > 1 || count_match == 0) { continue; } // answer found success = 1; break; } } if (success) { printf("Yes\n%s\n", tmp); } else { printf("No\n"); } free(s); free(tmp); } return 0; }
Acacius is studying strings theory. Today he came with the following problem.You are given a string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once?Each question mark should be replaced with exactly one lowercase English letter. For example, string "a?b?c" can be transformed into strings "aabbc" and "azbzc", but can't be transformed into strings "aabc", "a?bbc" and "babbc".Occurrence of a string $$$t$$$ of length $$$m$$$ in the string $$$s$$$ of length $$$n$$$ as a substring is a index $$$i$$$ ($$$1 \leq i \leq n - m + 1$$$) such that string $$$s[i..i+m-1]$$$ consisting of $$$m$$$ consecutive symbols of $$$s$$$ starting from $$$i$$$-th equals to string $$$t$$$. For example string "ababa" has two occurrences of a string "aba" as a substring with $$$i = 1$$$ and $$$i = 3$$$, but there are no occurrences of a string "aba" in the string "acba" as a substring.Please help Acacius to check if it is possible to replace all question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once.
For each test case output an answer for it. In case if there is no way to replace question marks in string $$$s$$$ with a lowercase English letters in such a way that there is exactly one occurrence of a string "abacaba" in the resulting string as a substring output "No". Otherwise output "Yes" and in the next line output a resulting string consisting of $$$n$$$ lowercase English letters. If there are multiple possible strings, output any. You may print every letter in "Yes" and "No" in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answer).
C
f6b7ad10382135b293bd3f2f3257d4d3
e1bb68ceb53d5a686c14227e49b74659
GNU C11
standard output
512 megabytes
train_000.jsonl
[ "implementation", "brute force", "strings" ]
1595149200
["6\n7\nabacaba\n7\n???????\n11\naba?abacaba\n11\nabacaba?aba\n15\nasdf???f???qwer\n11\nabacabacaba"]
NoteIn first example there is exactly one occurrence of a string "abacaba" in the string "abacaba" as a substring.In second example seven question marks can be replaced with any seven lowercase English letters and with "abacaba" in particular.In sixth example there are two occurrences of a string "abacaba" as a substring.
PASSED
1,500
standard input
1 second
First line of input contains an integer $$$T$$$ ($$$1 \leq T \leq 5000$$$), number of test cases. $$$T$$$ pairs of lines with test case descriptions follow. The first line of a test case description contains a single integer $$$n$$$ ($$$7 \leq n \leq 50$$$), length of a string $$$s$$$. The second line of a test case description contains string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters and question marks.
["Yes\nabacaba\nYes\nabacaba\nYes\nabadabacaba\nYes\nabacabadaba\nNo\nNo"]
#include <stdio.h> #include <string.h> int final(char s[], int n){ int cnt1=0, cnt2=0, q=0; for(int i=0; i<n-6;i++ ){ if((s[i]=='a'||s[i]=='?')&&(s[i+1]=='b'||s[i+1]=='?')&&(s[i+2]=='a'||s[i+2]=='?')&&(s[i+3]=='c'||s[i+3]=='?')&&(s[i+4]=='a'||s[i+4]=='?')&&(s[i+5]=='b'||s[i+5]=='?')&&(s[i+6]=='a'||s[i+6]=='?')){ cnt2++; // printf("%d\n", 0); } if(s[i]=='a'&&s[i+1]=='b'&&s[i+2]=='a'&&s[i+3]=='c'&&s[i+4]=='a'&&s[i+5]=='b'&&s[i+6]=='a'){ cnt1++; } } cnt2=cnt2-cnt1; if(cnt1==1){ return 20; } else if(cnt1>1){ return 0; } else if(cnt2>=1){ char h[n+1]; for(int e=0; s[e]!='\0'; e++){ h[e] = s[e]; // printf("%d\n", 0); } h[n] = '\0'; for(int i=0; i<n-6;i++ ){ if((s[i]=='a'||s[i]=='?')&&(s[i+1]=='b'||s[i+1]=='?')&&(s[i+2]=='a'||s[i+2]=='?')&&(s[i+3]=='c'||s[i+3]=='?')&&(s[i+4]=='a'||s[i+4]=='?')&&(s[i+5]=='b'||s[i+5]=='?')&&(s[i+6]=='a'||s[i+6]=='?')){ s[i]='a'; s[i+1]='b'; s[i+2]='a'; s[i+3]='c'; s[i+4]='a'; s[i+5]='b'; s[i+6]='a'; // printf("%s\n", s); } q=0; for(int x=0; x<n-6; x++){ if(s[x]=='a'&&s[x+1]=='b'&&s[x+2]=='a'&&s[x+3]=='c'&&s[x+4]=='a'&&s[x+5]=='b'&&s[x+6]=='a'){ q++; } } if(q==1){ return 20; // printf("%d\n", 0); } else{ for(int e=0; s[e]!='\0'; e++){ s[e] = h[e]; } // if(i==(n-7)){ // return 0; // } // printf("%d\n", 0); continue; } } } return 0; } int main(){ int t; scanf("%d", &t); for(int i=0; i<t; i++){ int n; scanf("%d", &n); char s[n+1]; scanf("%s", &s); if((final(s, n))==20){ printf("Yes\n"); for(int j=0; s[j]!='\0'; j++){ if(s[j]== '?'){ s[j]='x'; } } printf("%s\n", s); } else if((final(s, n))==0){ printf("No\n"); } } return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
c4040e98eb3c90b9bd9a157813815a8a
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #define sort radix_sort(a,n) int min(int p,int q) { if(p>q) return q; else return p; } int max(int p,int q) { if(p>q) return p; else return q; } typedef long long int ll; //n=inp(); void radix_sort(int a[], int n) { int i, x[n+1], m = 0, exp = 1; for (i = 1; i <= n; i++) if (a[i] > m) m = a[i]; while (m / exp > 0) { int box[10] = {0,0,0,0,0,0,0,0,0,0}; for (i = 0; i < n; i++) box[a[i] / exp % 10]++; for (i = 1; i < 10; i++) box[i] += box[i - 1]; for (i = n-1; i >= 0; i--) { x[--box[a[i] / exp % 10]] = a[i]; } for (i = 0; i < n; i++) { a[i] = x[i]; } exp *= 10; } } int a[105][105]; int fun(n,m) { int cnt=0,i,j; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(a[i][j]==a[n-i+1][j]) { cnt++; } } } if(cnt == (n*m)) { return 1; } else return 0; } //sort; int main() { int t,n,i,m,j,k; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",&a[i][j]);int w=0,x; x=n; while(x!=0) { x=x/2; w++; } // printf("w%d",w); while(n%2==0) { t=fun(n,m); if(t==1) n=n/2; else break; } printf("%d",n); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
ebbe82c294a2247d6c368272941ccbd1
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> typedef int bool; #define FALSE 0 #define TRUE 1 int a[100][100]; void readMatrix(int n, int m, int a[][100]) { int i, j; for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &a[i][j]); } void writeMatrix(int n, int m, int a[][100]) { int i, j; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) printf("%d\t", a[i][j]); printf("\n"); } } bool halvable(int a[][100], int n, int m) { bool symmetric = n % 2 == 0; if (symmetric) { int i; for (i = 0; i < n / 2; i++) { int j = n - i - 1; if (!sameRow(a[i], a[j], m)) symmetric = FALSE; } } return symmetric; } int rough(int a[][100], int n, int m) { int n_; for (n_ = n; halvable(a, n_, m); n_ /= 2); return n_; } bool sameRow(int a[], int b[], int m) { bool same = TRUE; int i; for (i = 0; i < m; i++) if (a[i] != b[i]) same = FALSE; return same; } int main(void) { int n, m; scanf("%d %d\n", &n, &m); readMatrix(n, m, a); // writeMatrix(n, m, a); int res = rough(a, n, m); printf("%d\n", res); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
7c793c97630d1b95a5c6bedec57837aa
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> #include <stdlib.h> int main () { int n, m, flag; scanf ("%i\n", &n); scanf ("%i\n", &m); int i, j; int *a = malloc (n * m * sizeof (int)); for (i = 0; i < n; ++i) for (j = 0; j < m; ++j) scanf("%i", a + i * m + j); while (n > 1) { flag = 1; if (n&1 == 1) break; for (i = 0; i < n/2; ++i) for (j = 0; j < m; ++j) if (a [i * m + j] != a[(n - i - 1) * m + j]) { flag = 0; break; } if (!flag) break; else n = n/2; } printf ("%i\n", n); free (a); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
ed1ae4fb486b560a07f36abbc40c7543
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> int judge(int b[],int c[],int m) { int i,ans=1; i=1; while(i<=m) { if(b[i]!=c[i]) { ans=0; break; } i++; } return ans; } int main(void) { int n,m,a[105][105],i,j,ans; scanf("%d %d",&n,&m); for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",&a[i][j]); if(n%2!=0) ans=n; else { for(ans=n;n%2==0;n/=2) { for(j=n,i=1;i<=n/2;i++,j--) if(!judge(a[i],a[j],m)) break; if(i<=n/2) break; else ans=n/2; } } printf("%d\n",ans); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
f1d3390568c34ded90890cd7eebe1beb
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> int a[200][200]; int cmp(int n,int m) { int i,j,k; if(n%2==1) return n; for(i=0;i<=n/2-1;i++) { for(j=0;j<m;j++) { if(a[i][j]!=a[n-1-i][j]) return n; } } cmp(n/2,m); } main() { int n,m,i,j; scanf("%d %d",&n,&m); for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&a[i][j]); printf("%d\n",cmp(n,m)); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
517a5007086ae55099be0234ba58b8e6
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> int get_min(int a[100][100] , int n , int m){ if(n % 2 == 1) return n; if(n == 1) return 1; int i,j,min = 0; for(i=0;i<n/2 ; i++){ for(j=0;j<m;j++){ if(a[i][j] != a[n-i-1][j]) return n; } } return get_min(a,n/2,m); } int main(){ int n,m,min,i,j; scanf("%d %d",&n,&m); int a[100][100]; for(i=0;i<n;i++){ for(j=0;j<m;j++){ scanf("%d",&a[i][j]); } } min = get_min(a,n,m); printf("%d\n",min); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
905515fc7281ab1fc130f3f8aecb813e
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> int m,a[101][101]={0}; int check(int x){ int j,i; for(i=1;i<=x/2;i++) for(j=1;j<=m;j++) if(a[i][j] != a[x-i+1][j]){ // printf("%d %d %d %d %d\n",i,x-i+1,j,a[i][j],a[x-i+1][j]); return 0; } return 1; } int main(){ int i,k,j,l,n,tmp; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",&a[i][j]); tmp = n; while(1) if(tmp%2==1) break; else if(check(tmp) == 1) tmp = tmp/2; else break; printf("%d\n",tmp); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
2df32780d91c898b85d9c161976b8b4e
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> char s[200][400]; int main() { int n,m,ans,i,flag=1; scanf("%d%d",&n,&m); getchar(); if(n%2==0) { for(i=0; i<n/2; i++) { scanf("%[^\n]s",s[i]); getchar(); } for(; i<n; i++) { scanf("%[^\n]s",s[i]); getchar(); if(strcmp(s[i],s[n-i-1])) { flag=0; break; } } for(i++; i<n; i++) { scanf("%[^\n]s",s[0]); getchar(); } if(flag) { ans=n; n/=2; while(n%2==0&&flag) { for(i=0; i<n/2; i++) if(strcmp(s[i],s[n-i-1])) { flag=0; break; } if(flag) ans=n; n/=2; } printf("%d\n",ans/2); } else { printf("%d\n",n); } } else printf("%d\n",n); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
1ae53b7161eac60002a144dfabd43e52
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> #include <stdlib.h> #define MAX 100 int mat[MAX][MAX]; int mirror(int mat[MAX][MAX],int n,int m){ if(n==1){ return 1; } if(n%2==0){ for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(!(mat[i][j]==mat[n-i-1][j])){ return n; } } } return mirror(mat,n/2,m); }else return n; } int main(){ int n,m; scanf("%d %d",&n,&m); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&mat[i][j]); } } int num=mirror(mat,n,m); printf("%d\n",num); }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
435c19a70381656434a76daf1e81364a
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> #include<stdlib.h> #include<stdbool.h> int main() { int n,m,i,j,k; bool **mat; int f,size; scanf("%d %d",&n,&m); mat=(bool**)malloc(sizeof(bool*)*n); for(i=0;i<n;i++) { mat[i]=(bool*)malloc(sizeof(bool)*m); } for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",&mat[i][j]); } } i=0; f=0; size=n; while(!f) { k=n-1; if( (k-i) %2 ==0) { f=1; } while(i<k && !f) { for(j=0;j<m;j++) { if(mat[i][j]==mat[k][j]) continue; else break; } if(j==m) { i++;k--; } else f=1; } if(!f) size=size/2; } printf("%d\n",size); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
13cc1138ba7e02004e5200182629d6f5
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> int main() { int flag,mat[110][110],n,m,i,j,k; while(scanf("%d %d",&n,&m)!=EOF) { flag=1; for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&mat[i][j]); if(n%2) printf("%d\n",n); else { while(n%2!=1) {for(i=0;i<n/2;i++) for(j=0;j<m;j++) if(mat[i][j]!=mat[n-1-i][j]) {flag=0;goto loop;} loop: if(flag==0) break; else n=n/2; } printf("%d\n",n); } } return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
8ba5570fbbdd73144f0719112a2eb64e
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> int a[106][108]; int main() { int x,y,j,i,f,c; scanf("%d %d",&x,&y); for(i=0;i<x;i++) { for(j=0;j<y;j++) scanf("%d",&a[i][j]); } c=x; f=1; while(f==1) { if(c%2==1) break; for(i=0;i<c/2;i++) { for(j=0;j<y;j++) { if(a[i][j]!=a[c-1-i][j]) f=0; } } for(i=0;i<c/2;i++) { for(j=0;j<y;j++) { a[i][j]=a[i][j]+a[c-i-1][j]; if(a[i][j]==0 || a[i][j]==2 || a[i][j]==4 || a[i][j]==8 || a[i][j]==16 || a[i][j]==32 || a[i][j]==64 || a[i][j]==128 || a[i][j]==256); else f=0; } } if(f==0) break; c=c/2; } printf("%d",c); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
0645e407e7fe3e88384967c60398a369
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> #define N 101 int arr[N][N] = {0}; void Swap(int *x, int *y) { int tmp; tmp = *x; *x = *y; *y = tmp; } int IsSymetric(int n, int m) { int i, j; int i1; if (n % 2 != 0) return 0; i1 = n - 1; for (i = 0; i < n/2; ++i, --i1) { for (j = 0; j < m; ++j) { if (arr[i][j] != arr[i1][j]) return 0; } } return 1; } int main(void) { int i, j; int n, m; int tmp; scanf("%i %i", &n, &m); for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) { scanf("%i", &tmp); arr[i][j] = tmp; } } while (IsSymetric(n, m)) { n /= 2; } printf("%i\n", n); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
ab915e20c733fd4f28cb3cc9838c05e9
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> #include<math.h> int main() { int n,m,i,j,k; scanf("%d%d",&n,&m); int sum[n]; for(i=0;i<n;i++) sum[i]=0; if(n%2==1) { printf("%d",n); return 0; } int arr[n][m]; for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",&arr[i][j]); sum[i]+=pow(2,m-j-1)*arr[i][j]; } } for(k=1;k<=n/2;k*=2) { for(i=0;i<n/k;i++) { if(sum[i]!=sum[n/k-1-i]) {printf("%d\n",(n/k)); return 0; } } } while(n%2==0) n/=2; printf("%d",n); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
84cb73388458740f01883d2b61c817f3
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> int main(void) { int a[100][100]; int i,j,n,m,flag=0,min,k; scanf("%d %d",&n,&m); for(i=0;i<n;i++) { for(j=0;j<m;j++) scanf("%d",&a[i][j]); } if(n%2!=0) printf("%d",n); else { min=n; i=n-1; while(i>0) { for(k=0;k<(1+i)/2;k++) { for(j=0;j<m;j++) { if(a[k][j]==a[i-k][j]) flag=1; else { flag=0; goto end_1; } } } end_1:; if(flag==1) { min=(i+1)/2; i=(i-1)/2; } if((i+1)%2!=0 ||flag ==0) { printf("%d",min); break; } flag=0; } } return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
637a12974d2a92e47a159a130ea568ac
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> #include<string.h> int jg(int n,char s[][205]) { int i,j; int flag=0; for(i=1,j=n;i<=n;i++,j--) { if(strcmp(s[i],s[j])!=0) { flag=1; } } if(flag==1) return 0; else return 1; } int main() { char s[105][205]; int i,flag; int n,m,t; while(scanf("%d%d",&n,&m)!=EOF) { memset(s,0,sizeof(s)); getchar(); flag=0; t=1; for(i=1;i<=n;i++) { gets(s[i]); } if(n%2==1) printf("%d\n",n); else { while(jg(n,s)==1) { n=n/2; if(n%2==1) break; } printf("%d\n",n); } } return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
a0f6eae19b3fd0107e64a4f8be7eb980
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> #include <string.h> #include <math.h> int main( void ) { int n, m; char mi[100][1100]; scanf("%i %i\n", &n, &m); int i, j; for( i = 0; i < n; i++ ) fgets(mi[i], 1000, stdin); if( (n%2) == 1 ) { printf("%i\n", n); return 0; } for( i = 1; i < n; i++ ) if( strcmp(mi[i], mi[0]) ) break; if( i == n ) { int k = 1; for( k = 1; k <= 10; k++ ) if( pow(2,k) == n ) { printf("1\n"); return 0; } } while( (n % 2) == 0 ) { for( i = 0, j = n-1; i < j; i++, j-- ) if( strcmp(mi[i], mi[j]) ) { printf("%i\n", n); return 0; } n /= 2; } printf("%i\n", n); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
d4d87f432314f8a5472aec2abd33ebde
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> int divideMat(int mat[200][200],int n,int m){ int i,j; int igual = 1; if(n%2 != 0) return n; for(i=0;i<n/2;i++){ for(j=0;j<m;j++){ if(mat[i][j] == mat[n-1-i][j] && igual) igual =1; else igual=0; } } if(igual)return divideMat(mat,n/2,m); else return n; } int main(){ int m,n; int i,j,min; int mat[200][200]; scanf("%d %d",&n,&m); for(i=0;i<n;i++){ for(j=0;j<m;j++) scanf("%d",&mat[i][j]); } min = divideMat(mat,n,m); printf("%d\n",min); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
9579969d9426760ac43b3406c25ee597
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> #define N 100 int main() { static int aa[N][N]; int n, m, i, j; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &aa[i][j]); while (n % 2 == 0) { int i1, i2, good; good = 1; for (i1 = n / 2 - 1, i2 = n / 2; i1 >= 0 && i2 < n; i1--, i2++) for (j = 0; j < m; j++) if (aa[i1][j] != aa[i2][j]) { good = 0; break; } if (!good) break; n /= 2; } printf("%d\n", n); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
2fae0c15bd7f4d3d949884108ce24f5a
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> #define N 100 int equal(int *aa, int *bb, int n) { int i; for (i = 0; i < n; i++) if (aa[i] != bb[i]) return 0; return 1; } int solve(int aa[][N], int n, int m) { int i, j; if (n % 2 == 1) return n; for (i = 0, j = n - 1; i < j; i++, j--) if (!equal(aa[i], aa[j], m)) return n; return solve(aa, n / 2, m); } int main() { static int aa[N][N]; int n, m, i, j; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &aa[i][j]); printf("%d\n", solve(aa, n, m)); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
60032e091ff13929c87e9b3d6cdc5dd7
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
main() { int n,m,i,j,k,p,f; scanf("%d%d",&n,&m); int a[n][m]; for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&a[i][j]); p=n; while(p%2==0){j=p-1; for(i=0;i<p/2;i++,j--) { f=1; for(k=0;k<m;k++) if(a[i][k]!=a[j][k]) {f=0;break;} if(!f) break; } if(!f) break; p/=2; } printf("%d",p); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
5f8dd09709e4662918562c90f6ca4cb9
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n, m, i, j, x, f; char a[101][101]; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { scanf("%d", &x); a[i][j] = x + '0'; } a[i][m] = 0; } while (1) { if (n%2 == 1) { printf("%d\n", n); return 0; } f = 1; for (i = 0; i < n/2; i++) if (strcmp(a[i], a[n-i-1]) != 0) f = 0; if (f == 0) { printf("%d\n", n); return 0; } n /= 2; } return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
8d8cac38927bb2e73dc7cd36a1d50e17
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> int mirror_check_and_return(int arr[][101],int n,int m) { int arr2[101][101]; int i,j; if(n%2==1) return n; for(i=0;i<n/2;i++) { for(j=0;j<m;j++) { arr2[i][j]=arr[i][j]; if(arr[i][j]!=arr[n-1-i][j]) return n; } } return mirror_check_and_return(arr2,n/2,m); } int main(void) { int i,j,n,m,arr[101][101]; scanf("%d%d",&n,&m); for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&arr[i][j]); printf("%d",mirror_check_and_return(arr,n,m)); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
b772e56d4962ff57067124728ed5df1f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> int main(){ int n,m,i,j,k,f=0,min,mitad; int v[100][100]; scanf("%d%d",&n,&m); min = n; for(i=0 ; i<n ;i++) for(j=0 ; j<m ; j++) scanf("%d",&v[i][j]); if(n%2!=0) printf("%d",min); else{ mitad = n; while( mitad%2==0 ){ mitad = mitad/2; for(i=0,k=2*mitad-1 ; i<mitad ; i++,k--) for(j=0 ; j<m ; j++) if( v[i][j]!=v[k][j] ) f=1; if( f==0 ) min = mitad; else break; } printf("%d",min); } return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
531cc6e178e7f7079fbe9ed1fa8b3c49
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> int mat[105][105]; int main(void) { int n, m; int i, j; int p; int mid; int sim; scanf(" %d %d", &n, &m); for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { scanf(" %d", &mat[i][j]); } } while(n % 2 == 0) { mid = n / 2; sim = 1; for (i = 0, p = n - 1; i < mid; i++, p--) { for (j = 0; j < m; j++) { if (mat[i][j] != mat[p][j]) { sim = 0; i = mid; break; } } } if (sim == 0) { break; } else { n = n / 2; } } printf("%d\n", n); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
33094c90f3e0f87169536a373e994ae1
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> int a[110][110],b[110],c[110]; int main(){ int n,m,ans,i,j,k,l,flag; while(scanf("%d %d",&n,&m)!=EOF){ for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&a[i][j]); if(n%2==1) ans=n; else{ for(k=n,ans=n,flag=1;k>1&&k%2==0;k=k/2){ for(i=0,j=k-1;i<k/2;i++,j--) for(l=0;l<m;l++){ b[l]=a[i][l]; c[l]=a[j][l]; if(b[l]!=c[l]) flag=0; } if(flag==1) ans=ans/2; } } printf("%d\n",ans); } return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
88e4681c71920d4bbabc0c2d5357c70b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <string.h> #include <ctype.h> int main() { int m,n,i,j; scanf("%d %d",&m,&n); char arr[100][1000]; getchar(); for(i=0;i<m;i++) { gets(arr[i]); } while(m%2==0) { int st=0,en=m-1; for(st=0;st<(m/2);st++) { if(strcmp(arr[st],arr[en])!=0) { printf("%d",m); return 0; } en--; } m=m/2; } printf("%d",m); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
51406a10634f5adde20a479d3fa2692c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #define N 102 int mx[N][N]; int n,m; int check(int pos){ int u = 0, v = pos-1; while(u < v){ for(int j = 0; j < m; j ++){ if(mx[u][j] != mx[v][j]) return 0; } u++; v--; } return 1; } int go(int pos){ if(pos%2 == 1) return pos; else{ if(check(pos)) return go(pos/2); else return pos; } } int main(){ scanf("%d %d",&n,&m); for(int i = 0; i < n; i ++){ for(int j = 0 ; j < m; j ++){ scanf("%d",&mx[i][j]); } } int res = go(n); printf("%d\n",res); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
c4ba4fb7a3ec6b6a5317fa53d9b35f34
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> int main(void) { int n,m,i,j,k,l,x,a[105][105],b[500],out,tmp,flag,flag1,flag2; scanf("%d %d",&n,&m); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%d",&a[i][j]); } } flag=0;out=n; while(1) { if(out%2==0) { for(i=1;i<=out/2;i++) { for(j=1;j<=m;j++) { if(a[i][j]!=a[out+1-i][j]) flag=1; } } if(flag==1) break; else out=out/2; } else break; } printf("%d\n",out); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
5476b68099b8259ba33321d6d6b55b81
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include<stdio.h> int a[100][100],b[100][100],c[100][100]; int main() { int n,m,i,j,line,temp=0; scanf("%d%d",&n,&m); for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&a[i][j]); line=n; while(!(line%2)) { for(i=0;i<line/2;i++) for(j=0;j<m;j++) if(a[i][j]!=a[line-1-i][j]) temp++; if(temp) break; else line/=2; temp =0; } printf("%d\n",line); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
9a8abfe0b34dc60bf28aac4a5e23d8c1
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
#include <stdio.h> #include <stdlib.h> #define MAX 120 int main() { int n,m,i,j,r,flag; int a[MAX][MAX]; scanf("%d%d",&n,&m); for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&a[i][j]); r=n; while(1) { if(r%2)break; r/=2; flag=0; for(i=0;i<r;i++) { for(j=0;j<m;j++) if(a[i][j]!=a[2*r-1-i][j]){ flag=1; break; } if(flag)break; } if(flag){ r*=2; break; } } printf("%d\n",r); return 0; }
Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?
In the single line, print the answer to the problem β€” the minimum number of rows of matrix b.
C
90125e9d42c6dcb0bf3b2b5e4d0f845e
efa24389fe25b3ace74f0168d3243ef2
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation" ]
1398612600
["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"]
NoteIn the first test sample the answer is a 2 × 3 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001
PASSED
1,300
standard input
1 second
The first line contains two integers, n and m (1 ≀ n, m ≀ 100). Each of the next n lines contains m integers β€” the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≀ aij ≀ 1) β€” the i-th row of the matrix a.
["2", "3", "2"]
// http://codeforces.com/problemset/problem/426/B #include <stdio.h> #include <stdlib.h> #include <stdbool.h> short n, m; // n -> rows & m -> columns short minRows; void cheak( unsigned long long arr[n][2] ) { short i; bool flag; if( minRows % 2 == 1 ) { return; } flag = 1; for( i = 0; i < minRows / 2; i++ ) { if( arr[i][0] != arr[ minRows - i - 1 ][0] || arr[i][1] != arr[ minRows - i - 1 ][1] ) { flag = 0; break; } } if( flag == 1 ) { minRows /= 2; cheak( arr ); } return; } int main( void ) { short i, j; short first, second; short temp; scanf( "%hi %hi", &n, &m ); if( n % 2 == 1 ) { printf( "%hi\n", n ); return 0; } unsigned long long arr[n][2]; if( m <= 64 ) { first = m; } else { first = 64; } second = m - 64; for( i = 0; i < n; i++ ) { arr[i][0] = 0; for( j = 0; j < first; j++ ) { scanf( "%hi", &temp ); if( temp == 1 ) { arr[i][0] |= ( 1 << j ); } } arr[i][1] = 0; for( j = 0; j < second; j++ ) { scanf( "%hi", &temp ); if( temp == 1 ) { arr[i][1] |= ( 1 << j ); } } } /*for( i = 0; i < n; i++ ) { printf( "%I64 %I64\n", arr[i][0], arr[i][1] ); }*/ minRows = n; cheak( arr ); printf( "%hi\n", minRows ); return 0; }