prob_desc_description
stringlengths
63
3.8k
prob_desc_output_spec
stringlengths
17
1.47k
lang_cluster
stringclasses
2 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
lang
stringclasses
7 values
prob_desc_output_to
stringclasses
3 values
prob_desc_memory_limit
stringclasses
19 values
file_name
stringclasses
111 values
tags
listlengths
0
11
prob_desc_created_at
stringlengths
10
10
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_notes
stringlengths
4
3k
exec_outcome
stringclasses
1 value
difficulty
int64
-1
3.5k
prob_desc_input_from
stringclasses
3 values
prob_desc_time_limit
stringclasses
27 values
prob_desc_input_spec
stringlengths
28
2.42k
prob_desc_sample_outputs
stringlengths
2
796
source_code
stringlengths
42
65.5k
hidden_unit_tests
stringclasses
1 value
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
e9105e42ea902ce8c71a978ffbf7dc60
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include <stdio.h> #define N 111 char s[N][N]; int rem[N], x[N]; int main() { int n, m, i, j, k; scanf("%d%d", &n, &m); for(i=0; i<n; i++) { scanf("%s", s[i]); } for(i=0; i<m; i++) { rem[i] = 1; } for(i=0; i<n; i++) { x[i] = 0; } for(j=0; j<m; j++) { for(i=0; i<n-1; i++) { if(s[i][j] > s[i+1]...
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
b97e7d64e7ad97b91035d9b44e034641
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include<stdio.h> #include<string.h> int main() { char x[1000][1001]; int row,col,i,j,k,ans=0; scanf("%d%d",&row,&col); for(i=0;i<row;i++) scanf("%s",&x[i]); for(i=1;i<row;i++) { if(strcmp(x[i-1],x[i])>0){ //Destroy column which is causing that. for(j=0;j<col;j++) if(x[i-1][j]>x[i][j]) break; ...
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
e8d8c181b100291c256d71539003165c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include <stdio.h> #include <stdlib.h> int main () { int n, m, i, j, k, count = 0; char **table; int *elim; scanf ("%d %d", &n, &m); table = malloc (n * sizeof (char*)); for (i = 0; i <= n; i++) table[i] = malloc (m * sizeof (char)); for (i = 0; i < n; i++) scanf ("%s", table[i]); if (n == 1) printf("0\n...
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
6c381bc9eb989ea5996689fa240ead79
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include <stdio.h> #include <stdlib.h> int main () { int n, m, i, j, k, count = 0; char **table; int *elim; scanf ("%d %d", &n, &m); table = malloc (n * sizeof (char*)); for (i = 0; i <= n; i++) table[i] = malloc (m * sizeof (char)); for (i = 0; i < n; i++) scanf ("%s", table[i]); if (n == 1) { printf("0...
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
81b1de1da79957428aa2e0f8509f9605
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include<stdio.h> typedef unsigned u; char M[1111][1111]; u A[1111],B[1111],*a,*b,*c,l; int main() { u x,y,z,i,j,k,r; scanf("%u%u",&x,&y); for(i=0;i<x;A[i]=B[i]=i)scanf("%s",M[i++]); for(a=A,b=B,l=x,j=r=0;j<y;++j) { for(i=k=0;++i<l;)if(a[i]) { if(M[a[i]][j]<M[a[i]-1][j])goto tj; if(M[a[i]][j]==M[a[i]-1][...
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
07b63858853c7ab96438f5baa2957d87
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include <stdio.h> #include <math.h> #include <stdlib.h> int main() { int a,b,c,d,e,f,i,j,k,p,q,sum=0,flag=0,ct1=-1,ct2=0; char x[110][110]; int y[110]; scanf("%d %d",&a,&b); for(i=0;i<a;i++) { scanf("%s",x[i]); } for(j=0;j<b;j++) { flag=0; ct2=0; for(i=1;...
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
6f7f6a9aecb354d8a84a0f61af142cec
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include <stdio.h> /* resubmit 1 */ int main() { int n, m; char table[100][100]; int skip[100]; int i, j; int min_rem; scanf("%d", &n); scanf("%d", &m); getchar(); for (i = 0; i < n; i++) { skip[i] = 0; for (j = 0; j < m; j++) { table[i][j] = getchar()...
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
166fb1952bb35d98f6aa74216afca59a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include <stdio.h> int main() { int n, m; char table[100][100]; int skip[100]; int i, j; int min_rem; scanf("%d", &n); scanf("%d", &m); getchar(); for (i = 0; i < n; i++) { skip[i] = 0; for (j = 0; j < m; j++) { table[i][j] = getchar(); } ...
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
C
a45cfc2855f82f162133930d9834a9f0
56c81143d535c2ce8eeebd198d31f132
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "implementation", "brute force" ]
1418833800
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
PASSED
1,500
standard input
2 seconds
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
["0", "2", "4"]
#include<stdio.h> #include<stdlib.h> #include<string.h> char temp[100][110],tab[100][110]; int n,m; int pos(int j) { int i; for(i=0;i<m;i++) { if(tab[j][i]<tab[j-1][i]) return i; } } void copy(int k) { int i,j,top=0; for(i=0;i<n;i++) { top=0; for(j=0;j<m;j++) { if(j!=k) temp[i][top++] = tab[...
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.The participants are offered m problems on the contest. For each friend, Gena knows what prob...
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
C
bc5b2d1413efcaddbf3bf1d905000159
6fe79b5ff6b49fab853e6d443b202012
GNU C
standard output
256 megabytes
train_001.jsonl
[ "dp", "sortings", "bitmasks" ]
1397749200
["2 2 1\n100 1 1\n2\n100 2 1\n1", "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2", "1 2 1\n1 1 1\n1"]
null
PASSED
1,900
standard input
1 second
The first line contains three integers n, m and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor. The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contai...
["202", "205", "-1"]
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #define MP(a,b) make_pair(a,b) #define mem(a,b) memset(a , b , sizeof (a)) #define lol long long #define sz(a) (int)a.size() #define llsz(a) (long long...
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
68d252dc2af57192840554d8fa6d037f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
/* https://codeforces.com/contest/322/submission/20970107 (rainboy) */ #include <stdio.h> int main() { int n, m, i; scanf("%d%d", &n, &m); printf("%d\n", n + m - 1); for (i = 1; i <= m; i++) printf("1 %d\n", i); for (i = 2; i <= n; i++) printf("%d %d\n", i, m); return 0; }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
12ba8e4b5218ddd6d9aa9e220dd5c2e2
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include<stdio.h> int main(){ int a,b,i; int x=1; int y=1; scanf("%d %d",&a,&b); printf("%d\n",a-1+b); for(i=0;i<a-1;i++){ printf("%d %d\n",x,y); x++; } for(i=0;i<b;i++){ printf("%d %d\n",x,y); y++; } }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
7a943cb4c9632065f892d1454f8df146
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include <stdio.h> int main() { int n, m, i; scanf("%d%d", &n, &m); printf("%d\n", n + m - 1); for (i = 1; i <= m; i++) printf("1 %d\n", i); for (i = 2; i <= n; i++) printf("%d %d\n", i, m); return 0; }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
25eaa9b1e7c72be56e79d8d20f05a706
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include <stdio.h> int main(void) { int n = 0; int m = 0; scanf("%d %d", &n, &m); printf("%d\n", n + m - 1); for (int i = 0; i < m; i++) { printf("%d %d\n", 1, i + 1); } if (n > 1) { printf("%d %d\n", n, m); for (int i = n - 1; i > 1; i--) { printf("%...
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
404776fe8c4c8e21a2c063634bc94c6a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include <stdio.h> #include <stdlib.h> int main() { int n, m; scanf("%d%d", &n, &m); printf("%d\n", (n+m-1)); int i, j; for(i = 1; i <= m; i++) { printf("%d %d\n", 1, i); } for(j = 2; j <= n; j++) { printf("%d %d\n",j, 1); } return 0; }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
7d48f60bd91762ee662c4336d5a0a970
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include <stdio.h> int n, m, k, i, j; int main() { scanf("%d %d",&n,&m); printf("%d\n",n+m-1); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if((i==1 && j!=1) || (i!=1 && j==1) || (i==1 && j==1)) { printf("%d %d\n",i,j); } } } ...
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
12ca156b8f1b2fec86b46b9238649ce8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include <stdio.h> int main(){ int n,m,g; scanf("%d%d",&n,&m); printf("%d\n",n+m-1); printf("1 1\n"); if(n>=m) g=m; else g=n; for(int i=1;i<g;i++){ printf("%d %d\n",i,i+1); printf("%d %d\n",i+1,i); } if(g==m){ for(int i = m+1;i<=n;i++){ printf("%d 1\n",i); } } if(g==n){ for(int i= n+1;i<=m;i++...
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
1debcd513c0b1179ec31c3258038fd07
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include<stdio.h> main() { int b,g; scanf("%d %d",&b,&g); printf("%d\n",b+g-1); for(int a=1 ; a<=g ; a++) printf("1 %d\n",a); for(int a=1 ; a<b ;a++) printf("%d 1\n",a+1); }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
6277e433caf277c052369e3e812ad983
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include <stdlib.h> #include <stdio.h> #include <math.h> int main() { int n,m; scanf("%d%d",&n,&m); printf("%d\n",m+n-1); for (int i=1;i<=m;i++) { printf("1 %d\n", i); } for (int i=2;i<=n;i++) { printf("%d 1\n",i); } }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
c5ae85758600273b7d294a7a650347df
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include<stdio.h> main() { int b,g; scanf("%d %d",&b,&g); printf("%d\n",b+g-1); for(int a=1 ; a<=g ; a++) printf("1 %d\n",a); for(int a=1 ; a<b ;a++) printf("%d 1\n",a+1); }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
b056d8c9dcce685517431d0b01b9ae7b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include<stdio.h> int main() { int girl,boys,i,j,k; scanf("%d%d",&boys,&girl); i=boys+girl-1; printf("%d\n",i); for(i=1;i<=girl;i++) printf("1 %d\n",i); if(girl>1) j=2; else j=1; for(i=2;i<=boys;i++) printf("%d %d\n",i,j); return 0; }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
918d3bebcb84d2ca5b200717fad6f950
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include<stdio.h> int main() { int a,b,c,i; scanf("%d %d",&a,&b); printf("%d\n",a+b-1); for(i=1;i<=b;i++) { printf("1 %d\n",i); } for(i=2;i<=a;i++) { printf("%d 1\n",i); } return 0; }
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he...
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
C
14fc3a7fef44a02791aee62838c4c8c8
cee414f8c8b9b5b088d2eb7a44bf9aaf
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy" ]
1372433400
["2 1", "2 2"]
NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.
PASSED
1,000
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"]
#include<stdio.h> int main() { int b,g,i,j; scanf("%d%d",&b,&g); printf("%d\n",b+g-1); for(j=1;j<=b;j++) for(i=1;i<=g;i++){ if(j>1&&i>1)break; printf("%d %d\n",j,i); } return 0; }
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
7b7506f28892dfe69a9291278847dc9d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> #include<stdlib.h> void fun(int ); void fun(int n) { int i,j,s,l=0,flag=0; for(i=0;i<=n/4;i++) { s=n-i*4; if(s%7==0) { flag=1; for(j=0;j<i;j++) { printf("4"); } s=s/7; for(j=0;j<...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
46e68bea224b2474f4db45ee7453e63b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> #include <stdlib.h> int main() { int n,i,j,k,status=0; scanf("%d",&n); for(i=0;i<=n/4;i++) { for(j=0;j<=n/7;j++) { if(i*4+j*7==n) { status=1; break; } } if(status==1) ...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
df37db305138f82294bfc6d2a4567d4b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main(void) { int i,j,n,k,l,a=0; scanf("%d", &n); for(i=0;i<=n/4; i++) { for(j=0; j<=n/7; j++) { if(n-4*i-7*j==0) {a--; break;} } if(a<0) break; } if(a==0) printf("-1"); else { for(k=0; k<i; k++) printf("4"); for(k=0; k<j; k++) printf("7"); } }
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
b5579d544cf36d80a5930d15b3fd00bf
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { int num; scanf("%d",&num); int b; b=num; int s=0,f=0; if(b%4!=0){ while(b>=7 && b%4!=0) {b=b-7; s++; } // printf("sevens %d\n",s); while(b>0) {b=b-4; f++; } // printf("fours %d\n",f); if(f>=7){ s=s+(f/7)*4; f=f%7;} } else{ int q=b/4; s=(q/7)*4; f=q%7; } //...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
7383223931b8f324b3d93e3687db8037
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { int n; scanf("%d",&n); int b; b=n; int s=0,f=0; if(b%4!=0){ while(b>=7 && b%4!=0) {b=b-7; s++; } // printf("sevens %d\n",s); while(b>0) {b=b-4; f++; } // printf("fours %d\n",f); if(f>=7){ s=s+(f/7)*4; f=f%7;} } else{ int q=b/4; s=(q/7)*4; f=q%7; } //printf...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
f84350d7d65df57c330a5cafd6a8bb5b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> int main() { int n, i, a = 0, b = 0; scanf("%d", &n); a = 0; if(n==4 || n==7) { printf("%d",n); return 0; } if(n%7==0) { for(i=0;i<n/7;i++) { printf("7"); } return 0; } while (4 * a + 7 * b < n) {...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
35caa64616ddc2111184e2513cccb422
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> int main() { int n, acum=0, total=0; scanf("%i", &n); while(n > 0){ if(n%7 != 0){ n=n-4; total++; acum++; } else{ n=n-7; total++; } } if(n==0){ for(int i=0;i<total;i++){ if(i < acum){ printf("4"); } else pri...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
4a4191823b3a1b377f6f6e46129293c4
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> int main() { int n, acum=0, total=0; scanf("%d", &n); while(n > 0){ if(n%7 != 0){ n=n-4; total++; acum++; } else{ n=n-7; total++; } } if(n==0){ for(int i=0; i<total;i++){ if(i < acum){ printf("4"); } else pr...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
1c41e1c274090a3d0f7afc38329f94eb
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> int main(){ int n,flag=0,min=2147483647,num1,num2,sum; scanf("%d",&n); for(int i=0;i<=n/7;i++){ if((n-i*7)%4==0){ flag=1; sum=i+(n-7*i)/4; if(min>sum){ num1=i; num2=(n-7*i)/4; min=sum; ...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
f3a532afb38cb6d731a70ca0f13249c1
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> #include<string.h> #include<ctype.h> int main() { int a,m=0,n=0,i; scanf("%d",&a); for(i=0; a>0; i++) { if(a%7==0) {m++; a-=7;} else if(a%4==0) {n++; a-=4;} else {m++; a-=7;} } if(a<0) printf("-1\n"); else{ for(i=0; i<n; i++) printf("4");...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
3486177689902940c1df09eac501a44f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { long long int n,a,b,i=0,c=1,j,sum=0,m=1,v=0,q,w; scanf("%lld",&n); while(1){ a=(n-(7*i))/4; b=(n-(7*i))%4; if(b!=0){ i++; } else break; if(a<0){ c=0; break; } } whil...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
e6b9f1e63a50bd6446453356c2f1c8cd
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { long long int n,a,b,i=0,c=1,j,sum=0,m=1,v=0,q,w; scanf("%lld",&n); while(1){ a=(n-(7*i))/4; b=(n-(7*i))%4; if(b!=0){ i++; } else break; if(a<0){ c=0; break; } } whil...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
1e8a747817b367f4cc75e3da3c81070a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { int n,a; scanf("%d",&n); int four=0,seven=0; four = n/4; n = n%4; int res=1; if(n!=0) { four--; for(a=1; a<7&&four>=0; a++,four--) { n+=4; if(n>=7) { seven++; n=n-7;...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
5dcc0e73b00e44cd3a33684bc7d76d3f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> int main() { int n,i,SEV=0,FOR=0,N; scanf("%d",&n); N=n; while(N>0) { if(N%7==0) {SEV+=N/7;break;} else if(N%4==0) {FOR+=(N%28)/4;SEV+=(N/28)*4;break;} else {N-=7;SEV++;} } if(N<=0) {printf("-1\n")...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
2960c049da87f90d3ad3264b03833d0a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> int main() { int n,i,SEV=0,FOR=0,N; scanf("%d",&n); N=n; while(N>0) { if(N%7==0) {SEV+=N/7;break;} else if(N%4==0) {FOR+=(N%28)/4;SEV+=(N/28)*4;break;} else {N-=7;SEV++;} } if(N<=0) {printf("-1\n")...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
1c3e633deff750dc8dc4171fa866468e
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> int main(){ int n; scanf("%d", &n); int f = -1, s = -1; for(int i = 0;i < n; i++){ int tmp = n - i * 7; if( tmp % 4 == 0 && tmp / 4 >= 0){ if( (f == -1 && s == -1) || (i + tmp / 4 < s + f ) ){ f = tmp / 4; s = i; } } } if( f == -1 && s == -1){ printf("-1\n"); } ...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
5b9eec0f47133dd6d8e40e4ce9a85480
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> #include<math.h> #include <string.h> int main() { int i, j, n, m, a; int d, x =0; scanf("%d", &d); for(i=0; d>=i*4 ;i++){ if((d-i*4)%7==0) { a=(d-i*4)/7; break; } } m = (a*7) + (i*4); if(m == d){ for(j=0; j<i; j++){ printf("4"); ...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
9c3f76c3cf81eda974ce5b356596eadb
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include <stdio.h> int main(){ int sum; scanf("%i",&sum); if(sum < 4) { puts("-1"); return 0; } int sevens = sum/7; int fours,rem; sevens++; while(sevens--){ rem = sum - 7*sevens; if(rem % 4 == 0){ //wuju we made it fours = rem/4; //printf("%i ",fours); while(fours--) putchar('4'); ...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
3a5d1af40f1ec049de58b90499459c19
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { long long int a,b,n=0,m=0,c=0,s=0,d=0,i,j; scanf("%lld",&a); for(; ;) { if(a%7==0) { c=a/7; m=1; break; } else { a=a-4; d++; if(a==0) { ...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
3c2a52e90a9835f3ece8d6d99cb4cb1e
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { int a,b,c,d,i; scanf("%d",&a); b=a%4; if(b!=0) b=4-b; a=a-b*7; a=a/4; if(a<0) printf("-1\n"); else { c=a/7; b=b+c*4; a=a%7; for(i=0; i<a; i++) { printf("4"); } for(i=0; ...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
5938d0c53bd5bcc3038b471896cf3024
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { int n,f=0,sum=0,i,j,fo=0,se=0; scanf("%d",&n); /*if(n%7==0) { for(int i=1;i<=n/7;i++) printf("%d",7); } else if(n%4==0) { for(int i=1;i<=n/4;i++) printf("%d",4); } else*/ { for(i=0;sum<n&&f==0;i++) { for(j=0;sum<n;j++) ...
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with t...
Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.
C
2584fa8c1adb1aa8cd5c28a8610ff72d
90c04d0dcec52f00abbead9cfe78f5b4
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force" ]
1314633600
["11", "10"]
null
PASSED
1,000
standard input
2 seconds
The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.
["47", "-1"]
#include<stdio.h> int main() { int n,i,k; scanf("%d",&n); if(n==1||n==2||n==3||n==5||n==6||n==9||n==10||n==13||n==17) { printf("-1\n"); } else if(n==4||n==7) { printf("%d\n",n); } else if(n==8) { printf("44\n"); } else if(n==11) { print...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
9d6514e4dffb0010fb4e93a037171898
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include<stdio.h> #include<stdlib.h> int a[200005],b[200005],temp[200005]; void merge(int l,int r) { if(l==r) return; int i,j,k,mid; mid=(l+r)/2; merge(l,mid); merge(mid+1,r); for(i=l,j=mid+1,k=l; k<=r; k++) { if(i==mid+1) { temp[k]=a[j]; j++; ...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
a5392a465cbc97ddea880dc4f008664b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include <stdio.h> #include <stdlib.h> static int _a[200000]; static inline int compare_int(const void* a, const void* b) { return *(const int*)b - *(const int*)a; } /* search sorted (ascending) array for lowest index i, such that v <= a[i] */ /* this index can be used for insertion (to keep array sorted) ...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
e090db87251a7ac704e33ec2ff72a29f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include <stdio.h> #include <stdlib.h> void read_array(int x,int y[]); void merge_sort(int arr[],int lo ,int hi ); void merge (int arr[],int lo ,int mid ,int hi); void NumOfElement(int a[],int b[],int c[],int x ,int y); void print_array(int n ,int a[]); int main() { int n,m; scanf("%d %d",&n,&m); int a[n]; int b[m]; in...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
6d24a08bbc4de806003d9d7203f6600e
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include <stdio.h> #include <stdlib.h> #define MALLOC(t,n) (t*) malloc(sizeof(t)*n) typedef struct indice{ int posicao; int valor; }indice; int comparador(const void *a, const void *b){ return (*(int*)a) - (*(int*)b); } int comparadorValor(const void *a, const void *b){ return (*(indice*)a).valor - ...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
aee114668f4a14b55d31f47fe32f6e1c
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include <stdio.h> void merge(int *arry,int l,int mid,int r){ int arry1[(r-l)+1]; int k = l; int j = mid+1; int count=0; while (k<=mid && j<=r){ if (arry[k]>arry[j]){ arry1[count] = arry[j]; j++; } else{ arry1[count]=arry[k]; k+...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
efd27dbc003b730bf53a233e6a370a8b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include<stdio.h> void shellSort(int data[],int len) { int m=(int)(log(len+1)/log(2));//计算hibbard增量的长度。 int i; int G[m]; for(i=0;i<m;i++) G[i]=(int)pow(2,i+1)-1;//计算Hibbard增量 for(i=m-1;i>=0;i--) insertionSort(data,len,G[i]); } void insertionSort(int data[],int len,int g) { int i,j,v; for(i=g;i<len;i++) { ...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
16779cf595a4105e3785b1a597e9b576
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include <stdio.h> #include <stdlib.h> int a[2000000]; int b[2000000]; int sum[2000000]; /* for(i=0;i<n-1;i++) { int y=i; if(a[i]>a[i+1]) { int temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; for(k=0;k<i;k++) ...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
2667fee646d53417a0a05d34cec0e0b4
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include <stdio.h> #include <stdlib.h> int a[2000000]; int b[2000000]; int sum[2000000]; void merge(int arr[], int l, int m, int r) { int i, j, k; int n1 = m - l + 1; int n2 = r - m; /* create temp arrays */ int L[n1], R[n2]; /* Copy data to temp arrays L[] and R[] */ for (i = 0; i < n1;...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
c615e55728fdf2e6507c2a1f851e4fcf
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include <stdio.h> int a[200005]; int sorted[200005]; int n, m; void merge(int start, int middle, int end){ int i, j; int ptr=start; for(i=start, j=middle+1; i<=middle && j<=end; ptr++){ if(a[i] > a[j]){ sorted[ptr] = a[j]; j++; } else{ sorted[ptr] = a[i]; i++; } } while(j<=end){ sorted[ptr]...
You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.
C
e9a519be33f25c828bae787330c18dd4
cfad2e80bbe6ed5a3c4878cbfe11b6d3
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "two pointers", "binary search", "sortings" ]
1448636400
["5 4\n1 3 5 7 9\n6 4 2 8", "5 5\n1 2 1 2 5\n3 1 4 1 5"]
null
PASSED
1,300
standard input
2 seconds
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b. The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109). The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).
["3 2 1 4", "4 2 4 2 5"]
#include <stdio.h> void merge(int* arr, int start, int mid, int end) { int i = start, j = mid + 1, k, aux[end + 1]; for (k = start; k <= end ; k++) aux[k] = arr[k]; for (k = start; k <= end; k++) { if (i > mid) arr[k] = aux[j++]; else if (j > end) arr[k] = aux[i++]; else if (aux[i] < aux[j]) arr[...
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative in...
Print n non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.
C
8f342e167e77088ce47f17e5cd475b17
f6820c61a82c3f88c76783e38717a9b7
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "greedy" ]
1353339000
["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1"]
NoteIf you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The i-th of these lines contains n space-separated integers: the j-th number represents the element of matrix bij. It is guaranteed, that for all i (1 ≤ i ≤ n) the following condition fulfills: bii = -...
["0", "18 18 0", "128 180 148 160"]
#include <stdio.h> int main() { int a[100]; int e, n, i, j; scanf("%d", &n); for (i = 0; i < n; i++) { a[i] = 0; } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%d", &e); if (i >= j) { continue; } a[i] |= e; a[j] |= e; } } for (i = 0; i < n; i++) { printf("%d "...
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative in...
Print n non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.
C
8f342e167e77088ce47f17e5cd475b17
be4341aac8350c706996f795cf1e971a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "greedy" ]
1353339000
["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1"]
NoteIf you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The i-th of these lines contains n space-separated integers: the j-th number represents the element of matrix bij. It is guaranteed, that for all i (1 ≤ i ≤ n) the following condition fulfills: bii = -...
["0", "18 18 0", "128 180 148 160"]
#include<stdio.h> int main(void){ int n,num,i,j,in; scanf("%d",&n); for(i=0;i<n;i++){ num=0; for(j=0;j<n;j++){ scanf("%d",&in); if(in==-1) continue; num|=in; } printf("%d%c",num,(i==n-1)?'\n':' '); } return 0; }
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative in...
Print n non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.
C
8f342e167e77088ce47f17e5cd475b17
8b1f20e2343bbb806bab7142c25d8aad
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "greedy" ]
1353339000
["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1"]
NoteIf you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The i-th of these lines contains n space-separated integers: the j-th number represents the element of matrix bij. It is guaranteed, that for all i (1 ≤ i ≤ n) the following condition fulfills: bii = -...
["0", "18 18 0", "128 180 148 160"]
#include <stdio.h> int main(void) { unsigned matrix[100][100]; unsigned n; scanf("%d",&n); unsigned i,j; for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",matrix[i]+j); unsigned result; i=0; result=0; for(j=0;j<n;j++) if(i!=j) result|=matrix[i][j]; printf("%d",result); for(i=1;i<n;i++){ result=0; ...
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative in...
Print n non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.
C
8f342e167e77088ce47f17e5cd475b17
91a0cfb46ff0b83dfe3bbfcdc3485220
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "greedy" ]
1353339000
["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1"]
NoteIf you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The i-th of these lines contains n space-separated integers: the j-th number represents the element of matrix bij. It is guaranteed, that for all i (1 ≤ i ≤ n) the following condition fulfills: bii = -...
["0", "18 18 0", "128 180 148 160"]
#include<stdio.h> int n,a[109],x,i,j; int main() { scanf("%d",&n); for(i=1;i<=n;i++) for(j=1;j<=n;j++) { scanf("%d",&x); if(x>0) a[i]=a[i]|x; } for(i=1;i<=n;i++) printf("%d ",a[i]); printf("\n"); return 0; }
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative in...
Print n non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.
C
8f342e167e77088ce47f17e5cd475b17
343d95dfd5d718637571001065c78855
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "greedy" ]
1353339000
["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1"]
NoteIf you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The i-th of these lines contains n space-separated integers: the j-th number represents the element of matrix bij. It is guaranteed, that for all i (1 ≤ i ≤ n) the following condition fulfills: bii = -...
["0", "18 18 0", "128 180 148 160"]
#include<stdio.h> #include<stdlib.h> long a[105]={0}; int main() { int i,j,n; long x; scanf("%d",&n); for(i=1;i<=n;i++) for(j=1;j<=n;j++) { scanf("%ld",&x); if(x>0) a[i]=a[i]|x; } for(i=1;i<=n;i++) printf("%ld ",a[i]); //system("pause"); return ...
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative in...
Print n non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.
C
8f342e167e77088ce47f17e5cd475b17
ddd2790df99da0dedb37f6730cf93e7b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "greedy" ]
1353339000
["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1"]
NoteIf you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The i-th of these lines contains n space-separated integers: the j-th number represents the element of matrix bij. It is guaranteed, that for all i (1 ≤ i ≤ n) the following condition fulfills: bii = -...
["0", "18 18 0", "128 180 148 160"]
#include <stdio.h> #include <stdlib.h> int n,b[101]={0}; int main() { int i,j,k,l; scanf("%d",&n); i=0;j=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf("%d",&k); if(k>0) b[i]=b[i]|k; } } for(i=0;i<n;i++) printf("%d ",b[i]); return 0; } ...
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative in...
Print n non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.
C
8f342e167e77088ce47f17e5cd475b17
dc21e0cff2be7dab2b7760ee2e4fc837
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "greedy" ]
1353339000
["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1"]
NoteIf you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The i-th of these lines contains n space-separated integers: the j-th number represents the element of matrix bij. It is guaranteed, that for all i (1 ≤ i ≤ n) the following condition fulfills: bii = -...
["0", "18 18 0", "128 180 148 160"]
#include<stdio.h> #include<string.h> long n,a[200][200]={0}; long shu[200][150]={0},len[200]={0}; long mi(long k) { int ans=1,i; for(i=0;i<k;i++) ans*=2; return ans; } int main() { long i,j,t,k; scanf("%ld",&n); for(i=0;i<n;i++) for(j=0;j<n;j++) {scanf("%ld",&a[i][j]); ...
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative in...
Print n non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.
C
8f342e167e77088ce47f17e5cd475b17
90dda7279b94d6d0118e577a3e1782bd
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "greedy" ]
1353339000
["1\n-1", "3\n-1 18 0\n18 -1 0\n0 0 -1", "4\n-1 128 128 128\n128 -1 148 160\n128 148 -1 128\n128 160 128 -1"]
NoteIf you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The i-th of these lines contains n space-separated integers: the j-th number represents the element of matrix bij. It is guaranteed, that for all i (1 ≤ i ≤ n) the following condition fulfills: bii = -...
["0", "18 18 0", "128 180 148 160"]
#include <stdio.h> int b[100][100]; int a[100]; void solve(int n) { int i, j, k; for (i = 0; i < n; i ++) { a[i] = 0; for (j = 0; j < 30; j ++) { for (k = 0; k < n; k ++) { if (k != i) { if (b[i][k] & (1 <<...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
323664b18aa926916dcdd846af9f66b1
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> int n; int arr[300000][2]; int out[300000]; int main() { int n1, n2; int buf; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &arr[i][0], &arr[i][1]); } if (n == 3) { for (int i = 1; i <= n; i++) { out[i] = i % n + 1; } } else { for (int i = 1; i <= n; i++)...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
82e860f99380295614c2a3e7157c5bd1
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
/* > < */ #include <stdio.h> #define MAXN 200003 static int n, a[MAXN][2]; static _Bool vis[MAXN] = { 0 }; int main() { int i; scanf("%d", &n); for (i = 0; i < n; ++i) { scanf("%d%d", &a[i][0], &a[i][1]); a[i][0]--; a[i][1]--; } if (n == 3) { puts("1 2 3"); ...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
a7b31a0ef73251e689ea0544f15c0c70
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> int main() { long long int n; scanf("%I64d",&n); long long int a[n+1],b[n+1]; a[0]=0; b[0]=0; for (long long int i=1;i<=n;i++) scanf("%I64d %I64d",&a[i],&b[i]); long long int s[n+1]; s[0]=0; long long int z=1; s[z]=1; z++; long long int i=1; while(z<...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
0554fdc9b7a12236fbe4917162a94268
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdlib.h> #include <stdio.h> typedef struct data { int neg1; int neg2; }data; int main() { data *d; int *a, x, y, i, n; scanf("%d", &n); d = (data *) malloc(sizeof(data) * n); for(i = 0; i < n; i++) scanf("%d%d", &d[i].neg1, &d[i].neg2); a = (int *) malloc(sizeof(int) * n); a[0] = 1; x = d[0].neg1...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
5682aa304de6553ee0cfaad4414693b0
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> #include <string.h> #define SWAP(x, y) (x ^= y ^= x ^= y) #define MAXN 200000 int order[MAXN + 1] = {0, 1}; int rule[MAXN + 1][2]; int main() { int N; scanf("%d", &N); for ( int i = 1; i <= N; i++) scanf("%d%d", &rule[i][0], &rule[i][1]); memset(order, 0, sizeof(order)); ...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
aeddc0fe0c0fc21a53da790b19b83292
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include<stdio.h> int main(){ int n,i,j,k,count=0; scanf("%d",&n); int a[n][2],b[n][2],c[n+1]; for(i=0;i<n;i++){ scanf("%d%d",&a[i][0],&a[i][1]); b[i][1]=a[i][0];b[i][0]=a[i][1]; } i=0; while(count<n){ if(a[a[i][0]-1][0]==a[i][1]){ c[count]=a[i][0]; count++; ...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
b5726131bda147f2b538e11112752728
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> #include <stdint.h> uint32_t n; uint32_t a[200002]; uint32_t a1[200002]; uint32_t a2[200002]; int main() { uint32_t i, j; scanf("%d", &n); for(i = 1; i <= n; i++) scanf("%d%d", a1+i, a2+i); // a[2] = 1; for(i = 1; i <= n; i++) { if(a1[i] == 1 || a2[i] == 1) { j = a1[i] == 1 ? a2[i] : ...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
fa419b2a89205c2f07666e6487ccb6ee
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> #define N 200000 int main() { static int ii[N], jj[N], aa[N][2], kk[N]; int n, h, i, j; scanf("%d", &n); if (n == 3) { printf("1 2 3\n"); return 0; } for (h = 0; h < n; h++) { scanf("%d%d", &i, &j), i--, j--; ii[h] = i; jj[h] = j; aa[i][kk[i]++] = j; aa[j][kk[j]++] = i; } h =...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
28875eadb24c3f886b751fc14ae6d6ac
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> #include <stdlib.h> int main(){ int n, i, j = 0; scanf("%d", &n); int arr[n][2]; for(i=0;i<n;++i){ scanf("%d %d",&arr[i+1][0],&arr[i+1][1]); } i = arr[1][0]; j = arr[1][1]; printf("1 "); int fl = 0, k; if(arr[i][0]==j){ fl=1; k=1;} else if(arr[i][1]==j) {fl=1; k=0;} if(fl==1) printf...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
31a1c60a6e6a1c20d15fc124242547c7
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> int main() { int n; scanf("%d", &n); int a[n+1][2], b[n+1], q=1, i=1; for (int i = 1; i < n+1; ++i) { scanf("%d%d", &a[i][0], &a[i][1]); } b[q]=1; q++; if(a[i][0]==a[a[i][1]][0]||a[i][0]==a[a[i][1]][1]) { b[q]=a[i][1]; q++; b[q]=a[i][0]; ...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
1b37a5e691c2d19e5dc2eddf29c19343
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> #include <limits.h> #include <stdlib.h> int main(){ int n; scanf("%d",&n); int ans[n+5]; int a[n+5]; int b[n+5]; for (int i = 1; i <=n ; ++i) { scanf("%d%d",&a[i],&b[i]); } ans[1]=1; ans[2]=a[1]; ans[3]=b[1]; if(a[a[1]]!=b[1] && b[a[1]]!=b[1]...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
c37609d3dd6e6801a7d1108605f57dff
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include<stdio.h> int k,i,j,a,b,sayac=0; int dizi[200000][2]; void bunratax(int lo){ static int ol=0; if(ol==k){ } else{ sayac=1 ; printf("%d ",lo); int l1=dizi[lo][0]; int l2=dizi[lo][1]; if((dizi[l1][0]==l2 || dizi[l1][1]==l2)&&l1!=1){ ol++ ; bunratax(l1); } else{ ol++ ; bunratax(l...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
ee6b64e996af5d2a125a0a8764c50533
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include<stdio.h> int main() { int n,i,j,next; int a[200001][3]={0}; scanf("%d",&n); for(i=1;i<n+1;i++)scanf("%d %d", &a[i][0],&a[i][1]); j=1; if(a[a[j][0]][0]==a[j][1]||a[a[j][0]][1]==a[j][1])a[j][2]=a[j][0]; else a[j][2]=a[j][1]; next=a[j][0]+a[j][1]-a[j][2]; j=a[j][2]; //printf("%d\n",j); for(i=1;i<n;i++)...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
2c0fc972a62b6c1cd94ec2b98e0ef86a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> #define N 200001 int vis[N]; int main () { static int a[N][2]; int n, i, j, next; scanf ("%d", &n); for (i = 1; i <= n; i++) { scanf ("%d%d", &a[i][0], &a[i][1]); } next = 1; while (n--) { printf("%d ", next); vis[next] = 1; i = a[next][0], j = a[next][1]; if (vis[i])...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
c6be420cec5e0cd6031ea8319e7fc022
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> typedef struct kid { int kid1; int kid2; }kid; kid kids[200000] = {0}; int flags[200000] = {0}; int result[200000] = {0}; int check(int kid, int other) { if (kids[kid - 1].kid1 == other || kids[kid - 1].kid2 == other) { return 1; } return 0; } int main() { int ...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
41bb4f60d10dc7f32759e1ecf480bd47
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> int order(int a[][2], int i); int main() { int n, i, j = 1; scanf("%d", &n); int a[n + 1][2]; for(i = 1; i <= n; i++) scanf("%d%d", &a[i][0], &a[i][1]); printf("1 "); if(n != 3) for(i = 1; i <= n - 1; i++) { printf("%d ", order(a, j)); ...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
fe1a53e54ac415bc351326ad4e6479ee
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdlib.h> #include <stdio.h> int get_int(); int max(int a, int b) { if (a > b) { return a; } return b; } int min(int a, int b) { if (a < b) { return a; } return b; } int cmp(const void* p1, const void* p2) { return *(int*)p1 - *(int*)p2; } typedef struct { int x, y; } par; int main() { int...
There are $$$n$$$ kids, numbered from $$$1$$$ to $$$n$$$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (all these numbers are from $$$1$$$ to $$$n$$$ and are distinct, so $$$p$$$ is a permutation). Let the next kid for a kid $$$p_i$...
Print $$$n$$$ integers $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ — permutation of integers from $$$1$$$ to $$$n$$$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one s...
C
819d3694fccf2b5af0ec3b4ee429dbb3
ab96572fd123ded1016e8f1d4853552a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1545921300
["5\n3 5\n1 4\n2 4\n1 5\n2 3", "3\n2 3\n3 1\n1 2"]
null
PASSED
1,600
standard input
3 seconds
The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$) — the number of the kids. The next $$$n$$$ lines contain $$$2$$$ integers each. The $$$i$$$-th line contains two integers $$$a_{i, 1}$$$ and $$$a_{i, 2}$$$ ($$$1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$$$) — the kids t...
["3 2 4 1 5", "3 1 2"]
#include <stdio.h> int remember[300005][2]; int used[300005]; int main(int argc, char const *argv[]) { int N; scanf("%d",&N); for (int i = 1; i <= N; ++i) { scanf("%d%d",&remember[i][0],&remember[i][1]); used[i] = 0; } int cur=1; for (int i = 0; i < N; ++i) { printf("%d ",cur ); used[cur] = 1; if((use...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
71e1e376306b0af520ef0b90c01ac1e3
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include <stdio.h> #include <math.h> int main(){ int n,ans=-1000001; double m; scanf("%d",&n); for(int i = 0; i<n;++i){ scanf("%lf",&m); if(m<0 && m>ans){ ans = m; } if(((sqrt(m) - ((int) sqrt(m))) != 0.0) && m > ans){ ans = m; } } ...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
1812911efcfa779e8695f38dfa09e195
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int main() { int n,a; scanf("%d",&n); int max=-10000000; double temp_1; double temp_2; while(n>0) { n--; scanf("%d",&a); if(a<0) max=max>a?max:a; else { temp_1=sqrt(a); temp_2=(double)(int)temp_1; if(temp_1!=temp_2) max=max>a?max:a; } } printf("%...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
4a547833169544f4ea48bbf31d9651fa
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int main() { long long int n,a,s,m=-1,x=-1000000,i,p=0,q=0; scanf("%I64d",&n); for(i=1;i<=n;i++) { scanf("%I64d",&a); if(a>=0) { s=sqrt(a); if(a!=(s*s)) { if(a>m) m=a; q=...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
396967f76081efb0d903787f0e3e42c3
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<stdlib.h> #include<math.h> int main() { int n; scanf("%d",&n); int a[n]; for(int i=0;i<n;i++) scanf("%d",&a[i]); int largest=-10000000; for(int i=0;i<n;i++) { int x; int j=1; if(a[i]>0) { x=a[i]; while( x>0 ) { x-=j; j=j+2; } } else x=a[i]; if( x!...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
783a692bbd97d29c2e239e133550823d
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> int f(int n) { if(n==0) return 1; int x,i,k=0; for(x=1;x*x<=n;x++) { if(x*x==n) k=1; } return k; } int main() { int t,p,q,r=0,max=0; scanf("%d",&t); int a[t+1][3],b[t]; for(p=0;p<t;p++) { scanf("%d",&a[p][1]); a[p][2]=f(a[p][1]); } for(p=0;p<t;p++) { if(a[p][2]==0) {b[r]=a[p...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
31156b683baa94ee047a5b652468dcc9
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int main() { int b,a; int max=-10000000; int i,size; scanf("%d",&size); for(i=0;i<size;i++) { scanf("%d",&a); b=sqrt(a); if((b*b==a)) continue; else if(a>max) max=a; } printf("%d\n",max); return 0; ...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
93d3a13abbbb8ae1aef90def3cb6c278
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int main() { double f; int n,i; scanf("%d",&n); //printf("-----1\n"); long p,max=-1000000; for(i=0;i<n;i++) { scanf("%ld",&p); if(p<0) { if(p>max) max=p; } else if(p%10 == 2 || p%10 == 3 || p%10 == 7 |...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
4471363c6a4ad1a1cfdd35a124cebc6c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int myjudge(int a){ int i; for(i=0;i*i<=a;i++) if(i*i==a) break; if(i*i==a) return 0; return 1; } int main() { int n; scanf("%d",&n); int a[n]; int i; for(i = 0; i < n; i++) scanf("%d",&a[i]); int j; for(i = 0; i < n - 1; i++) ...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
ebba8d087d9e6c63058e651cb992b6db
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include <stdio.h> #include <math.h> int main() { int i,n; int t[1000]; int max = -pow(10,6); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&t[i]); if(sqrt(t[i])!=(int)sqrt(t[i])) { if(t[i]>max) max = t[i]; } } printf("%d",max); return 0; }
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
94b7bdbef88f20779617a23f7742c5c7
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include <stdio.h> #include <stdlib.h> #include<math.h> int main() { int x; float y; int n,i,j,max=0,max2=-1000001; scanf("%d",&n); int a[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { if(a[i]<0) { if(max2<a[i]) { ...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
7be657981720486cc65d0a57a831c26f
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include <stdio.h> #include <stdlib.h> #include <math.h> int cmpfunc (const void * a, const void * b) { return ( *(int*)a - *(int*)b );} int main () { long t[1000]; int n; scanf ("%d",&n); for (int i=0;i<n;i++) scanf("%d",&t[i]); long i=n-1; qsort(t, n, sizeof(int), cmpfunc); while (round(sqrt(t[i]))==sqrt(t...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
90ab07b581b0d61de06fc26e4a5b0ed2
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include <stdio.h> #include<math.h> int main() { long long int n,i,x,y,mx=0,num=0; scanf("%lld",&n); for(i=0;i<n;i++) { scanf("%lld",&x); if(x<0) { if(num==0) num=x; else if(x>num) num=x; continue; } ...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
70da6f1dceea20832e274c2220b96faf
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include <stdio.h> int main() { long long int n,i,ans; long long int a[1005]; int p[1000005]={0}; scanf("%I64d",&n); for(i=0;i<n;i++) scanf("%I64d",&a[i]); for(i=0;i<=1000;i++) { p[i*i]=1; } ans=-10000000; for(i=0;i<n;i++) { if(a[i]>=0) { if(p[a[i]]==0) { if(ans<a[i]) ans=a[i]; ...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
4214b1150fdd92cd6e265a0ef5c1ab3b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int ch(int n) { double d; d=sqrt(n); int p=d; if(p*p==n) return 0; else return 1; } int main() { int i,j,k,n,c=-1000005; scanf("%d",&k); for(i=0; i<k; i++) { scanf("%d",&n); if(n>0 ) { if(ch(n)) ...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
d7ddc920b08fac1b2402bdf7bd7d6403
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int panduan(int n) { float i; if(sqrt(n)!=(int)sqrt(n)) return 0; else return 1; } int a[10001]; int n; int main() { scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a[i]); } for(int i=0;i<n-1;i++) { for(int j=i+1;j<n;j++) { if(a[j]>a[i]) { int temp=a[j...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
8d753cc63ee96554dc60ccee00e24455
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int main() { int n; while(scanf("%d",&n)!=EOF) { int a[1007],b[1007],j=0,i; for(i=1;i<=n;i++) { scanf("%d",&a[i]); int t; t=sqrt(a[i]); if(a[i]!=t*t) { b[j]=a[i]; j++; } } for(i=0;i<j;i++) if(b[0]<b[i]) b[0]=b[i]; printf("%d\n",b[0])...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
5c80d8dd213f9779ba0b9908cf46c089
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include<stdio.h> #include<math.h> int main() { int n; while(scanf("%d",&n)!=EOF) { int a[1007],b[1007],j=0,i; for(i=1;i<=n;i++) { scanf("%d",&a[i]); int t; t=sqrt(a[i]); if(a[i]!=t*t) { b[j]=a[i]; if(b[0]<b[j]) b[0]=b[j]; j++; } } printf("%d\n",b[0]); } }
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
9f6ebc3e2b79c84bea7979a62280935e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include <stdio.h> #include <stdlib.h> #include<math.h> int main() { int n,i,num,res; res=-1000001; scanf("%d",&n); int x[n]; for(i=0;i<n;i++){ scanf("%d",&x[i]); } for(i=0;i<n;i++){ num=sqrt(x[i]); if(x[i]!=num*num){ if(res<x[i]) { res=x[i]; } ...
Given an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.A number x is said to be a perfect square if there exists an integer y such that x = y2.
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
C
d46d5f130d8c443f28b52096c384fef3
22488156a50c18e3047bbbc5ae3d4519
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "brute force", "math" ]
1516462500
["2\n4 2", "8\n1 2 4 8 16 32 64 576"]
NoteIn the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
PASSED
900
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array. The second line contains n integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — the elements of the array. It is guaranteed that at least one element of the array is not a perfect square.
["2", "32"]
#include <stdio.h> #include <math.h> int main ( ){ int n,x,i; long int y=-1000000; scanf("%d",&n); int arr[n]; for(i=0;i<n;i++) { scanf("%d",&arr[i]); x=sqrt(arr[i]); if((x*x)!=arr[i]&& arr[i]>y) y=arr[i]; } printf("%d",y) ; return 0; }