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 have a string $$$s$$$ of length $$$n$$$ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character <, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character > in string > > < >, the string will become to > > >. And if we choose character < in string > <, the string will become to <.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings >, > > are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
e4b48fcce933373bf3c1e9cec20ec2dc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n<>\n3\n><<\n1\n>"]
NoteIn the first test case we can delete any character in string <>.In the second test case we don't need to delete any characters. The string > < < is good, because we can perform the following sequence of operations: > < < $$$\rightarrow$$$ < < $$$\rightarrow$$$ <.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters > and <.
["1\n0\n0"]
#include <stdio.h> int main(void) { int t, n; char s[100]; int i, j, result, f1, f2, mf1, mf2, c1, c2, u; int d[100]; char test; scanf("%d", &t); for(i = u = 0; u < t; u++, i = 0){ scanf("%d", &n); test = getchar(); if(test = '\n' && i == 0); while((test = getchar()) != '\n' && i < n){ s[i] = test; i++; } f1 = mf1 = s[0] == '>' ? 1 : 0; f2 = mf2 = s[i-1] == '<' ? 1 : 0; for(c1 = 0, j = 1; j < i && f1 == mf1; j++) if(s[0] == s[j]) c1++; else f1 = f1 == 0 ? 1 : 0; for(c2 = 0, j = i - 2; j >= 0 && f2 == mf2; j--) if(s[i-1] == s[j]) c2++; else f2 = f2 == 0 ? 1 : 0; result = c1 <= c2 ? c1 : c2; result += mf1 == 1 || mf2 == 1 ? -result : 1; d[u] = result; } for(u = 0; u < t; u++) printf("%d\n", d[u]); return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
fc864d4954307701584a14dcd2ee845b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include<stdio.h> int main() { int t, n, i, c, r, c2; scanf("%d", &t); while(t--) { char s[101]; scanf("%d%s", &n, &s); c=0; for(i=0;s[i]!='\0';i++) { if(s[i]=='<') c++; else break; } r=strlen(s); c2=0; for(i=r-1;i>=0;i--) { if(s[i]=='>') c2++; else break; } if(c<c2) printf("%d\n", c); else printf("%d\n", c2); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
aa307339e84a7ca5bc2894a8d792be6f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include<stdio.h> #include<stdlib.h> int main() { int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); char a[n]; scanf("%s",a); int c=0,d=0; for(int i=0;i<n;i++) { if(a[i]!='>') { c++; } else break; } for(int j=n-1;j>=0;j--) { if(a[j]!='<') { d++; } else break; } if(c>=d) { printf("%d\n",d); } else printf("%d\n",c); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
dc03547d5ee4319665c1407668bd5a31
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include<stdio.h> #include<stdlib.h> int main() { int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); char a[n]; scanf("%s",a); int c=0,d=0; for(int i=0;i<n;i++) { if(a[i]!='>') { c++; } else { break; } } for(int j=n-1;j>=0;j--) { if(a[j]!='<') { d++; } else { break; } } if(c>=d) { printf("%d\n",d); } else printf("%d\n",c); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
0c6ef85081c413e2bcaeb5ddeeab4089
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include<stdio.h> int main(){ int t; scanf("%d",&t); while(t--) { int n,i,sum1=0,sum2=0; scanf("%d",&n); char a[n]; scanf("%s",a); for(i=0;i<n;i++) { if(a[i]=='<') sum1++; else break; } for(i=0;i<n;i++) { if(a[n-1-i]=='>') sum2++; else break; } if(sum1<=sum2) printf("%d\n",sum1); else printf("%d\n",sum2); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
0ce3793ad4120de7195cf3cd62e825df
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include <stdio.h> int main() { int t; scanf("%d", &t); while (t--) { int i,n,ans=0; scanf("%d", &n); char str[n]; scanf(" %s",str); for (i=0;i<=n/2;i++) if(str[i]=='>'||str[n-i-1]=='<') { ans = i; break; } printf("%d\n", ans); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
a754e972890fbd515235f7ccc6cc044c
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include <stdio.h> int main() { int t; scanf("%d", &t); while (t--) { int n, ans; scanf("%d", &n); char str[n + 1]; scanf(" %s", str); for (int i = 0; i <= n / 2; i++) if (str[i] == '>' || str[n - i - 1] == '<') { ans = i; break; } printf("%d\n", ans); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
50a20c94d178fa11edd16a739bdabbd5
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include <stdio.h> int main(int argc, char const *argv[]) { int t; scanf("%d", &t); while (t--) { int n, ans; scanf("%d", &n); char str[n + 1]; scanf(" %s", str); for (int i = 0; i <= n / 2; i++) if (str[i] == '>' || str[n - i - 1] == '<') { ans = i; break; } printf("%d\n", ans); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
bb53b6a46f56ed1878a34ff344453597
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include <stdio.h> #define N 107 char s[N]; int min(int a, int b) { return (a<b) ? a : b; } int main() { int t; scanf("%d", &t); for (int ii=0; ii<t; ii++) { int n; scanf("%d", &n); getchar(); for (int i=0; i<n; i++) { char tmp; scanf("%c", &tmp); s[i]=tmp; } getchar(); //puts("*"); int L=0, R=0; for (int i=0; i<n; i++) { if (s[i]=='<') continue; else { L=i; break; } } for (int i=n-1; i>=0; i--) { if (s[i]=='>') continue; else { R=n-i-1; break; } } printf("%d\n", min(L, R)); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
9e8243eee30283a6f3dddb85ad8dcd27
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include<stdio.h> int nnn(int a,int b) { return (a<b)?a:b; } int main() { int t; scanf("%d",&t); while(t--) { int n,l=-1,r=-1,lcnt=0,rcnt=0; scanf("%d",&n); char s[101]={'\0'}; scanf("%s",s); for(int i=0;i<n;i++) { if(s[i]!='<') { l=i; break; } else lcnt++; } //printf("l=%d ",l); if(l==-1||l==0) printf("0\n"); else { for(int i=n-1;i>=0;i--) { if(s[i]!='>') { r=i; break; } else rcnt++; } if(r==-1||r==n-1) printf("0\n"); else { //printf("%d %d",l,r); int ans=nnn(lcnt,rcnt); printf("%d\n",ans); } } } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
e2b1bf6d8ab17dccf4aeca5605612e78
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include<stdio.h> #include<string.h> int main() { int t,n,i,j,c; char s[105]; scanf("%d",&t); for(i=1;i<=t;i++){ scanf("%d\n",&n); gets(s); c=0; if(s[0]=='>'||s[n-1]=='<'){ c=0; } else{ for(j=0;j<n;j++){ if(s[j]=='>'){ c=j; break; } } for(j=n-1;j>=0;j--){ if(s[j]=='<'){ if(n-j-1<c){ c=n-j-1; } break; } } } printf("%d\n",c); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
c706e581cfab187842c6347a130ebcd3
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include<stdio.h> #include<string.h> int main() { int i,test; scanf("%d",&test); for(i=0;i<test;i++) { int j,ans,length; scanf("%d",&length); char string[length]; scanf("%s",string); for(j=0;j<length;j++) { if(string[j]=='>'||string[length-j-1]=='<') { printf("%d\n",j); break; } } } }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
0ccc9d9f3973659e1e5114a1d1e9b089
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include <stdio.h> int main(){ int ttl,n,i,j,rst[120],a = 0,b = 0; char stt,end,temp[120]; scanf("%d",&ttl); for(i = 0;i<ttl;i++){ scanf("%d",&n); scanf("%s",temp); stt = temp[0]; end = temp[n-1]; if(stt == '>'||end=='<') rst[i] = 0; else{ a = 0; b = 0; for(j = 0;j<n;j++){ if(temp[j]=='>'){ break; }else{ a += 1; } } for(j = n-1;j>=0;j--){ if(temp[j]=='<'){ break; }else{ b += 1; } } rst[i] = a<b?a:b; } } for(i = 0;i<ttl;i++){ printf("%d\n",rst[i]); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
5aca0368c3595388b5b854e05ef0f7d5
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include<stdio.h> int main() { int i,j,n,t,p,num,num1,a[110]; char s[110]; scanf("%d",&t); for(i=0;i<t;i++){ scanf("%d",&n); getchar(); gets(s); num=0; num1=0; for(j=n-1;j>=0;j--) if(s[j]=='<') break; p=j; while(s[++p]=='>') num++; for(j=0;j<n;j++) if(s[j]=='>') break; p=j; while(p>=0&&s[--p]=='<') num1++; if(num<=num1) a[i]=num; else a[i]=num1; } for(i=0;i<t;i++) printf("%d\n",a[i]); return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
307cac4d276a375b73addacb1f72d33f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include <stdio.h> ///typedef long long ll; ///int minimum (int a, int b) {return a < b ? a : b;} ///ll gcd (ll a, ll b) {return b == 0 ? a : a%b;} ///ll diff (ll a, ll b) {return a < b ? b - a : a - b;} ///int str_len(char arr[]) {int i = 1; while (arr[i] != '\0') i++; return i;} ///char* str_copy (char arr[], int n) {int i = 0; char out[n]; while(i < n) {out[i] = arr[i]; i++;} return out;} ///int absVal (int a) {return (a < 0) ? (0 - a) : a;} ///int count [10010]; int main(){ int tc, i; scanf("%d", &tc); for (i = 0; i < tc; i++){ int n, j, lftCnt = 0, rtCnt = 0; scanf("%d", &n); char inp[n+1]; scanf("%s", inp); for (j = 0; j < n-1; j++){ if (inp[j] == '<' && inp[j+1] == '>'){ int k; for (k = j; k >= 0; k--){ if (inp[k] != '>') lftCnt++; else lftCnt = 0; } for (k = j; k < n; k++){ if (inp[k] != '<') rtCnt++; else rtCnt = 0; } } } printf("%d\n", lftCnt < rtCnt ? lftCnt : rtCnt); } return 0; }
You have a string $$$s$$$ of length $$$n$$$ consisting of only characters &gt; and &lt;. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character &gt;, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character &lt;, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character &gt; in string &gt; &gt; &lt; &gt;, the string will become to &gt; &gt; &gt;. And if we choose character &lt; in string &gt; &lt;, the string will become to &lt;.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings &gt;, &gt; &gt; are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.
C
0ba97bcfb5f539c848f2cd097b34ff33
af09c8c888f9976f3d36f458afa4b2ee
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1553267100
["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;"]
NoteIn the first test case we can delete any character in string &lt;&gt;.In the second test case we don't need to delete any characters. The string &gt; &lt; &lt; is good, because we can perform the following sequence of operations: &gt; &lt; &lt; $$$\rightarrow$$$ &lt; &lt; $$$\rightarrow$$$ &lt;.
PASSED
1,200
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters &gt; and &lt;.
["1\n0\n0"]
#include <stdio.h> int good_string(int n) { char s[n+1]; int i, j; for (i = 0, scanf("%s",s); i < n && s[i] != '>'; i++); for (j = 0; j < n && s[n-1-j] != '<'; j++); if (i > j) { return j; } return i; } int main(void) { int t, n; for (scanf("%d",&t); t > 0 && scanf("%d",&n); t--) { printf("%d\n",good_string(n)); } return 0; }
You are given an array $$$s$$$ consisting of $$$n$$$ integers.You have to find any array $$$t$$$ of length $$$k$$$ such that you can cut out maximum number of copies of array $$$t$$$ from array $$$s$$$.Cutting out the copy of $$$t$$$ means that for each element $$$t_i$$$ of array $$$t$$$ you have to find $$$t_i$$$ in $$$s$$$ and remove it from $$$s$$$. If for some $$$t_i$$$ you cannot find such element in $$$s$$$, then you cannot cut out one more copy of $$$t$$$. The both arrays can contain duplicate elements.For example, if $$$s = [1, 2, 3, 2, 4, 3, 1]$$$ and $$$k = 3$$$ then one of the possible answers is $$$t = [1, 2, 3]$$$. This array $$$t$$$ can be cut out $$$2$$$ times. To cut out the first copy of $$$t$$$ you can use the elements $$$[1, \underline{\textbf{2}}, 3, 2, 4, \underline{\textbf{3}}, \underline{\textbf{1}}]$$$ (use the highlighted elements). After cutting out the first copy of $$$t$$$ the array $$$s$$$ can look like $$$[1, 3, 2, 4]$$$. To cut out the second copy of $$$t$$$ you can use the elements $$$[\underline{\textbf{1}}, \underline{\textbf{3}}, \underline{\textbf{2}}, 4]$$$. After cutting out the second copy of $$$t$$$ the array $$$s$$$ will be $$$[4]$$$. Your task is to find such array $$$t$$$ that you can cut out the copy of $$$t$$$ from $$$s$$$ maximum number of times. If there are multiple answers, you may choose any of them.
Print $$$k$$$ integers — the elements of array $$$t$$$ such that you can cut out maximum possible number of copies of this array from $$$s$$$. If there are multiple answers, print any of them. The required array $$$t$$$ can contain duplicate elements. All the elements of $$$t$$$ ($$$t_1, t_2, \dots, t_k$$$) should satisfy the following condition: $$$1 \le t_i \le 2 \cdot 10^5$$$.
C
cfccf06c4d0de89bf0978dc6512265c4
20e0cc649708d37904b53aac5e9a21c1
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "binary search", "sortings" ]
1542378900
["7 3\n1 2 3 2 4 3 1", "10 4\n1 3 1 3 10 3 7 7 12 3", "15 2\n1 2 1 1 1 2 1 1 2 1 2 1 1 1 1"]
NoteThe first example is described in the problem statement.In the second example the only answer is $$$[7, 3, 1, 3]$$$ and any its permutations. It can be shown that you cannot choose any other array such that the maximum number of copies you can cut out would be equal to $$$2$$$.In the third example the array $$$t$$$ can be cut out $$$5$$$ times.
PASSED
1,600
standard input
3 seconds
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$s$$$ and the desired number of elements in $$$t$$$, respectively. The second line of the input contains exactly $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ ($$$1 \le s_i \le 2 \cdot 10^5$$$).
["1 2 3", "7 3 1 3", "1 1"]
#include<stdio.h> int num[200002],n,r,temp[200002]; void mergesort(int low, int high, int num[]){ if(low == high){ return; } int mid = (low + high)/2; mergesort(low, mid,num); mergesort(mid + 1, high,num); int i,j,k; for(i = low,j = mid + 1, k = low; k <= high; k++){ if(i == mid + 1){ temp[k] = num[j++]; } else if(j == high + 1){ temp[k] = num[i++]; } else if(num[i] < num[j]){ temp[k] = num[i++]; } else{ temp[k] = num[j++]; } } for(k = low; k <= high; k++){ num[k] = temp[k]; } } int searching(int repeat){ int i,j = 1,l,m = 0; l = num[0]; for(i = 1; i < n; i++){ if(num[i] == l){ j++; if(j == repeat){ m++; l = 0; } } else{ j = 1; if(j == repeat){ m++; } l = num[i]; } if(m == r){ return 1; } } return 0; } int binary_search(int low, int high){ int mid; while(high - low > 2){ mid = (low + high)/2; if(searching(mid) == 1){ low = mid; } else{ high = mid - 1; } } for(mid = high; mid >= low; mid--){ if(searching(mid) == 1){ return mid; } } } int main(){ int i,j,k = 1,l,m = 0; scanf("%d %d",&n,&r); for(i = 0; i < n; i++){ scanf("%d",&num[i]); } mergesort(0,n - 1,num); if(n < 2*r){ for(i = 0; i < r; i++){ printf("%d ",num[i]); } } j = binary_search(1,n); l = num[0]; for(i = 1; i < n; i++){ if(num[i] == l){ k++; if(k == j){ printf("%d ",num[i]); m++; l = 0; } } else{ k = 1; l = num[i]; if(k == j){ printf("%d ",num[i]); } } if(m == r){ return 0; } } }
You are given an array $$$s$$$ consisting of $$$n$$$ integers.You have to find any array $$$t$$$ of length $$$k$$$ such that you can cut out maximum number of copies of array $$$t$$$ from array $$$s$$$.Cutting out the copy of $$$t$$$ means that for each element $$$t_i$$$ of array $$$t$$$ you have to find $$$t_i$$$ in $$$s$$$ and remove it from $$$s$$$. If for some $$$t_i$$$ you cannot find such element in $$$s$$$, then you cannot cut out one more copy of $$$t$$$. The both arrays can contain duplicate elements.For example, if $$$s = [1, 2, 3, 2, 4, 3, 1]$$$ and $$$k = 3$$$ then one of the possible answers is $$$t = [1, 2, 3]$$$. This array $$$t$$$ can be cut out $$$2$$$ times. To cut out the first copy of $$$t$$$ you can use the elements $$$[1, \underline{\textbf{2}}, 3, 2, 4, \underline{\textbf{3}}, \underline{\textbf{1}}]$$$ (use the highlighted elements). After cutting out the first copy of $$$t$$$ the array $$$s$$$ can look like $$$[1, 3, 2, 4]$$$. To cut out the second copy of $$$t$$$ you can use the elements $$$[\underline{\textbf{1}}, \underline{\textbf{3}}, \underline{\textbf{2}}, 4]$$$. After cutting out the second copy of $$$t$$$ the array $$$s$$$ will be $$$[4]$$$. Your task is to find such array $$$t$$$ that you can cut out the copy of $$$t$$$ from $$$s$$$ maximum number of times. If there are multiple answers, you may choose any of them.
Print $$$k$$$ integers — the elements of array $$$t$$$ such that you can cut out maximum possible number of copies of this array from $$$s$$$. If there are multiple answers, print any of them. The required array $$$t$$$ can contain duplicate elements. All the elements of $$$t$$$ ($$$t_1, t_2, \dots, t_k$$$) should satisfy the following condition: $$$1 \le t_i \le 2 \cdot 10^5$$$.
C
cfccf06c4d0de89bf0978dc6512265c4
1b51e33e92375e471bd7fc4e1505aa5b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "binary search", "sortings" ]
1542378900
["7 3\n1 2 3 2 4 3 1", "10 4\n1 3 1 3 10 3 7 7 12 3", "15 2\n1 2 1 1 1 2 1 1 2 1 2 1 1 1 1"]
NoteThe first example is described in the problem statement.In the second example the only answer is $$$[7, 3, 1, 3]$$$ and any its permutations. It can be shown that you cannot choose any other array such that the maximum number of copies you can cut out would be equal to $$$2$$$.In the third example the array $$$t$$$ can be cut out $$$5$$$ times.
PASSED
1,600
standard input
3 seconds
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$s$$$ and the desired number of elements in $$$t$$$, respectively. The second line of the input contains exactly $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ ($$$1 \le s_i \le 2 \cdot 10^5$$$).
["1 2 3", "7 3 1 3", "1 1"]
#include<stdio.h> int num[200002],n,r,temp[200002]; void mergesort(int low, int high, int num[]){ if(low == high){ return; } int mid = (low + high)/2; mergesort(low, mid,num); mergesort(mid + 1, high,num); int i,j,k; for(i = low,j = mid + 1, k = low; k <= high; k++){ if(i == mid + 1){ temp[k] = num[j++]; } else if(j == high + 1){ temp[k] = num[i++]; } else if(num[i] < num[j]){ temp[k] = num[i++]; } else{ temp[k] = num[j++]; } } for(k = low; k <= high; k++){ num[k] = temp[k]; } } int searching(int repeat){ int i,j = 1,l,m = 0; l = num[0]; for(i = 1; i < n; i++){ if(num[i] == l){ j++; if(j == repeat){ m++; l = 0; } } else{ j = 1; if(j == repeat){ m++; } l = num[i]; } if(m == r){ return 1; } } return 0; } int binary_search(int low, int high){ int mid; while(high - low > 2){ mid = (low + high)/2; if(searching(mid) == 1){ low = mid; } else{ high = mid - 1; } } for(mid = high; mid >= low; mid--){ if(searching(mid) == 1){ return mid; } } } int main(){ int i,j,k = 1,l,m; m = 0; scanf("%d %d",&n,&r); for(i = 0; i < n; i++){ scanf("%d",&num[i]); } mergesort(0,n - 1,num); if(n < 2*r){ for(i = 0; i < r; i++){ printf("%d ",num[i]); } } j = binary_search(1,n); l = num[0]; for(i = 1; i < n; i++){ if(num[i] == l){ k++; if(k == j){ printf("%d ",num[i]); m++; l = 0; } } else{ k = 1; l = num[i]; if(k == j){ printf("%d ",num[i]); } } if(m == r){ return 0; } } }
You are given an array $$$s$$$ consisting of $$$n$$$ integers.You have to find any array $$$t$$$ of length $$$k$$$ such that you can cut out maximum number of copies of array $$$t$$$ from array $$$s$$$.Cutting out the copy of $$$t$$$ means that for each element $$$t_i$$$ of array $$$t$$$ you have to find $$$t_i$$$ in $$$s$$$ and remove it from $$$s$$$. If for some $$$t_i$$$ you cannot find such element in $$$s$$$, then you cannot cut out one more copy of $$$t$$$. The both arrays can contain duplicate elements.For example, if $$$s = [1, 2, 3, 2, 4, 3, 1]$$$ and $$$k = 3$$$ then one of the possible answers is $$$t = [1, 2, 3]$$$. This array $$$t$$$ can be cut out $$$2$$$ times. To cut out the first copy of $$$t$$$ you can use the elements $$$[1, \underline{\textbf{2}}, 3, 2, 4, \underline{\textbf{3}}, \underline{\textbf{1}}]$$$ (use the highlighted elements). After cutting out the first copy of $$$t$$$ the array $$$s$$$ can look like $$$[1, 3, 2, 4]$$$. To cut out the second copy of $$$t$$$ you can use the elements $$$[\underline{\textbf{1}}, \underline{\textbf{3}}, \underline{\textbf{2}}, 4]$$$. After cutting out the second copy of $$$t$$$ the array $$$s$$$ will be $$$[4]$$$. Your task is to find such array $$$t$$$ that you can cut out the copy of $$$t$$$ from $$$s$$$ maximum number of times. If there are multiple answers, you may choose any of them.
Print $$$k$$$ integers — the elements of array $$$t$$$ such that you can cut out maximum possible number of copies of this array from $$$s$$$. If there are multiple answers, print any of them. The required array $$$t$$$ can contain duplicate elements. All the elements of $$$t$$$ ($$$t_1, t_2, \dots, t_k$$$) should satisfy the following condition: $$$1 \le t_i \le 2 \cdot 10^5$$$.
C
cfccf06c4d0de89bf0978dc6512265c4
3fe290f79f711ba7ab4343fa67790e85
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "binary search", "sortings" ]
1542378900
["7 3\n1 2 3 2 4 3 1", "10 4\n1 3 1 3 10 3 7 7 12 3", "15 2\n1 2 1 1 1 2 1 1 2 1 2 1 1 1 1"]
NoteThe first example is described in the problem statement.In the second example the only answer is $$$[7, 3, 1, 3]$$$ and any its permutations. It can be shown that you cannot choose any other array such that the maximum number of copies you can cut out would be equal to $$$2$$$.In the third example the array $$$t$$$ can be cut out $$$5$$$ times.
PASSED
1,600
standard input
3 seconds
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$s$$$ and the desired number of elements in $$$t$$$, respectively. The second line of the input contains exactly $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ ($$$1 \le s_i \le 2 \cdot 10^5$$$).
["1 2 3", "7 3 1 3", "1 1"]
#include<stdio.h> int num[200002],n,r,temp[200002]; void mergesort(int low, int high, int num[]){ if(low == high){ return; } int mid = (low + high)/2; mergesort(low, mid,num); mergesort(mid + 1, high,num); int i,j,k; for(i = low,j = mid + 1, k = low; k <= high; k++){ if(i == mid + 1){ temp[k] = num[j++]; } else if(j == high + 1){ temp[k] = num[i++]; } else if(num[i] < num[j]){ temp[k] = num[i++]; } else{ temp[k] = num[j++]; } } for(k = low; k <= high; k++){ num[k] = temp[k]; } } int searching(int repeat){ int i,j = 1,l,m = 0; l = num[0]; for(i = 1; i < n; i++){ if(num[i] == l){ j++; if(j == repeat){ m++; l = 0; } } else{ j = 1; if(j == repeat){ m++; } l = num[i]; } if(m == r){ return 1; } } return 0; } int binary_search(int low, int high){ int mid; while(high - low > 2){ mid = (low + high)/2; if(searching(mid) == 1){ low = mid; } else{ high = mid - 1; } } for(mid = high; mid >= low; mid--){ if(searching(mid) == 1){ return mid; } } } int main(){ int i,j,k = 1,l,m = 0; scanf("%d %d",&n,&r); for(i = 0; i < n; i++){ scanf("%d",&num[i]); } mergesort(0,n - 1,num); if(n < 2*r){ for(i = 0; i < r; i++){ printf("%d ",num[i]); } } j = binary_search(1,n); l = num[0]; for(i = 1; i < n; i++){ if(num[i] == l){ k++; if(k == j){ printf("%d ",num[i]); m++; l = 0; } } else{ k = 1; l = num[i]; if(k == j){ printf("%d ",num[i]); } } if(m == r){ return 0; } } }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
940d36bab5f8e88ca758fdf883ab7de0
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> int main() { int n, i, j,a[4] = { 0 }, OK = 1; char s[300], ch[] = { "ACGT" }; scanf("%d %s", &n, s); for (i = 0; i < n; i++) { if (s[i] == 'A') a[0]++; else if (s[i] == 'C') a[1]++; else if (s[i] == 'G') a[2]++; else if (s[i] == 'T') a[3]++; } // check if possible if (n % 4 != 0) OK = 0; for (i = 0; i < 4; i++) if (a[i] > n / 4) { OK = 0; break; } if (!OK) { printf("==="); return 0; } j = 0; for (i = 0; i < n; i++) { if (s[i] == '?') { while (a[j] == n / 4) j++; s[i] = ch[j]; a[j]++; } } puts(s); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
febd9010593c2d3d1f5f19536e39c540
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int main() { int n,i,count[4]; char s[260]; scanf("%d%s",&n,s); if(n%4) puts("==="); else { for(i=0;i<4;i++) count[i]=n/4; for(i=0;i<n;i++) { switch(s[i]) { case 'A':count[0]--; break; case 'C':count[1]--; break; case 'G':count[2]--; break; case 'T':count[3]--; break; } } for(i=0;i<4;i++) { if(count[i]<0) break; } if(i<4) puts("==="); else { for(i=0;i<n;i++) { if(s[i]=='?') { if(count[0]>0) { s[i]='A'; count[0]--; } else if(count[1]>0) { s[i]='C'; count[1]--; } else if(count[2]>0) { s[i]='G'; count[2]--; } else if(count[3]>0) { s[i]='T'; count[3]--; } } } printf("%s\n",s); } } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
70e4dfc52795b10531ab85481782231c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
/* * */ #include <stdio.h> #include <stdlib.h> int max(int a, int b){ return a > b ? a : b; } int main(int argc, char* argv[]){ int n, i; scanf("%d", &n); char* s = malloc((n+1)*sizeof(char)); scanf("%s", s); *(s+n) = '\0'; int a = 0, c = 0, g = 0, t = 0, free = 0; for(i = 0; i < n; i++){ if(*(s+i) == 'A') a++; else if(*(s+i) == 'C') c++; else if(*(s+i) == 'G') g++; else if(*(s+i) == 'T') t++; else if(*(s+i) == '?') free++; } int maxVal = max(max(a, c), max(g, t)); int needed = (maxVal - a) + (maxVal - c) + (maxVal - g) + (maxVal - t); if(needed <= free){ if((free-needed)%4 == 0){ int tmpa = maxVal - a; int tmpc = maxVal - c; int tmpg = maxVal - g; int tmpt = maxVal - t; free -= needed; for(i = 0; i < n; i++){ if(*(s+i) == '?'){ if(tmpa > 0){ *(s+i) = 'A'; tmpa--; }else if(tmpc > 0){ *(s+i) = 'C'; tmpc--; }else if(tmpg > 0){ *(s+i) = 'G'; tmpg--; }else if(tmpt > 0){ *(s+i) = 'T'; tmpt--; } } } if(free > 0){ tmpa = free/4; tmpc = tmpa; tmpg = tmpa; tmpt = tmpa; for(i = 0; i < n; i++){ if(*(s+i) == '?'){ if(tmpa > 0){ *(s+i) = 'A'; tmpa--; }else if(tmpc > 0){ *(s+i) = 'C'; tmpc--; }else if(tmpg > 0){ *(s+i) = 'G'; tmpg--; }else if(tmpt > 0){ *(s+i) = 'T'; tmpt--; } } } } printf("%s\n", s); }else printf("===\n"); }else printf("===\n"); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
cb72737fccbd65377f78cc9dfcc371f9
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int main(void){ int n,i,j,aver,a[6],flag; char s[260]; while(scanf("%d",&n)!=EOF){ scanf("%s",s); if(n%4){ printf("===\n"); continue; } aver=n/4; int a[6]={0}; for(i=0;i<n;i++){ if(s[i]=='A') a[0]++; if(s[i]=='C') a[1]++; if(s[i]=='G') a[2]++; if(s[i]=='T') a[3]++; } //printf("%d %d %d %d\n",a[0],a[1],a[2],a[3]); flag=0; for(i=0;i<4;i++){ if(a[i]>aver){ flag=1; break; } } if(flag) { printf("===\n"); continue; } for(i=0;i<n;i++){ if(s[i]=='?'){ j=0; while(1){ if(a[j]<aver){ if(j==0){ s[i]='A'; a[j]++; } if(j==1){ s[i]='C'; a[j]++; } if(j==2){ s[i]='G'; a[j]++; } if(j==3){ s[i]='T'; a[j]++; } break; } j++; } } } //printf("%d %d %d %d\n",a[0],a[1],a[2],a[3]); printf("%s\n",s); } }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
833bd0b5484bcae382a4dec44ff47be6
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int main() { int n,flag=0,l,i,arr[4]={0},r,max=0,j; scanf("%d",&n); char s[257],genes[5]={'A','C','G','T'}; scanf("%s",s); l=strlen(s); for(i=0;i<l;i++) { if(s[i]=='A') arr[0]++; if(s[i]=='C') arr[1]++; if(s[i]=='G') arr[2]++; if(s[i]=='T') arr[3]++; } r=n/4,max=0; for(int j=0;j<4;j++) { if(arr[j]>max) max=arr[j]; } for(i=0;i<l;i++) { if(s[i]=='?') { for(j=0;j<4;j++) { if(arr[j]<r) { s[i]=genes[j]; arr[j]++; break; } } } } if(((n%4)!=0)||(max>r)) flag=1; if(flag==0) printf("%s",s); if (flag==1) printf("==="); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
aa1f643da67395bd06dae60cb2a7791c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int main() { int n,i,j,k,a1,a2,a3,a4,a5,m1,m2,m3,m4,b[300]; char s[300]; while(~scanf("%d",&n)) { getchar(); a1=a2=a3=a4=a5=0; j=0; memset(b,0,sizeof(b)); k=n/4; for(i=0; i<n; i++) { scanf("%c",&s[i]); if(s[i]=='A') a1++; else if(s[i]=='C') a2++; else if(s[i]=='G') a3++; else if(s[i]=='T') a4++; else if(s[i]=='?') { a5++; b[j]=i; j++; } } if(n%4!=0) printf("===\n"); else { m1=k-a1; m2=k-a2; m3=k-a3; m4=k-a4; if(a1<=k&&a2<=k&&a3<=k&&a4<=k) { for(i=0; i<m1; i++) s[b[i]]='A'; for(; i<m2+m1; i++) s[b[i]]='C'; for(; i<m2+m1+m3; i++) s[b[i]]='G'; for(; i<m2+m1+m3+m4; i++) s[b[i]]='T'; } else { printf("===\n"); return 0; } for(i=0; i<n; i++) printf("%c",s[i]); printf("\n"); } } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
1b60ae4ca57f55ea78f24e4bc1810a2f
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int b[5]; int main() { int n,i,j,len,IS=1; char a[255],c[5]={'?','A','C','G','T'}; scanf("%d",&n); getchar(); for(i=0;i<n;i++) scanf("%c",&a[i]); if(n%4!=0) printf("==="); else { len=n/4; for(i=0;i<n;i++) switch(a[i]) { case 'A': b[1]++;break; case 'C': b[2]++;break; case 'G': b[3]++;break; case 'T': b[4]++;break; case '?': b[0]++;break; default: break; } for(i=1;i<5;i++) if(b[i]>len) { printf("==="); IS=0; break; } if(IS==1) { for(i=0;i<n;i++) if(a[i]=='?') { for(j=1;j<=4;j++) if(b[j]<len) { a[i]=c[j]; b[j]++; break; } } for(i=0;i<n;i++) printf("%c",a[i]); } } }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
7d1490c349de788d6aa3c216e8287d3f
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> int main(void) { int n, a['T'+3]={0}; char s[259]; scanf("%d %s", &n, &s); if(n%4!=0){printf("===");return 0;} for(int i=0; i<n; i++) a[s[i]]++; if(a['A']>n/4 || a['C']>n/4 || a['G']>n/4 || a['T']>n/4){printf("===");return 0;} for(int i=0; i<n; i++) if(s[i]!='?') putchar(s[i]); else if (a['A']<n/4) putchar('A'),a['A']++; else if (a['C']<n/4) putchar('C'),a['C']++; else if (a['G']<n/4) putchar('G'),a['G']++; else if (a['T']<n/4) putchar('T'),a['T']++; return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
251348d52d10b9638cf323573b83b23d
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include <stdlib.h> int main() { int n; char s[300]; while(~scanf("%d",&n)) { int a,b,c,d,e,max,i; a=b=c=d=e=0; scanf("%s",s); for(i=0; i<n; i++) { if(s[i]=='A') a++; else if(s[i]=='G') b++; else if(s[i]=='C') c++; else if(s[i]=='T') d++; else e++; } max=n/4; if(n%4!=0||a>max||b>max||c>max||d>max) printf("==="); else { for(i=0; i<n; i++) { if(s[i]!='?') { printf("%c",s[i]); continue; } else { if(max!=a) { printf("A"); a++; } else if(max!=b) { printf("G"); b++; } else if(max!=c) { printf("C"); c++; } else if(max!=d) { printf("T"); d++; } e--; } } } printf("\n"); } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
89b531e6c40a559dd8d990a58a56a521
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int main(){ int n,b[4]={0,0,0,0},i,j,f=0;char a[259]; scanf("%d",&n); scanf("%s",a); if(n%4!=0) printf("==="); else { for(i=0;i<n;i++) { if(a[i]=='A') b[0]++; else if(a[i]=='C') b[1]++; else if(a[i]=='G') b[2]++; else if(a[i]=='T') b[3]++; } for(i=0;i<4;i++) { if(b[i]>n/4) { printf("==="); f=1;break; } } if(f==0) { j=0; for(i=0;i<n;i++) { if(a[i]=='?') { if(b[j]>=n/4) j++; if(b[j]>=n/4) j++; if(b[j]>=n/4) j++; if(j==0) a[i]='A'; else if(j==1) a[i]='C'; else if(j==2) a[i]='G'; else if(j==3) a[i]='T'; b[j]++; } } printf("%s",a); } } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
bed11d3ba466d77d8c0550739633b5a3
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> int main() { int n; scanf("%d", &n); char A[256]; int N[] = {0, 0, 0, 0}; scanf("%s", &A); if (n % 4 != 0) printf("==="); else { int c = 0; while (c < n) { char curr = A[c]; if (curr == 'A') N[0]++; else if (curr == 'C') N[1]++; else if (curr == 'G') N[2]++; else if (curr == 'T') N[3]++; c++; } if ((N[0] > (n/4)) || (N[1] > (n/4)) || (N[2] > (n/4)) || (N[3] > (n/4))) printf("==="); else { c = 0; while (c < n) { if (A[c] != '?') printf("%c", A[c]); else { if (N[0] < n/4) { printf("A"); N[0]++; } else if (N[1] < n/4) { printf("C"); N[1]++; } else if (N[2] < n/4) { printf("G"); N[2]++; } else if (N[3] < n/4) { printf("T"); N[3]++; } } c++; } } } }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
f8df51e7461f7ef2d9729e7953409cb3
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> typedef unsigned u; char S[999];u F[128]; int main() { u n,i; scanf("%u%s",&n,S); for(i=-1;S[++i];)++F[(u)S[i]]; if(n%4||F['A']>n/4||F['C']>n/4||F['G']>n/4||F['T']>n/4){printf("===\n");return 0;} F['A']=n/4-F['A']; F['C']=n/4-F['C']; F['G']=n/4-F['G']; F['T']=n/4-F['T']; for(i=-1;S[++i];)if(S[i]=='?') { if(F['A']){S[i]='A';--F['A'];continue;} if(F['C']){S[i]='C';--F['C'];continue;} if(F['G']){S[i]='G';--F['G'];continue;} if(F['T']){S[i]='T';--F['T'];continue;} } printf("%s\n",S); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
f692105dbc301a911c547953dc5b21c0
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include <string.h> #define MAX 256 int Func(int a, int b, int c, int d, int *rez) { int m[4], fl, i, t; m[0]=a; m[1]=b; m[2]=c; m[3]=d; do { fl=1; for (i=0; i<3; i++) if (m[i]<m[i+1]) { t=m[i]; m[i]=m[i+1]; m[i+1]=t; fl=0; } } while (fl==0); *rez=m[0]; return 3*m[0]-m[1]-m[2]-m[3]; } int Exist(int x, int y) { int i=0; while (x+4*i<=y) { if (x+4*(i)==y) return i; i++; } return -1; } char Fill(char s[], int max, int k, int kA, int kC, int kG, int kT) { int i, j, st=0, l=strlen(s), r; char sim[]={'A', 'C', 'G', 'T'}; int val[]={kA, kC, kG, kT}; for (j=0; j<4; j++) { r=0; for (i=st; i<l; i++) { if (r==max-val[j]+k) { st=i; break; } if (s[i]=='?') { s[i]=sim[j]; r++; } } } return; } int main() { int n, i, k, max=0, kA=0, kC=0, kG=0, kT=0, kQ=0; char s[MAX]; scanf("%d%s", &n, s); for (i=0; i<n; i++) { switch (s[i]) { case 'A': kA++; break; case 'C': kC++; break; case 'G': kG++; break; case 'T': kT++; break; case '?': kQ++; break; } } if ((k=Exist(Func(kA, kC, kG, kT, &max), kQ))!=-1) { Fill(s, max, k, kA, kC, kG, kT); printf("%s\n", s); } else printf("===\n"); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
d6cc592fecf2fff3e5292d910fe0fe92
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include <string.h> #define MAX 256 int main() { int n, i, kA=0, kC=0, kG=0, kT=0, kQ=0; char s[MAX]; scanf("%d%s", &n, s); if (n%4!=0) printf("==="); else { for (i=0; i<n; i++) { switch (s[i]) { case 'A': kA++; break; case 'C': kC++; break; case 'G': kG++; break; case 'T': kT++; break; case '?': kQ++; break; } } for (i=0; i<n; i++) { if (s[i]=='?') { if (kA<n/4) { s[i]='A'; kA++; continue; } if (kC<n/4) { s[i]='C'; kC++; continue; } if (kG<n/4) { s[i]='G'; kG++; continue; } if (kT<n/4) { s[i]='T'; kT++; continue; } } } if ((kA==n/4) && (kG==n/4) && (kC==n/4) && (kT==n/4)) printf("%s", s); else printf("==="); } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
96c3ddad531e2ffb411bee5d3b234b27
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> main() { int n,i,j,t=0,a=0,g=0,c=0; scanf("%d\n",&n); char s[n+1]; gets(s); if(n%4!=0) { printf("===");return 0; } for(i=0;i<n;i++) { if(s[i]=='A')a++; if(s[i]=='G')g++; if(s[i]=='C')c++; if(s[i]=='T')t++; } if(a>n/4||g>n/4||c>n/4||t>n/4) { printf("===");return 0; } a=n/4-a;g=n/4-g;c=n/4-c;t=n/4-t; for(i=0;i<n;i++) { if(s[i]=='?') { if(a>0) { s[i]='A';a--; }else if(g>0) { s[i]='G';g--; }else if(c>0) { s[i]='C';c--; }else if(t>0) { s[i]='T';t--; } } } for(i=0;i<n;i++)printf("%c",s[i]); }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
01d07ed08188c87d76431ebbc9ae6b8f
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int main() { int n; scanf(" %d", &n); if( n % 4 != 0 ) { printf("===\n"); return 0; } char s[n+1]; scanf(" %s", s); s[n] = '\0'; int a, g, c, t, q = 0; a = g = c = t = n/4; for(int i = 0; i < n; i++) { if( s[i] == 'A' ) a--; else if( s[i] == 'G' ) g--; else if( s[i] == 'C' ) c--; else if(s[i] == 'T' ) t--; else q++; } for(int i = 0; i < n; i++) { if ( s[i] == '?' ) { if(a != 0) { s[i] = 'A'; a--; } else if( g != 0 ) { s[i] = 'G'; g--; } else if( c != 0 ) { s[i] = 'C'; c--; } else if( t != 0 ) { s[i] = 'T'; t--; } } } if(a < 0 || c < 0 || g < 0 || t < 0) printf("===\n"); else printf("%s\n", s); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
ec3e156125a2480fa6ced719d9e10750
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include <string.h> int main() { int n,i,a=0,g=0,c=0,t=0,j=-1; scanf("%d",&n); char s[256]; int gen[5]={0}; int que[256]={0}; scanf("%s",&s); for(i=0;i<n;i++) { if(s[i]=='A') ++gen[0]; else if(s[i]=='C') ++gen[1]; else if(s[i]=='G') ++gen[2]; else if(s[i]=='T') ++gen[3]; else { ++gen[4]; que[++j]=i; } } if(gen[4]==0) { for(i=0;i<3;i++) { if(gen[i+1]==gen[i]) continue; else { printf("==="); return 0; } } printf("%s",s); return 0; } int max=gen[0]; for(i=1;i<4;i++) { if(gen[i]>max) max=gen[i]; } // printf("%d\n ",max); while(gen[0]<max && gen[4]) { ++gen[0]; --gen[4]; ++a; } while(gen[1]<max && gen[4]) { ++gen[1]; --gen[4]; ++c; } while(gen[2]<max && gen[4]) { ++gen[2]; --gen[4]; ++g; } while(gen[3]<max && gen[4]) { ++gen[3]; --gen[4]; ++t; } /* for(i=0;i<4;i++) { printf("%d ",gen[i]); }*/ for(i=0;i<4;i++) { if(gen[i]==max) continue; else { printf("==="); return 0; } } if(gen[4]%4!=0) { printf("==="); return 0; } int rem=gen[4]/4; a+=rem; c+=rem; g+=rem; t+=rem; while(a) { s[que[j]]='A'; --j; --a; } while(c) { s[que[j]]='C'; --j; --c; } while(g) { s[que[j]]='G'; --j; --g; } while(t) { s[que[j]]='T'; --j; --t; } printf("%s",s); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
4b521d4207c41cdf97ebda5c28593126
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int maximum(int a,int b,int c,int d) { if(a>=b&&a>=c&&a>=d) return a; else if(b>=c&&b>=d) return b; else if(c>=d) return c; else return d; } int main() { int n; scanf("%d",&n); int count[5]={0}; char s[n+1]; scanf("%s",s); int i; for(i=0;i<n;i++) { if(s[i]=='A') count[0]++; else if(s[i]=='G') count[1]++; else if(s[i]=='T') count[2]++; else if(s[i]=='C') count[3]++; else if(s[i]=='?') count[4]++; } int max=maximum(count[0],count[1],count[2],count[3]); if(n%4==0&&4*max<=n) { int rem=n/4-max; int temp,j; for(i=0;i<4;i++) { temp=rem+max-count[i]; for(j=0;j<n&&temp>0;j++) if(s[j]=='?') { if(i==0) s[j]='A'; else if(i==1) s[j]='G'; else if(i==2) s[j]='T'; else if(i==3) s[j]='C'; temp--; } } printf("%s\n",s); } else printf("===\n"); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
4dfea1b9fc91f70db89d7e5798a3d805
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> int occ(char c , char ch[]) { int i,k=0 ; for(i=0;i<strlen(ch);i++) { if(ch[i]==c) k++ ; } return k ; } int main() { int n ; scanf("%d",&n); char ch[n]; scanf("%s",ch); if ((n%4!=0)||(occ('A',ch)>n/4)||(occ('C',ch)>n/4)||(occ('G',ch)>n/4)||(occ('T',ch)>n/4)) printf("==="); else { int i; if (occ('A',ch)<n/4) { for(i=0;(i<strlen(ch))&&(occ('A',ch)<n/4);i++) { if(ch[i]=='?') ch[i]='A' ; } } if (occ('G',ch)<n/4) { for(i=0;(i<strlen(ch))&&(occ('G',ch)<n/4);i++) { if(ch[i]=='?') ch[i]='G' ; } } if (occ('C',ch)<n/4) { for(i=0;(i<strlen(ch))&&(occ('C',ch)<n/4);i++) { if(ch[i]=='?') ch[i]='C' ; } } if (occ('T',ch)<n/4) { for(i=0;(i<strlen(ch))&&(occ('T',ch)<n/4);i++) { if(ch[i]=='?') ch[i]='T' ; } } printf("%s",ch); } return 0 ; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
4e78d259e152c240a228d0386fac560e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include <string.h> int main(void) { char s[256]; int n,i,x; int A=0,C=0,G=0,T=0,U=0,j=0; int aA=0,aC=0,aG=0,aT=0; scanf("%d\n",&n); if(n%2 == 1) printf("==="); else { fgets(s, sizeof(s), stdin); for(i=0;i<n;i++) { switch(s[i]) { case'A': A++; break; case'C': C++; break; case'G': G++; break; case'T': T++; break; default: U++; break; } } aA = ((n/4)-A); aC = ((n/4)-C); aG = ((n/4)-G); aT = ((n/4)-A); if(A > (n/4) || C > (n/4) || G > (n/4) || T> (n/4)) printf("==="); else { x= ((n/4)-A) + ((n/4)-C) + ((n/4)-G) + ((n/4)-T); if(U != x) printf("==="); else { while(A != (n/4)) { for(i=0;i<n;i++) { if(s[i] == '?') { s[i] = 'A'; break; } } A++; } while(C != (n/4)) { for(i=0;i<n;i++) { if(s[i] == '?') { s[i] = 'C'; break; } } C++; } while( G != (n/4)) { for(i=0;i<n;i++) { if(s[i] == '?') { s[i] = 'G'; break; } } G++; } while(T != (n/4)) { for(i=0;i<n;i++) { if(s[i] == '?') { s[i] = 'T'; break; } } T++; } printf("%s\n",s); } } } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
c186444f9c094d68acbc61fffc5ea115
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int main() { char str[256]; int count[4],i,length=0,flag=0,n; scanf("%d",&n); scanf("%s",str); for(i=0;i<4;i++) count[i]=0; if(strlen(str)%4!=0) printf("===\n"); else { for(i=0;i<strlen(str);i++) { if(str[i]=='A') count[0]++; else if(str[i]=='C') count[1]++; else if(str[i]=='G') count[2]++; else if(str[i]=='T') count[3]++; else length++; } for(i=0;i<4;i++) { if(count[i]>strlen(str)/4) { flag=1; break; } } if(flag==1) printf("===\n"); else { char temp[length],j=0; for(i=1;i<=(strlen(str)/4)-count[0];i++) temp[j++]='A'; for(i=1;i<=(strlen(str)/4)-count[1];i++) temp[j++]='C'; for(i=1;i<=(strlen(str)/4)-count[2];i++) temp[j++]='G'; for(i=1;i<=(strlen(str)/4)-count[3];i++) temp[j++]='T'; j=0; for(i=0;i<strlen(str);i++) { if(str[i]=='?') str[i]=temp[j++]; } printf("%s\n",str); } } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
6bc8a2693d0792954b2e2d046ac936c0
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
//Created by Pratik Mandlecha #include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int n,flag=0; scanf("%d",&n); char s[257],ss[5]={'A','C','G','T'}; scanf("%s",s); int l=strlen(s); int i,a[4]={0}; for(i=0;i<l;i++) { if(s[i]=='A') a[0]++; if(s[i]=='C') a[1]++; if(s[i]=='G') a[2]++; if(s[i]=='T') a[3]++; } int r=n/4,max=0; for(int k=0;k<4;k++) { if(a[k]>max) max=a[k]; } for(i=0;i<l;i++) { if(s[i]=='?') { for(int k=0;k<4;k++) { if(a[k]<r) { s[i]=ss[k]; a[k]++; break; } } } } if(((n%4)!=0)||(max>r)) flag=1; if(flag==0) printf("%s",s); if (flag==1) printf("==="); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
14ab07e7dbcad5042f7f9245432366b2
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int main() { int n,a=0,g=0,c=0,t=0,question=0,q; scanf("%d",&n); char s[n]; scanf("%s",s); if(n==0) return 0; if(n%4==0) { q=n/4; for(int z=0;z<n;z++) { if(s[z]=='?') question++; if(s[z]=='A') a++; if(s[z]=='C') c++; if(s[z]=='G') g++; if(s[z]=='T') t++; } //printf("%d,%d,%d,%d,%d",a,c,g,t,question); if(a>q||c>q||g>q||t>q) {printf("===");return 0;} for(int p=0;p<n;p++) { if(s[p]=='?') { if(q-a>0) {s[p]='A'; a++; } else if(q-c>0) {s[p]='C';c++; } else if(q-g>0) {s[p]='G';g++; } else if(q-t>0) {s[p]='T';t++; } else{printf("==="); break;} } } printf("%s",s); } else { printf("==="); } }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
80ef075a8d091477b8e431e873eee6c9
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<math.h> #include<string.h> int main() { int i, n, na = 0, nc = 0, ng = 0, nt = 0, nn = 0, ni[300], pd = 1; char ch[300]; scanf("%d", &n); if (n % 4 == 0) { scanf("%s", ch); for (i = 0; i < n; i++) { switch (ch[i]) { case 'A': { na++; break; } case 'C': { nc++; break; } case 'G': { ng++; break; } case 'T': { nt++; break; } case '?': { nn++; ni[nn] = i; break; } } } if (na > (n / 4) || nc > (n / 4) || ng > (n / 4) || nt > (n / 4)) pd = 0; na -= (n / 4); nc -= (n / 4); ng -= (n / 4); nt -= (n / 4); for (i = 1; i <= nn; i++) { if (na < 0) { na++; ch[ni[i]] = 'A'; continue; } if (nc < 0) { nc++; ch[ni[i]] = 'C'; continue; } if (ng < 0) { ng++; ch[ni[i]] = 'G'; continue; } if (nt < 0) { nt++; ch[ni[i]] = 'T'; continue; } } } else pd = 0; if (pd) { for (i = 0; i < n; i++) printf("%c", ch[i]); } else printf("==="); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
a0e84b39e1e6564f1ca7c9e6a595560a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include<string.h> int main(void) { int i,j=0,a=0,c=0,g=0,t=0,q=0,n,w=0; scanf("%d",&n); char s[n+2]; int r[n]; scanf("%s",s); if(n%4!=0) {printf("===");return 0;} for(i=0;i<strlen(s);i++) { if(s[i]=='A') {a++;} if(s[i]=='C') {c++;} if(s[i]=='G') {g++;} if(s[i]=='T') {t++;} if(s[i]=='?') {q++;r[j]=i;j++;} } if(a>n/4||c>n/4||g>n/4||t>n/4) { printf("===");return 0;} for(;a<n/4;a++) { s[r[w]]='A'; w++; } for(;c<n/4;c++) { s[r[w]]='C'; w++; } for(;g<n/4;g++) { s[r[w]]='G'; w++; } for(;t<n/4;t++) { s[r[w]]='T'; w++; } printf("%s",s); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
70a4b24288db6a1281d657c6a603225c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include<string.h> int main(void) { int i,j=0,a=0,c=0,g=0,t=0,q=0,n,w=0; scanf("%d",&n); char s[n+2]; int r[n]; scanf("%s",s); if(n%4!=0) {printf("===");return 0;} for(i=0;i<strlen(s);i++) { if(s[i]=='A') {a++;} if(s[i]=='C') {c++;} if(s[i]=='G') {g++;} if(s[i]=='?') {q++;r[j]=i;j++;} } t=n-a-c-g-q; if(a>n/4||c>n/4||g>n/4||t>n/4) { printf("===");return 0;} for(;a<n/4;a++) { s[r[w]]='A'; w++; } for(;c<n/4;c++) { s[r[w]]='C'; w++; } for(;g<n/4;g++) { s[r[w]]='G'; w++; } for(;t<n/4;t++) { s[r[w]]='T'; w++; } printf("%s",s); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
6ce5ccae99d900672861667e5a7f7393
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int main() { int n;int i; char ch2[4]; char ch[300]; scanf("%d",&n); scanf("%s",ch); for(i=0;i<4;i++) ch2[i]=0; int a,b,c,d; ch2[0]=n/4; ch2[1]=n/4; ch2[2]=n/4; ch2[3]=n/4; for(i=0;i<n;i++) { switch(ch[i]) { case 'A' : ch2[0]--; break; case 'C' : ch2[1]--; break; case 'G' : ch2[2]--; break; case 'T' : ch2[3]--; break; } } if (n%4!=0) {printf("===");} else if(n%4==0) { i=0; while(i<n) { if (ch[i]=='?') { if (ch2[0]!=0) {ch[i]='A';ch2[0]--;} else if (ch2[1]!=0) {ch[i]='C';ch2[1]--;} else if (ch2[2]!=0) {ch[i]='G';ch2[2]--;} else if (ch2[3]!=0) {ch[i]='T';ch2[3]--;} } i++; } if (!ch2[0]&&!ch2[1]&&!ch2[2]&&!ch2[3]) printf("%s",ch); else printf("==="); } return 0 ; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
191bd7e351ee46488b921ae9a4fefa2b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> int n; char s[300]; int A,C,G,T; int main() { int i; scanf("%d%s",&n,s+1); if(n%4) { printf("==="); return 0;} A = C = G = T = n/4; for(i=1;s[i];i++) { if(s[i] == 'A') A--; else if(s[i] == 'C') C--; else if(s[i] == 'G') G--; else if(s[i] == 'T') T--; } if(A<0 || C<0 || G<0 || T<0) { printf("==="); return 0;} for(i=1;s[i];i++) if(s[i] == '?') { if(A) s[i] = 'A', A--; else if(C) s[i] = 'C', C--; else if(G) s[i] = 'G', G--; else if(T) s[i] = 'T', T--; } printf("%s",s+1); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
0cba0e22f76390945e7215d076c0951a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> int main() { int n,i,q=0,k=0,a=0,g=0,c=0,t=0; char ch,p; scanf("%d",&n); char s[n]; scanf("%s",&s); if((n%4)!=0) printf("==="); else { for(i=0;i<n;i++) { ch=s[i]; if(ch=='A') a++; else if(ch=='G') g++; else if(ch=='C') c++; else if(ch=='T') t++; else q++; } k=n/4; if(a>k || g>k || c>k ||t>k) printf("==="); else { for(i=0;i<n;i++) { p=s[i]; if(a<k) { if(p=='?') { p='A'; a++; } } else if(g<k) { if(p=='?') { p='G'; g++; } } else if(c<k) { if(p=='?') { p='C'; c++; } } else if(t<k) { if(p=='?') { p='T'; t++; } } printf("%c",p); } } } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
d74e30a3e24234a6f280ef9cb7ac0033
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> #include<math.h> int main(){ int a=0,c=0,g=0,t=0,x=0,l,i,j; char s[256]; scanf("%d",&l); int k=l/4; getchar(); gets(s); for(i=0;i<l;i++){ if(s[i]=='A') a++; if(s[i]=='C') c++; if(s[i]=='G') g++; if(s[i]=='T') t++; if(s[i]=='?') x++; } if(l%4!=0){ printf("==="); return 0; } if((a>l/4)||(c>l/4)||(g>l/4)||(t>l/4)){ printf("==="); return 0; } a=k-a; c=k-c; g=k-g; t=k-t; i=0; for(j=0;i<l;i++){ if((s[i]=='?')&&(j<a)){ s[i]='A'; j++; } if(j==a) break; } for(j=0;i<l;i++){ if((s[i]=='?')&&(j<c)){ s[i]='C'; j++; } if(j==c) break; } for(j=0;i<l;i++){ if((s[i]=='?')&&(j<g)){ s[i]='G'; j++; } if(j==g) break; } for(j=0;i<l;i++){ if((s[i]=='?')&&(j<t)){ s[i]='T'; j++; } if(j==t) break; } puts(s); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
581a70a0dbdf058fc670b27701c2e34c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <math.h> int main() { int n; scanf(" %d",&n); char str[n]; scanf(" %s",str); int i,a=0,c=0,g=0,t=0,x=0,y=0; if(n%4!=0){ printf("===\n"); return 0; } for(i=0;i<n;i++){ if(str[i]=='A'){ a++; } else if(str[i]=='C'){ c++; } else if(str[i]=='G'){ g++; } else if(str[i]=='T'){ t++; } else{ x++; } } int maxi=0; if(maxi<a){ maxi=a; } if(maxi<c){ maxi=c; } if(maxi<g){ maxi=g; } if(maxi<t){ maxi=t; } if(maxi*4>n){ printf("===\n"); return 0; } for(i=0;i<n;i++){ if(str[i]!='?'){ printf("%c",str[i]); } else{ y++; if(a!=maxi){ printf("A"); a++; } else if(c!=maxi){ printf("C"); c++; } else if(g!=maxi){ printf("G"); g++; } else if(t!=maxi){ printf("T"); t++; } else{ if(y%4==0){ printf("A"); } else if(y%4==1){ printf("C"); } else if(y%4==2){ printf("G"); } else{ printf("T"); } } } } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
75a7e0769820dca5fa51d373e61e3aec
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include <string.h> char find(int a,int g,int c,int t) { int min=a; if(g<min) min=g; if(c<min) min=c; if(t<min) min=t; if(min==a) return 'A'; else if(min==g) return 'G'; else if(min==c) return 'C'; else return 'T'; } int main() { int n,a=0,g=0,c=0,t=0,i=0; char str[260]; scanf("%d%s",&n,str); while(str[i]!='\0') { if(str[i]=='A') a++; else if(str[i]=='C') c++; else if(str[i]=='G') g++; else if(str[i]=='T') t++; i++; } i=0; if((a+g+c+t)!=n) { while(str[i]!='\0') { if(str[i]=='?') { char s=find(a,g,c,t); str[i]=s; if(s=='A') a++; else if(s=='G') g++; else if(s=='C') c++; else t++; } i++; } } if(a==g&&a==c&&a==t) printf("%s\n",str); else printf("===\n"); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
865e72511bb58631395c083666cefa3d
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int mx(int a, int b){if(a > b) return a; else return b;} int main(){ int n; scanf("%d", &n); char str[n + 1]; scanf(" %s", str); int sdiff = 0, i, a[5]; for(i = 0; i < 5; i++) a[i] = 0; for(i = 0; str[i] != '\0'; i++){ if(str[i] == 'A') a[0]++; else if(str[i] == 'G') a[1]++; else if(str[i] == 'C') a[2]++; else if(str[i] == 'T') a[3]++; else if(str[i] == '?') a[4]++; } char gen[] = {'A', 'G', 'C', 'T'}; int max = mx(mx(a[0], a[1]), mx(a[2], a[3])); for(i = 0; i < 4; i++) sdiff += max - a[i]; if(!sdiff){ if(a[4] % 4){ printf("===\n"); return 0; } int z = 0; for(i = 0; str[i] != '\0'; i++){ if(str[i] == '?'){ printf("%c", gen[z++]); if(z > 3) z = 0; } else printf("%c", str[i]); } printf("\n"); return 0; } if(a[4] < sdiff){ printf("===\n"); return 0; } if(a[4] > sdiff && (a[4] - sdiff) % 4){printf("===\n"); return 0; } int z = 0; for(i = 0; str[i] != '\0'; i++){ if(str[i] == '?'){ int j; for(j = 0; j < 4; j++) if(a[j] < max){a[j]++; break;} if(j == 4) { j = z++; if(z > 3) z = 0; } printf("%c", gen[j]); } else printf("%c", str[i]); } printf("\n"); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
ae221013f10c51ce472530c2ce0e27b8
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<stdlib.h> int main() { short n,x=0,c=0,v=0,b=0,i; scanf("%hi",&n); char *s=(char *)malloc(n+1); scanf("\n%s",s); if(n%4!=0) printf("==="); else { for(i=0;i<n;i++) { switch(s[i]) { case 'A': ++x; break; case 'T': ++c; break; case 'G': ++v; break; case 'C': ++b; break; } } if(x>n/4||c>n/4||v>n/4||b>n/4) printf("==="); else if(x==n/4&&c==n/4&&v==n/4&&b==n/4) printf("%s",s); else { i=0; while(i<n) { if(x==n/4) break; if(s[i]=='?') { s[i]='A'; ++x; } ++i; } while(i<n) { if(c==n/4) break; if(s[i]=='?') { s[i]='T'; ++c; } ++i; } while(i<n) { if(v==n/4) break; if(s[i]=='?') { s[i]='G'; ++v; } ++i; } while(i<n) { if(b==n/4) break; if(s[i]=='?') { s[i]='C'; ++b; } ++i; } printf("%s",s); } } free(s); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
cfac658658757ae29a204b06e255a0fb
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> main() { int n,i,j,t=0,a1=0,g=0,c=0; scanf("%d\n",&n); char a[n+1],b[n+1]; gets(a); if(n%4!=0) { printf("===");return 0; } for(i=0;i<n;i++) { if(a[i]=='A')a1++; if(a[i]=='G')g++; if(a[i]=='C')c++; if(a[i]=='T')t++; } if(a1>n/4||g>n/4||c>n/4||t>n/4) { printf("===");return 0; } a1=n/4-a1;g=n/4-g;c=n/4-c;t=n/4-t; for(i=0;i<n;i++) { if(a[i]=='?') { if(a1>0) { a[i]='A';(a1)--; }else if(g>0) { a[i]='G';g--; }else if(c>0) { a[i]='C';c--; }else if(t>0) { a[i]='T';t--; } } } for(i=0;i<n;i++)printf("%c",a[i]); }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
8fb98c4d858fb30ee02e6c95b54eb22e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> char cc[] = { 'A', 'C', 'G', 'T' }; int cnt[4]; void incr(char c) { int i; for (i = 0; i < 4; i++) if (cc[i] == c) { cnt[i]++; return; } } int main() { int i, j, n, yes; static char s[512]; scanf("%d", &n); scanf("%s", s); yes = 1; if (n % 4 != 0) yes = 0; for (i = 0; i < n; i++) if (s[i] != '?') incr(s[i]); for (i = 0; i < n; i++) { if (cnt[i] > n / 4) { yes = 0; break; } cnt[i] = n / 4 - cnt[i]; } for (i = j = 0; i < n; i++) { while (cnt[j] == 0) j++; if (s[i] == '?') { cnt[j]--; s[i] = cc[j]; } } printf("%s\n", yes ? s : "==="); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
b72d5d020aceb87f9f6914ed34aac7f4
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int ns,b,a,c,g,t,q,nd; void m(){ return; printf("%d\n", a); printf("%d\n", c); printf("%d\n", g); printf("%d\n", t); printf("%d\n", q); } int main(){ char s[255]; scanf("%d", &nd); scanf("%s", s); b=0; while (s[b]!='\0'){ if(s[b]=='A') a++; else if(s[b]=='C') c++; else if(s[b]=='G') g++; else if(s[b]=='T') t++; else q++; b++; } m(); ns=nd/4; if (nd%4||a>ns||c>ns|g>ns||t>ns){ printf("==="); return 0; } b=0; while (s[b]!='\0'){ if(s[b]=='?'){ if(a<ns){ s[b]='A'; a++; m(); } else if(c<ns){ s[b]='C'; c++; m(); } else if(g<ns){ s[b]='G'; g++; m(); } else if(t<ns){ s[b]='T'; t++; m(); } } b++; } printf("%s\n", s); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
b9139f918e6ec9b8a6ea976c587c1193
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include <stdio.h> #include <malloc.h> int main(int argc, char **argv) { unsigned long lengthOfGenome, runner, counts[300] = {0}; scanf("%lu", &lengthOfGenome); if( lengthOfGenome%4 != 0 ) { scanf("%*s"); printf("===\n"); return 0; } unsigned char *genome = (unsigned char*) malloc((lengthOfGenome+1)*sizeof(unsigned char)); if ( !genome ) { return -1; } scanf("%s",genome); for ( runner = 0; runner < lengthOfGenome; runner++ ) { counts[genome[runner]]++; } if ( counts['A'] > lengthOfGenome/4 || counts['C'] > lengthOfGenome/4 || counts['T'] > lengthOfGenome/4 || counts['G'] > lengthOfGenome/4 ) { printf("===\n"); return 0; } for ( runner = 0; runner < lengthOfGenome; runner++ ) { if ( genome[runner] != '?' ) { continue; } if ( counts['A'] < lengthOfGenome/4 ) { genome[runner] = 'A'; counts['A']++; } else if ( counts['C'] < lengthOfGenome/4 ) { genome[runner] = 'C'; counts['C']++; } else if ( counts['T'] < lengthOfGenome/4 ) { genome[runner] = 'T'; counts['T']++; } else { genome[runner] = 'G'; } } printf("%s\n", genome); free(genome); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
73584d9d0b7f72120a780d63ac17631d
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int main() { int n,i,a=0,c=0,t=0,g=0,x=0; char str[300]; scanf("%d",&n); scanf(" %[^\n]",str); if(n%4!=0) { printf("===\n"); return 0; } for(i=0;i<n;i++) { if(str[i]=='A') a++; else if(str[i]=='C') c++; else if(str[i]=='T') t++; else if(str[i]=='G') g++; else x++; } if(a>n/4||c>n/4||t>n/4||g>n/4) { printf("===\n"); return 0; } else { a=n/4-a; c=n/4-c; t=n/4-t; g=n/4-g; } for(i=0;i<n;i++) { if(str[i]=='?') { if(a>0) { printf("A"); //str[i]='A'; a--; } else if(c>0) { printf("C"); //str[i]='C'; c--; } else if(t>0) { printf("T"); //str[i]='T'; t--; } else if(g>0) { printf("G"); // str[i]='G'; g--; } } else printf("%c",str[i]); } /* for(i=0;i<n;i++) { printf("%c",str[i]); }*/ return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
39582d1f606c52f3cd8adda70f88cf04
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int main() { int n,i,j,t=0,a=0,g=0,c=0; scanf("%d\n",&n); char s[n+1]; gets(s); if(n%4!=0) { printf("==="); return 0; } for(i=0;i<n;i++) { if(s[i]=='A')a++; if(s[i]=='G')g++; if(s[i]=='C')c++; if(s[i]=='T')t++; } if(a>n/4||g>n/4||c>n/4||t>n/4) { printf("==="); return 0; } a=n/4-a;g=n/4-g;c=n/4-c;t=n/4-t; for(i=0;i<n;i++) { if(s[i]=='?') { if(a>0) { s[i]='A';a--; }else if(g>0) { s[i]='G';g--; }else if(c>0) { s[i]='C';c--; }else if(t>0) { s[i]='T';t--; } } } for(i=0;i<n;i++)printf("%c",s[i]); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
585693c786f38693e267362da5976fd6
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<limits.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<stdbool.h> int main() { int n; scanf("%d",&n); char a[260]; scanf("%s",a); int bucket[4]={0},q=0; for(int i=0;i<n;i++) { if(a[i]=='A') bucket[0]++; if(a[i]=='C') bucket[1]++; if(a[i]=='G') bucket[2]++; if(a[i]=='T') bucket[3]++; if(a[i]=='?') q++; } if(n%4!=0 || bucket[0]>n/4 || bucket[1]>n/4 || bucket[2]>n/4 || bucket[3]>n/4 ) { printf("===\n"); return 0; } for(int i=0;i<n;i++) { if(a[i]=='?') { if(n/4>bucket[0]) { a[i]='A'; bucket[0]++; continue; } if(n/4>bucket[1]) { a[i]='C'; bucket[1]++; continue; } if(n/4>bucket[2]) { a[i]='G'; bucket[2]++; continue; } if(n/4>bucket[3]) { a[i]='T'; bucket[3]++; continue; } } } printf("%s",a); printf("\n"); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
34080221a80015d5fe968542492ea15c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int main() { int n,i; char arr[256]; scanf("%d\n",&n); if(n%4!=0) { printf("==="); return 0; } int a=0,b=0,c=0,d=0; for(i=0;i<n;i++) { scanf("%c",&arr[i]); if(arr[i]=='A')a++;else if(arr[i]=='C')b++;else if(arr[i]=='T')c++;else if(arr[i]=='G')d++; } if(a>n/4||b>n/4||c>n/4||d>n/4) { printf("==="); return 0; } for(i=0;i<n;i++) { if(arr[i]=='?') { if(n/4-a>0) { arr[i]='A'; a++; } else if(n/4-b>0) { arr[i]='C'; b++; } else if(n/4-d>0) { arr[i]='G'; d++; } else if(n/4-c>0) { arr[i]='T'; c++; } } printf("%c",arr[i]); } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
47627fe6230e2ab090c75e2c8f79cac4
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> char value[4]={'A','C','G','T'}; int a[4]={0}; int main() { int n,i,j; scanf("%d\n",&n); char str[n+1]; gets(str); if(n%4 != 0) { printf("===\n"); return 0; } int max = n/4; for(i=0;i<n;i++) { if(str[i]=='A') { a[0]++; if(a[0]>max) { printf("===\n"); return 0; } } if(str[i]=='C') { a[1]++; if(a[1]>max) { printf("===\n"); return 0; } } if(str[i]=='G') { a[2]++; if(a[2]>max) { printf("===\n"); return 0; } } if(str[i]=='T') { a[3]++; if(a[3]>max) { printf("===\n"); return 0; } } } for(i=0;i<4;i++) { a[i]=max-a[i]; } for(i=0;i<n;i++) { if(str[i]=='?') { if(a[0]>0) { a[0]--; printf("%c",value[0]); } else if(a[1]>0) { a[1]--; printf("%c",value[1]); } else if(a[2]>0) { a[2]--; printf("%c",value[2]); } else if(a[3]>0) { a[3]--; printf("%c",value[3]); } } else { printf("%c",str[i]); } } printf("\n"); return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
1721fc7e3567761a14a0ad3650fe95f8
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int main() { int a[300],m[300],n[300],i,k,l=0,t,j,m1=0,m2=0,m3=0,m4=0,o=0,p=0,s1=0,s2=0,s3=0,s4=0,s=0,t1=0,t2=0,t3=0,t4=0; char c[300],d[300],b[300]; scanf("%d ",&t);gets(c); if(t%4!=0)printf("===\n");else{ for(i=0;i<strlen(c);i++) { if(c[i]=='A')m1++; else if(c[i]=='T')m2++; else if(c[i]=='G')m3++; else if(c[i]=='C')m4++; } n[0]=(t/4)-m1;n[1]=(t/4)-m2;n[2]=(t/4)-m3;n[3]=(t/4)-m4; for(i=0;i<strlen(c);i++) {if(l==n[0]){s=i;break;}if(c[i]=='?'){l++; c[i]='A';} } for(i=s;i<strlen(c);i++) {if(s1==n[1]){s=i;break;}if(c[i]=='?'){s1++; c[i]='T';} } for(i=s;i<strlen(c);i++) {if(s2==n[2]){s=i;break;}if(c[i]=='?'){s2++; c[i]='G';} } for(i=s;i<strlen(c);i++) {if(s3==n[3]){s=i;break;}if(c[i]=='?'){s3++; c[i]='C';} } for(i=0;i<strlen(c);i++) { if(c[i]=='A')t1++; else if(c[i]=='T')t2++; else if(c[i]=='G')t3++;else if(c[i]=='C')t4++; }if(t1==t2&&t2==t3&&t3==t4&&t4==t1)puts(c);else printf("===\n"); }}
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
bf6f7d9e274732a6b38c4da3f7be1729
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> int main() { char s[256]; int a=0,g=0,c=0,t=0,l,i,j=0,max=0,max2=0,x[256]={0}; scanf("%d",&l); scanf("%s",s); max=0; if(l%4==0 && l>=4) { for(i=0;i<l;i++) { if(s[i]=='A') { a++; if(a>max) { max=a; } } else if(s[i]=='G') { g++; if(g>max) { max=g; } } else if(s[i]=='C') { c++; if(c>max) { max=c; } } else if(s[i]=='T') { t++; if(t>max) { max=t; } } else if(s[i]=='?') { x[j]=i; j++; } } max2=l/4; if(max*4>l) { goto jump; } a=max2-a; g=max2-g; c=max2-c; t=max2-t; j=0; for(i=a;i>0;i--) { s[x[j]]='A'; j++; } for(i=g;i>0;i--) { s[x[j]]='G'; j++; } for(i=t;i>0;i--) { s[x[j]]='T'; j++; } for(i=c;i>0;i--) { s[x[j]]='C'; j++; } printf("%s",s); } else { jump: printf("==="); } return 0; }
The process of mammoth's genome decoding in Berland comes to its end!One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.
If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).
C
d6423f380e6ba711d175d91e73f97b47
29ba48089c33c19c1a7f85f28b0a25b4
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "strings" ]
1482113100
["8\nAG?C??CT", "4\nAGCT", "6\n????G?", "4\nAA??"]
NoteIn the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.In the third and the fourth examples it is impossible to decode the genom.
PASSED
900
standard input
1 second
The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome. The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.
["AGACGTCT", "AGCT", "===", "==="]
#include<stdio.h> #include<string.h> int main() { int n,c1=0,c2=0,c3=0,c4=0,i; char a[260]; scanf("%d",&n); scanf("%s",a); if(n%4!=0) printf("==="); else { for(i=0;i<n;i++) { if(a[i]=='A') c1++; if(a[i]=='G') c2++; if(a[i]=='C') c3++; if(a[i]=='T') c4++; } if(c1>n/4||c2>n/4||c3>n/4||c4>n/4) printf("==="); else { while(c1!=n/4) { for(i=0;i<n;i++) { if(a[i]=='?'){ a[i]='A'; break;} } c1++; } while(c2!=n/4) { for(i=0;i<n;i++) { if(a[i]=='?') { a[i]='G'; break; } } c2++; } while(c3!=n/4) { for(i=0;i<n;i++) { if(a[i]=='?') { a[i]='C'; break; } } c3++; } while(c4!=n/4) { for(i=0;i<n;i++) { if(a[i]=='?'){ a[i]='T'; break;} } c4++; } printf("%s",a); } } return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
f91e49258df1da9b92fa2c8642a8bb0b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int main() { int count = 0; int n, a, b, c, i; scanf("%d", &n); for(i = 0; i < n; i++) { scanf("%d %d %d", &a, &b, &c); if (a + b + c > 1) { count++; } } printf("%d", count); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
cba02c862a1376355d7b8fb4a3e194d1
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int main() { int n,output=0; scanf("%d",&n); while(n!=0) { int a,b,c; scanf("%d %d %d",&a,&b,&c); int count=0; if(a==1) count++; if(b==1) count++; if(c==1) count++; if(count>=2) output++; n--; } printf("%d",output); }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
c2a9eef0faa32aff8d26f91fe095aa91
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include <stdio.h> int main () { int n,i,a,b,c,d=0; scanf("%d",&n); for (i=0;i<n;i++){ scanf("%d %d %d",&a,&b,&c); if((a+b+c)>=2){ d++;} } printf("%d",d); }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
c5b78c57d30cc19b8e15d832bf2a6e0d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int main() { int n, p, v,i, t, solve = 0; scanf("%d",&n); for ( i = 0; i < n; i++) { scanf("%d%d%d", &p ,&v ,&t); if (p + v + t > 1) { solve++; } } printf("%d\n",solve); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
269f2eb966a0e1ab82cd91a2e69d7ed5
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include <stdio.h> int main() { int n; int Petya,Vasya,Tonya,sum,count=0,number=0; scanf("%d\n",&n); for (count=0;n>count;count++) { scanf("%d",&Petya); scanf("%d",&Vasya); scanf("%d",&Tonya); sum=Petya+Vasya+Tonya; if(sum>1) number ++; } printf("%d",number); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
21db883141baa1cce5f947902299e87d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include <stdio.h> int main(void) { // your code goes //codeforces 231A TEAM int n; int count = 0, num1, num2, num3; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d %d", &num1, &num2, &num3); if ((num1 && num2 == 1) || (num1 && num3 == 1) || (num2 && num3 == 1)) { count++; } } printf("%d\n", count); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
6d9b9193e42323b958464b0af7a003de
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
int main() { int p, v, t, n, i = 0; scanf("%d", &n); while (n--) { scanf("%d %d %d", &p, &v, &t); if (p + v + t > 1) i++; } printf("%d", i); }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
098e0cdbe354144f2bf9fb2627ceb0e2
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> main(){ int n,a,b,c,d=0; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d %d %d",&a,&b,&c); if(a+b+c>1) d++; } printf("%d",d); }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
05f78f336e552428970b6e3aab11fdb4
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int a,b,c,k=0,n,x; int main() { scanf("%d",&n); for(x=0;x<n;x++) { scanf("%d%d%d",&a,&b,&c); if((a+b+c)>1) k++; } printf("%d",k); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
3be16db068277f1d9a2d48368140582d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int main() { int n,i,a[5],sum=0,count=0; scanf("%d",&n); while(n--){ for(i=0;i<3;i++){ scanf("%d",&a[i]); } sum=0; for(i=0;i<3;i++){ if(a[i]==1) sum++; } if(sum>=2) count++; } printf("%d\n",count); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
e0191f351c3312b24b86bd6ca5b1d6dc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int main() { int n , count = 0 , sum = 0 , a[3] , i , j ; scanf("%d",&n); for(i = 0 ; i < n ; i = i + 1) { for(j = 0 ; j < 3 ; j = j + 1) { scanf("%d",&a[j]); sum = sum + a[j] ; } if(sum == 2 || sum == 3) { count = count + 1 ; } sum = 0; } printf("%d\n",count); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
c308b9c210075f7c236011617f778aad
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int main() { int n , count = 0 , sum , a , b , c, i ; scanf("%d",&n); for(i = 0 ; i < n ; i = i + 1) { scanf("%d%d%d",&a,&b,&c); if(a + b + c == 2 || a + b + c == 3) { count = count + 1 ; } } printf("%d\n",count); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
2bcd8de20597326968841258eb84e8cf
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int main() { int n , count = 0 , sum , a , b , c, i ; scanf("%d",&n); for(i = 0 ; i < n ; i = i + 1) { scanf("%d%d%d",&a,&b,&c); sum = a + b + c ; if(sum == 2 || sum == 3) { count = count + 1 ; } } printf("%d\n",count); return 0; }
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.
Print a single integer — the number of problems the friends will implement on the contest.
C
3542adc74a41ccfd72008faf983ffab5
2d74e6477b8d0077538d3971450795cb
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1349623800
["3\n1 1 0\n1 1 1\n1 0 0", "2\n1 0 0\n0 1 1"]
NoteIn the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it. In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
PASSED
800
standard input
2 seconds
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.
["2", "1"]
#include<stdio.h> int main() { int n,i,j; int a[3],s=0,count=0; scanf("%d",&n); for(i=0;i<n;i++) {s=0; for(j=0;j<3;j++) { scanf("%d",&a[j]); s=s+a[j]; } if(s>=2) count++; } printf("%d",count); return 0; }
In his spare time Vladik estimates beauty of the flags.Every flag could be represented as the matrix n × m which consists of positive integers.Let's define the beauty of the flag as number of components in its matrix. We call component a set of cells with same numbers and between any pair of cells from that set there exists a path through adjacent cells from same component. Here is the example of the partitioning some flag matrix into components: But this time he decided to change something in the process. Now he wants to estimate not the entire flag, but some segment. Segment of flag can be described as a submatrix of the flag matrix with opposite corners at (1, l) and (n, r), where conditions 1 ≤ l ≤ r ≤ m are satisfied.Help Vladik to calculate the beauty for some segments of the given flag.
For each segment print the result on the corresponding line.
C
167594e0be56b9d93e62258eb052fdc3
2ca5f2e76142093ad49eb6c3f811570b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "dsu", "graphs" ]
1495877700
["4 5 4\n1 1 1 1 1\n1 2 2 3 3\n1 1 1 2 5\n4 4 5 5 5\n1 5\n2 5\n1 2\n4 5"]
NotePartitioning on components for every segment from first test case:
PASSED
2,600
standard input
2 seconds
First line contains three space-separated integers n, m, q (1 ≤ n ≤ 10, 1 ≤ m, q ≤ 105) — dimensions of flag matrix and number of segments respectively. Each of next n lines contains m space-separated integers — description of flag matrix. All elements of flag matrix is positive integers not exceeding 106. Each of next q lines contains two space-separated integers l, r (1 ≤ l ≤ r ≤ m) — borders of segment which beauty Vladik wants to know.
["6\n7\n3\n4"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 10 #define M 100000 struct T { int *dsu; int cnt; } *tt[M * 4]; int find(int *dsu, int x) { return dsu[x] < 0 ? x : (dsu[x] = find(dsu, dsu[x])); } int join(int *dsu, int x, int y) { x = find(dsu, x); y = find(dsu, y); if (x == y) return 0; if (dsu[x] > dsu[y]) dsu[x] = y; else { if (dsu[x] == dsu[y]) dsu[x]--; dsu[y] = x; } return 1; } int aa[N][M]; int n; struct T *new_T(int l, int r) { struct T *t = malloc(sizeof *t); t->dsu = malloc((r - l) * n * sizeof *t->dsu); return t; } void build(int k, int l, int r) { struct T *t; int m, i; t = tt[k] = new_T(l, r); if (r - l == 1) { for (i = 0; i < n; i++) t->dsu[i] = -1; t->cnt = n; for (i = 1; i < n; i++) if (aa[i - 1][l] == aa[i][l]) t->cnt -= join(t->dsu, i - 1, i); return; } m = (l + r) / 2; build(k * 2 + 1, l, m); build(k * 2 + 2, m, r); t->cnt = tt[k * 2 + 1]->cnt + tt[k * 2 + 2]->cnt; memcpy(t->dsu, tt[k * 2 + 1]->dsu, (m - l) * n * sizeof *t->dsu); memcpy(t->dsu + (m - l) * n, tt[k * 2 + 2]->dsu, (r - m) * n * sizeof *t->dsu); for (i = (m - l) * n; i < (r - l) * n; i++) if (t->dsu[i] >= 0) t->dsu[i] += (m - l) * n; for (i = 0; i < n; i++) if (aa[i][m - 1] == aa[i][m]) t->cnt -= join(t->dsu, (m - l) * n + i, (m - 1 - l) * n + i); } int dsu[N + N]; int cnt; int ii[N * M], jj[N * M]; void query(int k, int l, int r, int ql, int qr) { struct T *t = tt[k]; int m, i, i_; if (qr <= l || r <= ql) return; if (ql <= l && r <= qr) { for (i = n; i < n + n; i++) dsu[i] = -1; if (ql < l) { for (i = 0; i < n; i++) { i_ = find(t->dsu, i); if (ii[i_] != -1) join(dsu, i + n, ii[i_] + n); ii[i_] = i; } for (i = 0; i < n; i++) ii[find(t->dsu, i)] = -1; for (i = 0; i < n; i++) if (aa[i][l - 1] == aa[i][l]) cnt -= join(dsu, i, i + n); } cnt += t->cnt; for (i = 0; i < n; i++) jj[find(t->dsu, i)] = find(dsu, i + n); for (i = 0; i < n; i++) dsu[i] = -1; for (i = 0; i < n; i++) { i_ = jj[find(t->dsu, (r - 1 - l) * n + i)]; if (i_ != -1) { if (ii[i_] != -1) join(dsu, i, ii[i_]); ii[i_] = i; } } for (i = 0; i < n; i++) { i_ = jj[find(t->dsu, (r - 1 - l) * n + i)]; if (i_ != -1) ii[i_] = -1; } for (i = 0; i < n; i++) jj[find(t->dsu, i)] = -1; for (i = 0; i < n; i++) { i_ = find(t->dsu, (r - 1 - l) * n + i); if (ii[i_] != -1) join(dsu, i, ii[i_]); ii[i_] = i; } for (i = 0; i < n; i++) ii[find(t->dsu, (r - 1 - l) * n + i)] = -1; return; } m = (l + r) / 2; query(k * 2 + 1, l, m, ql, qr); query(k * 2 + 2, m, r, ql, qr); } int main() { int m, q, i, j, l, r; scanf("%d%d%d", &n, &m, &q); for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &aa[i][j]); for (i = 0; i < n * m; i++) ii[i] = jj[i] = -1; build(0, 0, m); while (q-- > 0) { scanf("%d%d", &l, &r); l--; cnt = 0; for (i = 0; i < n + n; i++) dsu[i] = -1; query(0, 0, m, l, r); printf("%d\n", cnt); } return 0; }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
ccbbe968abe8781dad0e8c00e444de11
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include <stdio.h> int main() { int n,m,i, min=0, max=0, temp, people; scanf("%d%d", &n, &m); int arr[m], arr2[m]; people=n; // printf("people is %d\n" ,people); for(i=0;i<m;i++) { scanf("%d", &arr[i]); } for (i=0;i<m-1; i++) { for(int j=0; j<m-i-1; j++) { if (arr[j]>arr[j+1]) { temp= arr[j]; arr[j]= arr[j+1]; arr[j+1]= temp; } } } for(i=0;i<m;i++) { arr2[i]= arr[i]; } /* for(i=0;i<m;i++) { printf("%d ", arr[i]); } for(i=0;i<m;i++) { printf("%d ", arr2[i]); } */ for(i=0;i<m;i++) { // printf("Here"); for(; arr[i]>0 && people>0; arr[i]-- && people--) { // printf("Here too\n"); //min= (arr[i]*(arr[i]+1))/2 + min; min= min+ arr[i]; //printf(" arr[i] is %d and people is %d and min is %d \n", arr[i], people, min); } } for(people=n;people>0;people--) { for (i=0;i<m-1; i++) { for(int j=0; j<m-i-1; j++) { if (arr2[j]>arr2[j+1]) { temp= arr2[j]; arr2[j]= arr2[j+1]; arr2[j+1]= temp; } } } max=max+arr2[m-1]; arr2[m-1]--; } printf("%d %d",max, min); }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
308b5c4766fed480624be8c51adf9b79
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include<stdio.h> struct pair { int e; int i; }; int sort(int n,int *arr) { int i,j,temp; for(i=0;i<n-1;i++) for(j=0;j<n-i-1;j++) if(arr[j]>arr[j+1]) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } return 0; } struct pair maxpair(int n,int *arr) { int max=-1,maxi=-1; for(int i=0;i<n;i++) if(arr[i]!=0&&arr[i]>max) { max=arr[i];maxi=i; } struct pair r; r.e=max; r.i=maxi; return r; } int main() { int n,m; scanf("%d %d",&n,&m); int arr1[m],arr2[m]; for(int i=0;i<m;i++) { scanf("%d",&arr1[i]); arr2[i]=arr1[i]; } //for(int i=0;i<m;i++) //printf("UNSORT %d UNSORT %d\n",arr1[i],arr2[i]); //sortDescending(m,arr1); sort(m,arr2); //for(int i=0;i<m;i++) // printf("SORT %d SORT %d\n",arr1[i],arr2[i]); int max=0,min=0; int copy=n; int i=0; while(copy--) { struct pair a=maxpair(m,arr1); max+=a.e; arr1[a.i]--; } //for(i=0;i<m;i++) // printf("SORT %d SORT %d\n",arr1[i],arr2[i]); //printf("\n"); copy=n; i=0; while(copy--){ if(arr2[i]==0) i++; //printf("%d+",arr2[i]); min+=(arr2[i]--); } //printf("\n"); printf("%d %d\n",max,min); }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
d4cc8226ae2ad4f5ac9e8b0323af6d2a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include<stdio.h> #include<stdlib.h> int main() { int n,m; scanf("%d %d",&n,&m); int* A=(int*)calloc(m,sizeof(int)); int* B=(int*)calloc(m,sizeof(int)); for(int i=0;i<m;i++) { scanf("%d",A+i); B[i]=A[i]; } int max=0; int p=0; while(p!=n) { int k=A[0],pos=0; for(int i=0;i<m;i++) { if(A[i]>k) { k=A[i]; pos=i; } } max=max+k; A[pos]=A[pos]-1; p++; } int min=0; p=0; while(p!=n) { int k=max,pos=0; for(int i=0;i<m;i++) { if(B[i]<k && B[i]>0) { k=B[i]; pos=i; } } min=min+k; B[pos]=B[pos]-1; p++; } printf("%d %d",max,min); return 0; }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
11797fb5a203c7d35069f41c63911830
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include<stdio.h> int max(int arr[],int n) { int max=0; int j; for(int i=0;i<n;i++) { if(arr[i]>max) { max=arr[i]; j=i; } } return j; } int min(int arr[],int n) { int min=2000; int j; for(int i=0;i<n ;i++) { if(arr[i]<min && arr[i]>0) { min=arr[i]; j=i; } } return j; } int main () { int n,m; scanf("%d %d",&n,&m); int arr[m],arr1[m]; for(int i=0;i<m;i++) { scanf("%d",&arr[i]); arr1[i]=arr[i]; } int x=0,y=0; for(int i=0;i<n;i++) { int s=max(arr,m); x=x+arr[s]; arr[s]=arr[s]-1; } for(int i=0;i<n;i++) { int s=min(arr1,m); // printf("%d\n",arr1[s]); y=y+arr1[s]; arr1[s]=arr1[s]-1; //printf("%d\n",y); } printf("%d %d\n",x,y); }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
44fc52ae7114f24ae4a4cbb9a336f4fe
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n,m,count=0,temp; int tab[1000],tab2[1000],min=0,max=0; scanf("%d %d",&n,&m); for (int i = 0; i < m; i++) { scanf("%d",&tab[i]);count++; temp=tab[i]; if(i>0)for (int j = 0; j < count; j++) { if(tab[j]>tab[i]){ for (int k =i ; k>=j ; k--) { tab[k]=tab[k-1]; } tab[j]=temp; } } } int petit; temp=n; for (int i = 0; i <m; i++) { tab2[m-1-i]=tab[i]; } int MAXtab=0; int pos; int k=0; int i=0; int j=0; while(n){ for (k = 0; k < m ; k++) { if(tab2[k]>MAXtab){ MAXtab=tab2[k]; pos=k; } } tab2[pos]--; max+=MAXtab--; k=0; if(tab[i]!=0){ min+=tab[i]; tab[i]--; } if(tab[i]==0)i++; n--; } printf("%d %d",max,min); return 0; }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
c3421588bde2af55533a40dc224e680b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include<stdio.h> int main() { int n, m, a[1000], b[1000], i, j, t, x=0, y=0, k, z; scanf("%d %d", &n, &m); for(i=0; i<m; i++) scanf("%d", &a[i]); for(i=0; i<m; i++) { for(j=i+1; j<m; j++) { if(a[i]<a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } } } a[m]=0; for(i=0; i<m; i++) b[i]=a[i]; t=n; while(n!=0) { k = a[0]; z = 0; for(i=0; i<m; i++) { if(k<a[i]) { k=a[i]; z=i; } } x = x+k; a[z]--; n--; } for(i=m-1; i>=0; i--) { while(b[i]!=0 && t!=0) { y=y+b[i]; b[i]--; t--; } } printf("%d %d", x, y); return 0; }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
47e827ccffd77c40287fa069ba3129e0
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include<stdio.h> void mergesort(int arr[], int l, int r) { if (l < r) { int m = l+(r-l)/2; mergesort(arr, l, m); mergesort(arr, m+1,r); merge(arr, l, m, r); } } void merge(int arr[], int l, int m, int r) { int i, j, k; int n1 = m - l + 1; int n2 = r - m; int L[n1], R[n2]; for (i = 0; i < n1; i++) L[i] = arr[l + i]; for (j = 0; j < n2; j++) R[j] = arr[m + 1+ j]; i = 0; j = 0; k = l; while (i < n1 && j < n2) { if (L[i] >= R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } k++; } while (i < n1) { arr[k] = L[i]; i++; k++; } while (j < n2) { arr[k] = R[j]; j++; k++; } } void mergesortt(int arr[], int l, int r) { if (l < r) { int m = l+(r-l)/2; mergesortt(arr, l, m); mergesortt(arr, m+1,r); mergee(arr, l, m, r); } } void mergee(int arr[], int l, int m, int r) { int i, j, k; int n1 = m - l + 1; int n2 = r - m; int L[n1], R[n2]; for (i = 0; i < n1; i++) L[i] = arr[l + i]; for (j = 0; j < n2; j++) R[j] = arr[m + 1+ j]; i = 0; j = 0; k = l; while (i < n1 && j < n2) { if (L[i] <= R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } k++; } while (i < n1) { arr[k] = L[i]; i++; k++; } while (j < n2) { arr[k] = R[j]; j++; k++; } } int main() { int n,m,max=0,min=0; scanf("%d%d",&n,&m); int ar[m],br[m]; for(int i=0;i<m;i++) { scanf("%d",&ar[i]); br[i]=ar[i]; } /*if(m==1) max=n*(n+1)/2; else*/ { mergesort(ar,0,m-1); /*for(int i=0;i<m;i++) printf("%d ",ar[i]);*/ int i=0,cnt=0,r=0,temp=0,g=0; while(ar[i+1]<ar[i]) { cnt++; max+=ar[i]; ar[i]--; if(cnt==n) break; } if(cnt!=n) { temp=ar[0]; while(g==0) { for(int k=0;k<m;k++) { if(k==m-1) { temp=ar[m-1]; r=m-1; } else { if(ar[k]<ar[0]) { temp=ar[k]; r=k; break; } } } if(temp==ar[m-1]&&temp==ar[0]) { while(g==0) { for(int i=0;i<m;i++) { max+=ar[i]; ar[i]--; cnt++; if(cnt==n) { g=1; break; } } /*for(int i=0;i<m;i++) printf("%d ",ar[i]); printf("\n");*/ } } else { //printf("t%d\n",temp); int j=0; while(g==0&&ar[0]>temp) { for( j=0;j<r;j++) { cnt++; max+=ar[j]; ar[j]--; if(cnt==n) { g=1; break; } } } //i++; /* for(int i=0;i<m;i++) printf("%d ",ar[i]); printf("\n");*/ } } }//cnt! // printf("%d",max); } int f=0,scnt=0; mergesortt(br,0,m-1); for(int i=0;i<m&&f==0;i++) { while(br[i]) { scnt++; min+=br[i]; br[i]--; if(scnt==n) { f=1; break; } } } printf("%d %d",max,min); /*if(ar[0]%2==0||ar[n-1]%2==0) printf("%s","NO"); else { if(n%2!=0) printf("%s","YES"); else printf("%s","NO"); }*/ return 0; }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
4652fe5e672d7adf502bd1a563ed99a6
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include <stdio.h> 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; i++) L[i] = arr[l + i]; for (j = 0; j < n2; j++) R[j] = arr[m + 1+ j]; /* Merge the temp arrays back into arr[l..r]*/ i = 0; // Initial index of first subarray j = 0; // Initial index of second subarray k = l; // Initial index of merged subarray while (i < n1 && j < n2) { if (L[i] <= R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } k++; } /* Copy the remaining elements of L[], if there are any */ while (i < n1) { arr[k] = L[i]; i++; k++; } /* Copy the remaining elements of R[], if there are any */ while (j < n2) { arr[k] = R[j]; j++; k++; } } /* l is for left index and r is right index of the sub-array of arr to be sorted */ void mergeSort(int arr[], int l, int r) { if (l < r) { // Same as (l+r)/2, but avoids overflow for // large l and h int m = l+(r-l)/2; // Sort first and second halves mergeSort(arr, l, m); mergeSort(arr, m+1, r); merge(arr, l, m, r); } } int main() { int n , m; int arr[1000],arr2[1000]; scanf("%d %d",&n,&m); for(int i =0;i<m;i++) { scanf("%d",&arr[i]); arr2[i]=arr[i]; } mergeSort(arr,0,m-1); mergeSort(arr2,0,m-1); int max=0,min=0; for(int i =1;i<=n;i++) { max+=arr[m-1]; arr[m-1]-=1; mergeSort(arr,0,m-1); } int q = 0; for(int i =1;i<=n;i++) { if(arr2[q]<=0) q+=1; min+=arr2[q]; arr2[q]-=1; } printf("%d %d",max,min); return 0; }
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x &gt; 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.
Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.
C
6dea4611ca210b34ae2da93ebfa9896c
d3d4f80e5ab41414ca832f38aa1a306d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1345273500
["4 3\n2 1 1", "4 3\n2 2 2"]
NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd plane, the 3-rd person — to the 3-rd plane, the 4-th person — to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 1-st plane, the 3-rd person — to the 2-nd plane, the 4-th person — to the 2-nd plane.
PASSED
1,100
standard input
2 seconds
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.
["5 5", "7 6"]
#include <stdio.h> #include <stdlib.h> int cmp1 (const void * a, const void * b){ return (*(int*)b - *(int*)a); } int cmp2 (const void * a, const void * b){ return (*(int*)a - *(int*)b); } int main(){ int n, m; scanf("%d %d", &n, &m); int i, x[1000], y[1000], min = 0, max = 0, p = n; for(i = 0; i < m; ++i){ scanf("%d", &x[i]); y[i] = x[i]; } qsort(x, m, sizeof(int), cmp1); qsort(y, m, sizeof(int), cmp2); for(i = 0; i < n; ++i){ max += x[0]; x[0]--; if(y[0] > 0){ min += y[0]; y[0]--; } else { y[0] = 100000; min += y[1]; y[1]--; } qsort(x, m, sizeof(int), cmp1); qsort(y, m, sizeof(int), cmp2); } printf("%d %d\n", max, min); }
Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has $$$n$$$ positions to install lamps, they correspond to the integer numbers from $$$0$$$ to $$$n - 1$$$ on the OX axis. However, some positions are blocked and no post lamp can be placed there.There are post lamps of different types which differ only by their power. When placed in position $$$x$$$, post lamp of power $$$l$$$ illuminates the segment $$$[x; x + l]$$$. The power of each post lamp is always a positive integer number.The post lamp shop provides an infinite amount of lamps of each type from power $$$1$$$ to power $$$k$$$. Though each customer is only allowed to order post lamps of exactly one type. Post lamps of power $$$l$$$ cost $$$a_l$$$ each.What is the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment $$$[0; n]$$$ of the street? If some lamps illuminate any other segment of the street, Adilbek does not care, so, for example, he may place a lamp of power $$$3$$$ in position $$$n - 1$$$ (even though its illumination zone doesn't completely belong to segment $$$[0; n]$$$).
Print the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment $$$[0; n]$$$ of the street. If illumintaing the entire segment $$$[0; n]$$$ is impossible, print -1.
C
6f26747e5ed41d6eb1bfcef48a2dc46d
efe7d3b4ddba084a8adcbed36b736715
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1528625100
["6 2 3\n1 3\n1 2 3", "4 3 4\n1 2 3\n1 10 100 1000", "5 1 5\n0\n3 3 3 3 3", "7 4 3\n2 4 5 6\n3 14 15"]
null
PASSED
2,100
standard input
2 seconds
The first line contains three integer numbers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^6$$$, $$$0 \le m \le n$$$) — the length of the segment of the street Adilbek wants to illuminate, the number of the blocked positions and the maximum power of the post lamp available. The second line contains $$$m$$$ integer numbers $$$s_1, s_2, \dots, s_m$$$ ($$$0 \le s_1 &lt; s_2 &lt; \dots s_m &lt; n$$$) — the blocked positions. The third line contains $$$k$$$ integer numbers $$$a_1, a_2, \dots, a_k$$$ ($$$1 \le a_i \le 10^6$$$) — the costs of the post lamps.
["6", "1000", "-1", "-1"]
#include <stdio.h> #define MAX_PLACES 1000000 #define MAX_LAMPS 1000000 typedef long long int int64; int point[MAX_PLACES]; int costs[MAX_LAMPS]; int64 min(int64 a, int64 b) { return a < b ? a : b; } int64 max(int64 a, int64 b) { return a > b ? a : b; } int64 GetCost(int n, int power, int cost) { int64 total_cost = cost; int index = power; while (index < n) { total_cost += cost; index = point[index] + power; } return total_cost; } int64 Solve(int n, int k, int max_blocked) { int64 min_cost = -1; int i; for (i = max_blocked; i < k; ++i) { int64 cost = GetCost(n, i + 1, costs[i]); if (cost != -1) { min_cost = (min_cost == -1) ? cost : min(min_cost, cost); } } return min_cost; } int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); int i; for (i = 0; i < m; ++i) { int pos; scanf("%d", &pos); point[pos] = -1; } if (point[0] == -1) { printf("-1\n"); return 0; } int max_blocked = 0; int blocked = 0; for (i = 1; i < n; ++i) { if (point[i] == 0) { point[i] = i; blocked = 0; } else { point[i] = point[i - 1]; blocked += 1; } max_blocked = max(max_blocked, blocked); } for (i = 0; i < k; ++i) { scanf("%d", &costs[i]); } int64 res = Solve(n, k, max_blocked); printf("%I64d\n", res); return 0; }
Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has $$$n$$$ positions to install lamps, they correspond to the integer numbers from $$$0$$$ to $$$n - 1$$$ on the OX axis. However, some positions are blocked and no post lamp can be placed there.There are post lamps of different types which differ only by their power. When placed in position $$$x$$$, post lamp of power $$$l$$$ illuminates the segment $$$[x; x + l]$$$. The power of each post lamp is always a positive integer number.The post lamp shop provides an infinite amount of lamps of each type from power $$$1$$$ to power $$$k$$$. Though each customer is only allowed to order post lamps of exactly one type. Post lamps of power $$$l$$$ cost $$$a_l$$$ each.What is the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment $$$[0; n]$$$ of the street? If some lamps illuminate any other segment of the street, Adilbek does not care, so, for example, he may place a lamp of power $$$3$$$ in position $$$n - 1$$$ (even though its illumination zone doesn't completely belong to segment $$$[0; n]$$$).
Print the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment $$$[0; n]$$$ of the street. If illumintaing the entire segment $$$[0; n]$$$ is impossible, print -1.
C
6f26747e5ed41d6eb1bfcef48a2dc46d
16864688358bcb4bcfb5ffd7a81acaaa
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "brute force" ]
1528625100
["6 2 3\n1 3\n1 2 3", "4 3 4\n1 2 3\n1 10 100 1000", "5 1 5\n0\n3 3 3 3 3", "7 4 3\n2 4 5 6\n3 14 15"]
null
PASSED
2,100
standard input
2 seconds
The first line contains three integer numbers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^6$$$, $$$0 \le m \le n$$$) — the length of the segment of the street Adilbek wants to illuminate, the number of the blocked positions and the maximum power of the post lamp available. The second line contains $$$m$$$ integer numbers $$$s_1, s_2, \dots, s_m$$$ ($$$0 \le s_1 &lt; s_2 &lt; \dots s_m &lt; n$$$) — the blocked positions. The third line contains $$$k$$$ integer numbers $$$a_1, a_2, \dots, a_k$$$ ($$$1 \le a_i \le 10^6$$$) — the costs of the post lamps.
["6", "1000", "-1", "-1"]
/* upsolve with Dukkha */ #include <stdio.h> #define N 1000000 #define INF ((long long) 2e12) int aa[N], pp[N], qq[N]; int count(int n, int p) { int i, cnt = 0; for (i = 0; i < n; ) if (aa[i] == 0) { cnt++; i += p; } else { if (pp[i] + qq[i] - 1 >= p) return -1; i -= pp[i]; } return cnt; } int main() { int n, m, k, i, p; long long min; scanf("%d%d%d", &n, &m, &k); while (m--) { scanf("%d", &i); aa[i] = pp[i] = qq[i] = 1; } if (aa[0]) { printf("-1\n"); return 0; } for (i = 1; i < n; i++) if (pp[i]) pp[i] += pp[i - 1]; for (i = n - 2; i >= 0; i--) if (qq[i]) qq[i] += qq[i + 1]; min = INF; for (p = 1; p <= k; p++) { int a, cnt; long long c; scanf("%d", &a); cnt = count(n, p); if (cnt >= 0 && min > (c = (long long) a * cnt)) min = c; } printf("%lld\n", min == INF ? -1 : min); return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
a05cdb2451375a162b1c38cd4e956669
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { char s[1000000], pilha[1000000]; int i, topo = 0, count = 0; scanf(" %s", s); for(i = 0; i < strlen(s); i++){ if(s[i] == '[' || s[i] == '(' || s[i] == '{' || s[i] == '<'){ pilha[topo++] = s[i]; } else { if(topo == 0){ printf("Impossible"); return 0; } if(s[i] == '}' && pilha[topo-1] == '{' || s[i] == ')' && pilha[topo-1] == '(' || s[i] == ']' && pilha[topo-1] == '[' || s[i] == '>' && pilha[topo-1] == '<'){ topo--; } else { count++; topo--; } } } if(topo != 0){ printf("Impossible"); return 0; } printf("%i", count); return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
181cf1dd4ef33a40496efc514cb893d1
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
#include <stdio.h> #include <string.h> int main(){ char aberto[1000000]; int FilaAberto,FilaFechado; int ordem,i,j,tam,ok; char formula[1000000]; int a,b; scanf(" %s",formula); tam = strlen(formula); ok = 1; ordem = 0; if(tam%2==1){ printf("Impossible"); } else{ FilaAberto = 0; for(i=0;i<tam;i++){ if(formula[i]=='[' || formula[i]=='(' || formula[i]=='<' || formula[i]=='{'){ aberto[FilaAberto] = formula[i]; FilaAberto++; } else{ if(FilaAberto==0){ ok = 0; printf("Impossible"); break; } else{ if(formula[i]=='}' && aberto[FilaAberto-1]=='{' || formula[i]==']' && aberto[FilaAberto-1]=='[' || formula[i]=='>' && aberto[FilaAberto-1]=='<' || formula[i]==')' && aberto[FilaAberto-1]=='('){ FilaAberto--; } else{ FilaAberto--; ordem++; } } } } if(FilaAberto>0){ ok = 0; printf("Impossible"); } if(ok){ printf("%d",ordem); } } return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
decadb50bde5b1b0565f2c3f8d1104dd
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
/* بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ */ /* رَّبِّ زِدْنِى عِلْمًا */ #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <ctype.h> #define OUTPUT freopen("myfile.txt","w",stdout); #define INPUT freopen("input.txt","r",stdin); #define pi acos(-1.0) #define MAX 1000005 int main() { char inp[MAX]; int len,i,cnt,test; while(scanf("%s",inp)!=EOF) { len=strlen(inp); test=1; cnt=0; for(i=0;i<len;i++) { if(inp[i]=='(') inp[i]=1; else if(inp[i]==')') inp[i]=-1; else if(inp[i]=='[') inp[i]=2; else if(inp[i]==']') inp[i]=-2; else if(inp[i]=='{') inp[i]=3; else if(inp[i]=='}') inp[i]=-3; else if(inp[i]=='<') inp[i]=4; else if(inp[i]=='>') inp[i]=-4; } //for(i=0;i<len;i++) // printf("%d",inp[i]); //printf("\n"); //for(i=0;i<len;i++) // printf("%c",inp[i]); //printf("\n"); char stack[MAX]={0,}; int top=0; for(i=0;i<len;i++) { if(inp[i]>0) { stack[top++]=inp[i]; } else { if(top==0) test=0; else if(stack[top-1]==abs(inp[i])) { top--; } else if(stack[top-1]*inp[i]<0) { cnt++; top--; } else if(stack[top-1]*inp[i]>0) { test=0; } } } if(top!=0) test=0; if(test==0) printf("Impossible\n"); else printf("%d\n",cnt); } return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
519dc74e9a7f5649f2d52cfa13318495
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <stdbool.h> #include <time.h> #define SIZE 1000002 struct Node { long key; struct Node *next; }; typedef struct Node Node; void push(Node **Stack, long x) { Node *temp = malloc(sizeof *temp); temp -> next = *Stack; temp -> key = x; *Stack = temp; } long pop(Node **Stack) { Node *temp; long x = -1; if (*Stack != NULL) { temp = *Stack; x = temp -> key; *Stack = (*Stack) -> next; free(temp); } return x; } /*****************************************************************************/ int main(void) { Node *Stack = NULL; char s[SIZE]; long i, j, k, m, n, c; scanf("%s", s); bool error = false; i = 0; k = 0; while (s[i] != '\0' && !error) { switch (s[i]) { case '(': case '[': case '{': case '<': push(&Stack, s[i]); break; case ')': case ']': case '}': case '>': c = pop(&Stack); if (c == -1) { error = true; } else { if ((c == '(' && s[i] == ')') || (c == '[' && s[i] == ']') || (c == '{' && s[i] == '}') || (c == '<' && s[i] == '>')) { ++k; } } break; default: break; } ++i; } if (!error && Stack == NULL) { m = i / 2 - k; printf("%ld\n", m); } else { while (Stack != NULL) { pop(&Stack); } printf("Impossible\n"); } return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
f23441cc5ef88f29cff6401ba749d097
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
#include <stdio.h> #include <string.h> int cast(char ch) { if (ch=='[') return 1; if (ch==']') return -1; if (ch=='(') return 2; if (ch==')') return -2; if (ch=='{') return 3; if (ch=='}') return -3; if (ch=='<') return 4; if (ch=='>') return -4; } int main() { int i,j,n,ans=0,t=0; char a[1001000]; int b[1001000]; scanf("%s",&a); for (i=0; i<strlen(a); i++) { int now = cast(a[i]); if (now>0) { t++; b[t] = now; } else { now *= -1; if (b[t] != now) ans++; t--; if (t == -1) { printf("Impossible\n"); return 0; } } //for (j=1; j<=t; j++) printf("%d %d\n",j,b[j]); } if (t>0) printf("Impossible\n"); else printf("%d\n", ans); return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
06aafac57d63669aa015ce58c28325e1
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
#include <stdio.h> #include <string.h> int main(void) { char seq[1000005]; char temp; int j=0; int ans=0; for(;;) { if(scanf("%c", &temp)==-1 || temp=='\n') { break; } if(temp=='(' || temp=='<' || temp=='[' || temp=='{') { seq[j]=temp; j++; } else { j--; if(j<0) { break; } if((temp==')'&&seq[j]=='(') || (temp=='>'&&seq[j]=='<') || (temp==']'&&seq[j]=='[') || (temp=='}'&&seq[j]=='{')) { } else { ans++; } } } if(j!=0) { printf("Impossible"); return 0; } printf("%d", ans); return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
d49239f7fbfd38e52aab251fb65e936f
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
#include "stdio.h" #include "stdlib.h" char Openings[] = { '{' , '<' , '(' , '[' }; char Closings[] = { '}' , '>' , ')' , ']' }; int IsOpening( char cToken ) { int i; for( i = 0 ; i < sizeof(Openings) ; i++ ) { if( cToken == Openings[i] ) return 1; } return 0; } int IsPair( char cOpen , char cClose ) { int i; for( i = 0 ; i < sizeof(Openings) ; i++ ) { if( cOpen == Openings[i] ) { if( cClose == Closings[i] ) { return 1; } } } return 0; } int main() { int i; int iReplaceCount = 0; char * pInStr = NULL; char * pStackStr = NULL; char * pStackPointer = NULL; pInStr = (char * )malloc( 1000000 ); pStackStr = (char * )malloc( 1000000 ); scanf( "%s" , pInStr ); i = 0; pStackPointer = pStackStr; for( i = 0 ; pInStr[i] != '\0' ; i++ ) { // check opening or closing if( IsOpening( pInStr[i] ) == 1 ) { *pStackPointer = pInStr[i]; //printf("Push %c \n", pInStr[i] ); pStackPointer++; } else { if( pStackPointer == pStackStr ) { printf("Impossible"); return 0; } //if( *(pStackPointer -1) != pInStr[i] ) if( IsPair( *(pStackPointer -1) , pInStr[i] ) == 0) { // printf("%c != %c\n", *(pStackPointer -1), pInStr[i] ); iReplaceCount++; } pStackPointer--; } }// for( i = 0 ; pInStr[i] != '\0' ; i++ ) if( pStackPointer != pStackStr ) printf("Impossible"); else printf("%d",iReplaceCount); return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
32df8a135908388bc0d713437515c0b6
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
#include<stdio.h> //#include<conio.h> #include<string.h> char brackets[1000005]; int tos,need; void push(char c){ brackets[tos]=c; tos++; } void pop(char c){ if(tos==0){ need=-1; return; } if(c==brackets[tos-1]){ brackets[tos-1]='\0'; tos--; } else{ need++; tos--; } } int main(){ int i,l; char str[1000005]; gets(str); l=strlen(str); for(i=0;i<l;i++){ if(str[i]=='<' ||str[i]=='('||str[i]=='{'||str[i]=='['){ push(str[i]); } else{ if(str[i]=='>') pop('<'); else if(str[i]==')') pop('('); else if(str[i]=='}') pop('{'); else pop('['); } if(need==-1) break; } if(tos!=0 || need==-1){ printf("Impossible\n"); } else{ printf("%d\n",need); } // getch(); return 0; }
You are given string s consists of opening and closing brackets of four kinds &lt;&gt;, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace &lt; by the bracket {, but you can't replace it by ) or &gt;.The following definition of a regular bracket sequence is well-known, so you can be familiar with it.Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings &lt;s1&gt;s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.For example the string "[[(){}]&lt;&gt;]" is RBS, but the strings "[)()" and "][()()" are not.Determine the least number of replaces to make the string s RBS.
If it's impossible to get RBS from s print Impossible. Otherwise print the least number of replaces needed to get RBS from s.
C
4147fef7a151c52e92c010915b12c06b
7e96ba442985acc1f721a77b9e5d3c34
GNU C
standard output
256 megabytes
train_001.jsonl
[ "data structures", "math", "expression parsing" ]
1451055600
["[&lt;}){}", "{()}[]", "]]"]
null
PASSED
1,400
standard input
1 second
The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.
["2", "0", "Impossible"]
#include<stdio.h> #include<stdlib.h> int main(){ char sinal; char Pilha[1000001]; int topo=-1; int cont=0,erro=0; scanf("%c",&sinal); while (sinal!='\n'&& erro==0) { if(sinal=='{'||sinal=='['||sinal=='<'||sinal=='('){ topo++; Pilha[topo]=sinal; } else{ if(Pilha[topo]+2==sinal||Pilha[topo]+1==sinal){ topo--; } else{ topo--; cont++; } } if(topo<-1){ erro++; } scanf("%c",&sinal); } //ja chequei o topo agora falta checar se o topo é 0 ou n if(topo>=0||topo<-1||erro>0){ printf("Impossible\n"); } else{ printf("%d\n",cont); } return 0; }