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
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers:...
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters. It is guaranteed that ...
C
6587be85c64a0d5fb66eec0c5957cb62
f8b1e597c4e24bd3a00be3dcb9b1908e
GNU C
standard output
256 megabytes
train_003.jsonl
[ "dfs and similar" ]
1337182200
["3\npair pair int int int", "1\npair int"]
null
PASSED
1,500
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 105), showing how many numbers the type dictated by Gena contains. The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes). It is guaranteed that the total number of words does not exceed 105 and that a...
["pair<pair<int,int>,int>", "Error occurred"]
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef char* element; typedef struct node { element data; int to_add; struct node *left; struct node *right; struct node *parent; }one_node; typedef one_node *tree_t; void make_null_tree(tree_t *tree) { *tree = NULL; } tree_t create_node(eleme...
You are given a string $$$s$$$. You can build new string $$$p$$$ from $$$s$$$ using the following operation no more than two times: choose any subsequence $$$s_{i_1}, s_{i_2}, \dots, s_{i_k}$$$ where $$$1 \le i_1 &lt; i_2 &lt; \dots &lt; i_k \le |s|$$$; erase the chosen subsequence from $$$s$$$ ($$$s$$$ can become e...
Print $$$T$$$ answers — one per test case. Print YES (case insensitive) if it's possible to build $$$t$$$ and NO (case insensitive) otherwise.
C
e716a5b0536d8f5112fb5f93ab86635b
14c2833fee1486d75cbf42a3bb49aa94
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "strings" ]
1581518100
["4\nababcd\nabcba\na\nb\ndefi\nfed\nxyz\nx"]
null
PASSED
2,200
standard input
2 seconds
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$2T$$$ lines contain test cases — two per test case. The first line contains string $$$s$$$ consisting of lowercase Latin letters ($$$1 \le |s| \le 400$$$) — the initial string. The second line contains string ...
["YES\nNO\nNO\nYES"]
#include <stdio.h> #include <string.h> #define N 400 #define M 400 int max(int a, int b) { return a > b ? a : b; } int solve(char *aa, int n, char *b1, int m1, char *b2, int m2) { static int dp[N + 1][M + 1]; int i, j1; for (i = 0; i <= n; i++) for (j1 = 0; j1 <= m1; j1++) dp[i][j1] = -1; dp[0][0] = 0; fo...
You are given a string $$$s$$$. You can build new string $$$p$$$ from $$$s$$$ using the following operation no more than two times: choose any subsequence $$$s_{i_1}, s_{i_2}, \dots, s_{i_k}$$$ where $$$1 \le i_1 &lt; i_2 &lt; \dots &lt; i_k \le |s|$$$; erase the chosen subsequence from $$$s$$$ ($$$s$$$ can become e...
Print $$$T$$$ answers — one per test case. Print YES (case insensitive) if it's possible to build $$$t$$$ and NO (case insensitive) otherwise.
C
e716a5b0536d8f5112fb5f93ab86635b
5d97e1154e8febbcb34cc9ca3c1567b8
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "strings" ]
1581518100
["4\nababcd\nabcba\na\nb\ndefi\nfed\nxyz\nx"]
null
PASSED
2,200
standard input
2 seconds
The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$2T$$$ lines contain test cases — two per test case. The first line contains string $$$s$$$ consisting of lowercase Latin letters ($$$1 \le |s| \le 400$$$) — the initial string. The second line contains string ...
["YES\nNO\nNO\nYES"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_N 400 int nTest; int n; int m; char a[MAX_N + 9]; char b[MAX_N + 9]; int f[2][MAX_N + 9][MAX_N + 9]; int main() { scanf("%d", &nTest); for(int iTest = 1; iTest <= nTest; iTest++) { scanf("%s", a + 1); scanf("%s", b + 1); n = strlen(a + 1); ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
4ebb1e833fa0dbefc9eda683c5747fef
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define maxn 10000 //�����ַ�����s���±�Ϊa���±�Ϊb������Ԫ�� void swap( char *s,int a,int b){ char temp; temp=s[a]; s[a]=s[b]; s[b]=temp; } //�ж���������Ϊlenth���ַ������Ƿ���� int isEqual(char *s, char *t,int lenth){ int i=0; int flag=1; ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
cd9893bab9be8681b6b23a08c2c9b1b6
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int n,i,j,k,count=0,ara[30]={0},ara1[30]={0},ara2[10004]; scanf("%d",&n); char s1[200000],s2[200000],temp; scanf("%s",s1); scanf("%s",s2); for(i=0;i<n;i++) { ara1[s2[i]-'a']+=1; ara[s1[i]-'a']+=1; } ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
7b72b64f461a69fdba502bd676b88738
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<string.h> long long m,count,i,j,k,arr[10000],n,store; char name[10000],a,name1[10000]; int main() { scanf("%lld",&n); scanf("%s",name); scanf("%s",name1); m=0; count=0; if(strcmp(name,name1)==0) { printf("0\n"); } else{ for(i=0;i<n;i++) { ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
23c17e95280e1d73090bcd00b4ebf7dc
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<string.h> int main() { int n; scanf("%d",&n); char s[n+1],s1[n+1]; scanf("%s",s); scanf("%s",s1); int i,a[100000],k=0,j,q=0,u,p,d=0; char t; int b[30]={0},c[30]={0}; for(i=0;i<n;i++) { b[s[i]-'a']++; c[s1[i]-'a']++; } for(i=0;i<=26;i++) { if(b[i]!=0&&c[i]!=0) { if(b[i...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
1b572b6463826bad8c2f09d69abb9bec
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> int main() { int length; scanf("%d", &length); char string[100] = {}, tring[100] = {}; scanf("%s%s", string, tring); int valid = 1, changeNum = 0, changes[10000] = {}; for (int i = 0; i < length; i++) if (string[i] != tring[i]) { int end; for (end = i; end < length; end++) if (st...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
cbf5c18d5f442ace2c3b97c45c18aba0
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> int main() { char s[51], t[51]; int i, j, len, move[10000+1], movecount=-1, flag, temp, fflag; scanf("%d", &len); scanf("%s", s); scanf("%s", t); for(i=0; i<len; i++) { if(s[i]==t[i]) continue; flag=0; fflag=1; for(j=i+1; j<l...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
a1d203b57d0520f2270dc6b1a3b214a7
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<stdlib.h> int main(void) { int i,l,j,m,n,swap,index =0; char s1[60]; char s2[60]; int swp[10001]; scanf("%d\n",&n); scanf("%s\n%s",s1,s2); for(i=0;i<n;i++) { while(s1[i]==s2[i]) { if(i==n-1) { printf("%d\n",index); for(m=0;m<index;m++) { ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
a2943d68024303b34a45c3b57095d0de
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> int main(void) { // your code goes here int n,i,j,count=0,a[10001],x=0; scanf("%d",&n); char s[n+1],t[n+1],k; scanf("%s\n",s); scanf("%s",t); for(i=0;i<n;i++) { if(s[i]==t[i]) { continue; } else { for(j=i+1;j<n;j++) ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
50bacf2e042acb1bce42638bf34b626a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <stdlib.h> int war(const void*a, const void*b) { if(*(char*)a>*(char*)b)return(1); return(-1); } int main() { char s[100], t[100], ss[100], tt[100], c; int n, i, j, x, a[10000], r=0; scanf("%d%s%s", &n, s, t); for(i=0; i<n+2; i++) { ss[i]=s[i]; ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
9b8d8d9800840ae0aaef77f1c55651df
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> int main (void) { int n; while(scanf("%d", &n)!=EOF) { int count = 0; int arc = 0; char s[51]; int get[25000]; char t[51]; char sign1[26] = {0}; char sign2[26] = {0}; scanf("%s",s); scanf("%s",t); int i,j,k; for(i = 0; i < n; i++) { sign1[s[i] - 'a']++; sign2[t[i] - ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
c4b76f7a8cc41ab8f40b649da88a38c9
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <string.h> int main() {int n,i,j,pos,a[100000],b[30]={0},c[30]={0},q=0,k=0,u,d=0; char m; scanf("%d",&n); char s[n+1],t[n+1]; scanf("%s",s); scanf("%s",t); for(i=0;i<n;i++) { b[s[i]-'a']++; c[t[i]-'a']++; } for(i=0;i<=26;i++) { if(b[i]!=0&&c[i]!=0) { if(b[i]==c[i]) q++; }...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
2c24100d4ba30693612aaca98b69036d
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> int main(){ int n, ans[10001]={0}, ia=0; char s[100], t[100]; scanf("%d\n", &n); fgets(s, 100, stdin); fgets(t, 100, stdin); for(int i=0; i<n; i++){ //printf("s=%st=%s\n", s,t); if(s[i] != t[i]){ int j; char next, pre, tmp; ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
c3bb93f8f712678600ad47e33b2edd77
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <stdlib.h> #include <string.h> void swap (char *a, char *b) { char tmp = *a; *a = *b; *b = tmp; } typedef struct node { int key; struct node *prev; struct node *next; } node_t; int main (void) { int n; scanf ("%d", &n); char *s = calloc (n + 1, sizeof (...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
c1d52b02b883a1d5484b484e53e9df37
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <malloc.h> short box1[26] = {0}; short box2[26] = {0}; int main() { short i; for(i = 0; i < 26; ++i) { box1[i] = 0; box2[i] = 0; } short n; scanf("%hd", &n); ++n; char *s = malloc(n*sizeof(char)); char *t = malloc(n*sizeof(char)); --n; scanf("%s%s", s, t); for(i = 0; i < n; ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
bd15ab62f31e5df9d2baa27a68032c51
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <memory.h> int main (void) { int n; while(scanf("%d", &n)!=EOF) { int count_num = 0; int arc = 0; char s[51]; int get[250000]; char t[51]; char sign1[26]; char sign2[26]; memset(sign2,0,26); memset(sign1,0...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
d0246bb2ff6e1052c16bb19eac2ebab5
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <string.h> int main() { int i, j, n, move[10002], cnt = 0, k = 0; for (i = 0; i < 10002; i++) { move[i] = 0; } char temp = 'a'; scanf("%d", &n); char ara1[n + 1], ara2[n + 1]; scanf("%s", ara1); scanf("%s", ara2); for (i = 0; i < n; i++) { ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
2a7af63758bc5d009c9f06661c795658
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<string.h> main() { int n,record[100000],p=0,i,k=0,cnt=0,j; char s[100],t[100],temp; scanf("%d",&n); scanf("%s",s); scanf("%s",t); for(i=0;i<n;i++) { if(s[i]!=t[i]) { p=i+1;cnt=0; while(1) { ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
7227622c9787077494c137803f8fa4be
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <string.h> int n; char s[102], t[102]; int action1[5000], action2[5000]; int mysort(char *arr, int *action) { int i,j, r=0; for (i=1;i<n;i++){ // insert arr[i] for (j=i;j>0;j--){ if (arr[j] < arr[j-1]) { char t = arr[j-1]; ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
fc56d1bb04d44a5aa6b481eb90f5a8c8
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define N 200001 int main(void){ int n; char s[100],t[100],c; int i,j,k,p=0; int a[N]; scanf("%d",&n); scanf("%s",s); scanf("%s",t); for(i=0;i<n;i++){ if(t[i]==s[i]) continue; c='0'; for(j=i+1;j<n;j++){ if(t[i]==s[j]){ c='...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
8dfbd64887b5159581cc30fd77122358
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<string.h> int cmp( const void *a , const void *b ) { const char *c = (char *)a; const char *d = (char *)b; return *c-*d; } int main(){ int n;scanf("%d",&n); char s[n],t[n],ss[n],tt[n];int i,j=0,k=0,q;char temp; int sum[10005]={0}; getchar(); for(i=0;i<n;i++){ scanf("%c",&s[i])...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
ef07192379cc88035b8507da9dafc7fb
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<string.h>//注意strcmp和strncmp的区别 //这种方法在结尾加上了\0且改为了strcmp 但是第二十五组过不去 int cmp( const void *a , const void *b ) { const char *c = (char *)a; const char *d = (char *)b; return *c-*d; } int main(){ int n;scanf("%d",&n); char s[n+1],t[n+1],ss[n+1],tt[n+1];int i,j=0,k=0,q;char temp; in...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
42cb9edc4357f4e75b2a90422ab87a0d
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> int main() { int n, j, arr[26]={0} ,arr1[26]={0} ,i, moves=0, movecount[5000]={0} ; char s[52],t[52],key; scanf("%d",&n); scanf("%s\n%s",s,t); for(i=0;i<n;i++) { arr[s[i]-'a']++; arr1[t[i]-'a']++; } for(i=0;i<26;i++) if(arr[i]!=arr1[i]) {...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
921836f4ba22bdb4d34f594ef334d12b
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> int main() { char s[51], t[51]; int i, j, k, n, stk[2500], sp = 0; scanf("%d%s%s", &n, s, t); k = 0; for (i = 0 ; i < n ; i++) { for (j = 0 ; j < n ; j++) { if (s[j] == t[i]) { t[i] = s[j] = k++; break; } } if (j == n) { printf("-1"); return 0; } } for (i = n - ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
6b4f71ed668d2bb53c66327813756c1c
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int cmp(const void *a,const void *b) { return *(int *)a - *(int *)b; } int max(int a,int b) { if(a>b) return a; return b; } long long int min(long long int a,long long int b) { if(a<b) return a; return b; } int mod(int a) { if(a<0) ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
ea926189b936aa715155b0cb145ea131
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<string.h> int main(){ int n; while(scanf("%d",&n)==1){ char s[100],t[100],st[100],tt[100]; scanf("%s",s); scanf("%s",t); strcpy(st,s); strcpy(tt,t); for(int i=0;i<n-1;++i){ for(int j=i+1;j<n;++j){ if(st[i]>st[j]){ char temp=st[i]; st[i]=st[j]; st[j]=temp; ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
63ad801ef94311d068d10c713ed1c24c
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> #include <stdlib.h> #define max 57 #define Max 10007 void swap(char *a, char *b) { char temp; temp = *a; *a = *b; *b = temp; } int main() { int count = 0, n, j, i, move[Max], fa[26], fb[26], pos; char a[max], b[max]; scanf("%d", &n); scanf("%s %s", a, b); for(i = 0; i < 26; i++...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
0289c81feb084fae26e8749c8643fefc
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> int main() { int n; char s[55]; char t[55]; char tmp; int i; int j; int m; int moves[2600]; int k=0; scanf("%d",&n); scanf("%s",s); scanf("%s",t); for (i=n-1;i>=0;i--) { if (t[i]==s[i]) continue; if (i==0) { printf("-1\n"); return 0; }; /* find t[i] in s */ for (j=i-1;j>=0...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
87d737b1c9050a3c0175afa8e4a59fb2
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include <stdio.h> int main() { int i, j, tr=0,k, in=0,num, impsbl=0, cnt=0, ar[10005]; char t[60], s[60],tmp; scanf("%d ",&num); gets(s); gets(t); for (i=0;t[i];i++){ tr=0; if (t[i]!=s[i]){ for (j=i+1;s[j];j++){ if (tr==1) break; if (t[i]==s[j]){ tr=1; while (t[i]!=s[i]){ ...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
8c07a065758722ba7eae75605d1958b6
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> #include<string.h> int as[30],bs[30]; int main(void){ int n; char a[100],b[100]; scanf("%d",&n); scanf("%s",&a); scanf("%s",&b); memset(as,0,sizeof(as)); memset(bs,0,sizeof(bs)); for(int i=0;i<n;i++){ as[a[i] - 'a']++; bs[b[i] -...
You are given two strings $$$s$$$ and $$$t$$$. Both strings have length $$$n$$$ and consist of lowercase Latin letters. The characters in the strings are numbered from $$$1$$$ to $$$n$$$.You can successively perform the following move any number of times (possibly, zero): swap any two adjacent (neighboring) characters...
If it is impossible to obtain the string $$$t$$$ using moves, print "-1". Otherwise in the first line print one integer $$$k$$$ — the number of moves to transform $$$s$$$ to $$$t$$$. Note that $$$k$$$ must be an integer number between $$$0$$$ and $$$10^4$$$ inclusive. In the second line print $$$k$$$ integers $$$c_j$$$...
C
48e323edc41086cae52cc0e6bdd84e35
b982abf03e1067cdf3f94ddad1b6b30a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1533047700
["6\nabcdef\nabdfec", "4\nabcd\naccd"]
NoteIn the first example the string $$$s$$$ changes as follows: "abcdef" $$$\rightarrow$$$ "abdcef" $$$\rightarrow$$$ "abdcfe" $$$\rightarrow$$$ "abdfce" $$$\rightarrow$$$ "abdfec".In the second example there is no way to transform the string $$$s$$$ into the string $$$t$$$ through any allowed moves.
PASSED
1,200
standard input
1 second
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of strings $$$s$$$ and $$$t$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of $$$n$$$ lowercase Lat...
["4\n3 5 4 5", "-1"]
#include<stdio.h> int x[26]; void swp(char x[51],int X) { char temp; temp=x[X]; x[X]=x[X-1]; x[X-1]=temp; } int main() { int i,n,ans[10001],flag=1; for(i=0;i<26;i++) { x[i]=0; } char s1[51],s2[51]; scanf("%d%s%s",&n,s1,s2); for(i=0;i<n;i++) { x[s1[i]-'a']++; x[s2[i]-'a']--; } for(i=0;i<26;i++) { ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
eac6c3257e1f64f44d17c3eb7c2df3cd
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include<stdio.h> #include<stdlib.h> typedef unsigned u; int F(const void*x,const void*y){return*(int*)x-*(int*)y;} char A[222222],N[222222];u Ai,Ni; u S[222222],M[222222]; int main() { scanf("%s%s",A,N); for(Ai=-1;A[++Ai];); for(Ni=-1;N[++Ni];); u i,j,k,lo,hi,mi; for(i=-1;++i<Ai;--S[i])scanf("%u",S+i); lo=Ni-1;h...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
327135e7b817d52b910eaf6014bdd14f
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#ifdef ONLINE_JUDGE #define NDEBUG 1 #endif #include <assert.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <stdbool.h> #include <limits.h> #include <math.h> #define long int64_t #define fore(i,k,n) for (int _k = (k), _n = (n), i = _k; i <= _n; ++i) #define forr(i,n,k) f...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
9dcbe062059bac000baacb1eff3d2fd3
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
/* Codeforces Round #402 (Div.1). Problem A - String Game, by Abreto <m@abreto.net>. */ #include <stdio.h> #include <string.h> #define MAXS 200001 int lt = 0, lp = 0; char p[MAXS] = {0}, t[MAXS] = {0}; int a[MAXS] = {0}; int remainders[MAXS] = {0}; int nremainders = 0; int check(void) { int i = 0, j = 0; ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
f562cfbe060f43fbd67633cf39c20d1c
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include<stdio.h> #include<stdlib.h> #include<string.h> char ip[1000000]; char sub[1000000]; int per[1000000]; char temp[1000000]; int check(int x,int y) { int count=0; int i=0,j=0; int flag=0; while( i<x) { if (temp[i]==sub[j]) { count++; //printf("%d\n",count ); j++; } if (count==y)//y =sublen ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
1b578d6a34adc6fe6b7ec50e3732f2e9
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include <stdio.h> #include <string.h> char s[200001]; char p[200001]; int a[200001]; int flag[200001]={0}; int l,l2; int main() { scanf("%s",s); scanf("%s",p); l=strlen(s); l2=strlen(p); int i,b,j; for(i=0;i<l;i++) { scanf("%d",&b); a[b-1]=i; } int low=0; int up=l; int mid; while(low<=up) { mid=(up...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
4e13d3fb5080525616b1f142ff60bbfb
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include <stdio.h> #include <string.h> char s[200001]; char p[200001]; int a[200001]; int flag[200001]={0}; int l,l2; int main() { scanf("%s",&s); scanf("%s",&p); l=strlen(s); l2=strlen(p); int i,b,j; for(i=0;i<l;i++) { scanf("%d",&b); a[b-1]=i; } int low=0; int up=l; int mid; while(up-low>1) { mid=...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
46e3d6ecd35687854675f2f09ef0e89c
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include <stdio.h> #include <string.h> char P[200001]; char T[200001]; char Backup[200001]; int A[200001]; int Check(int idx) { memcpy(Backup, T, sizeof(T)); for(int i = 0; i <= idx; ++i) { Backup[A[i] - 1] = ' '; } int len = 0; for(int i = 0; Backup[i]; ++i) { if(Backup[i] != ' ')...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
7dc20d00172601f51244d26e760fb0b7
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include<stdio.h> #include<string.h> int substringf(int stringl, int substringl,int index1[],char substring[],char string[]) { int i,j; i=1; j=1; for(i=1;i<=stringl;i++) { if(index1[i]==1) { if(string[i]==substring[j]) { j++; if(j>substringl) return 0; //make mid answer and chagne the range...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
98fbac8e4866d04127801bca71558849
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include<stdio.h> #include<string.h> int fn(int bl[], char S[], char s[], int n) { int i, j=0; for(i=0;i<n;i++) { if(S[i]==s[j]&&bl[i+1]==1) { j++; } if(j==strlen(s)) { return 1; } } return 0; } void fn2(int bl[], int mid, int n, int a[]) { int i; for(i=1;i<=n;i++) { if(i<=mid) { bl[a[i...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
ab648bd062a83a756480c6c42a98135b
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include<stdio.h> #include<string.h> int fn(int bl[], char S[], char s[], int n) { int i, j=0; for(i=0;i<n;i++) { if(S[i]==s[j]&&bl[i+1]==1) { j++; } if(j>=strlen(s)) { return 1; } } return 0; } void fn2(int bl[], int mid, int n, int a[]) { int i; for(i=1;i<=n;i++) { if(i<=mid) { bl[a[i...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
44288150b54bd600759f5467bd61eb2d
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include <stdio.h> #include <string.h> /* * Returns whether string `p` is a subsequence of string `t` with characters skipped at positions for which * corresponding booleans in `t_removed_positions` are set * * Time complexity: O(|p| + |t|) */ int is_a_subsequence(char* p, char* t, int* t_removed_positions) { ...
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain or...
Print a single integer number, the maximum number of letters that Nastya can remove.
C
0aed14262c135d1624df9814078031ae
263cddefffe151ff370e95a59a8d80d5
GNU C
standard output
512 megabytes
train_003.jsonl
[ "binary search", "greedy", "strings" ]
1488096300
["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5"]
NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba" "ababcba" "ababcba" "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.
PASSED
1,700
standard input
2 seconds
The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| &lt; |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter ...
["3", "4"]
#include<stdio.h> #include<string.h> int a[2000005]; int check (char s[],char t[]) { int k=strlen(t); int i; int l=0; int count=0; for(i=0; t[l]!='\0' && s[i]!='\0' ;i++) { if(t[l]==s[i]) { count++; l++; } } if(count==k) return 1; else return 0; } int main() { int i,...
Note that this is the second problem of the two similar problems. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems.You are given a tree with $$$n$$$ nodes. In the beginning, $$$0$$$ is written on all edges. In one operation, you can choose any $$$2$$$ dist...
If there aren't any sequences of operations which lead to the given configuration, output "NO". If it exists, output "YES" in the first line. In the second line output $$$m$$$ — number of operations you are going to apply ($$$0 \le m \le 10^5$$$). Note that you don't have to minimize the number of the operations! In th...
C
0ef40ec5578a61c93254149c59282ee3
86b9b7dceb3272e9439d5d8d2c068685
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation", "dfs and similar", "trees" ]
1562339100
["5\n1 2 2\n2 3 4\n3 4 10\n3 5 18", "6\n1 2 6\n1 3 8\n1 4 12\n2 5 2\n2 6 4"]
NoteThe configuration from the first sample is drawn below, and it is impossible to achieve. The sequence of operations from the second sample is illustrated below.
PASSED
2,500
standard input
1 second
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$) — the number of nodes in a tree. Each of the next $$$n-1$$$ lines contains three integers $$$u$$$, $$$v$$$, $$$val$$$ ($$$1 \le u, v \le n$$$, $$$u \neq v$$$, $$$0 \le val \le 10\,000$$$), meaning that there is an edge between nodes $$$u$$$ and $...
["NO", "YES\n4\n3 6 1\n4 6 3\n3 4 7\n4 5 2"]
/* practice with Dukkha */ #include <stdio.h> #define N 1000 int oo[1 + (N - 1) * 2], oh[1 + (N - 1) * 2]; int link(int o, int h) { static int _ = 1; oo[_] = o, oh[_] = h; return _++; } int ij[N - 1], ww[N - 1]; int ae[N], dd[N], l1[N], l2[N]; void dfs1(int p, int i) { int o; l1[i] = l2[i] = i; for (o = ae...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
ca9facb1436fccb248d0ea1a1d05c4a3
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include<stdio.h> #include<math.h> int main() { int n; scanf("%d",&n); while(n--) { long long m,x; int j; scanf("%I64d",&x); m=sqrt(x); for(j=2;j*j<=m;j++) { if(m%j==0) break; } if(m*m==x && j*j>m && x!=1) ...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
d880705385fde51bc63aee7703427360
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include<stdio.h> #include<math.h> long long int x[100000]; int arr[1000001]; long long int perfect(long long int n) { long long int a=pow(n,0.5)+0.5; if(a*a==n) return a; else return 0; } int sieve(long int n) { long int j; for(long int i=2;i*i<=n;i++) { if(arr[i]==0) { j=i*i; while(j<=n) { if(arr[j]==0) arr[j]=1; j+...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
9b95ce5519a8ed2ca2ea5fcbf37b4a81
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include<stdio.h> #include<math.h> long long int x[100000]; int arr[1000001]; long long int perfect(long long int n) { long long int a=pow(n,0.5)+0.5; if(a*a==n) return a; else return 0; } int sieve(int n) { int j; for(int i=2;i*i<=n;i++) { if(arr[i]==0) { j=i*i; while(j<=n) { if(arr[j]==0) arr[j]=1; j+=i; } } } retur...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
717f39a31f7c82b9a89872a16c02ba5c
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
/* ID: mohamma73 LANG: C TASK: crypt1 */ #include"stdio.h" #include"stdlib.h" #include"ctype.h" #include"math.h" #include"string.h" struct step{ int a; int bonus; }; struct card{ int a[50]; int b[50]; int na; int nb; }; int getword(char *s,int n){ int i; char c; while(isspace(c=getchar())); for(i=0;i<n && !i...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
afae35b836cccc36dc4064547f053c35
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include <stdio.h> #include <stdlib.h> #include <math.h> int p (long long int k) { int c=1; register long long int l=sqrtl(k); long long int m; for(m=2;m<=l;m+=c) { if(k%m==0){return 0;} if(m==3){c=2;} } return 1; } int main() { long long int n; scanf("%I64d",&n); ...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
9e19d0ce780d5ee1953ad488d1a2ca08
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include<stdio.h> #include<math.h> int main() { int p[1000001]={0}; int i,j,test; long long int n,x; scanf("%d",&test); p[1]=1; for(i=2;i*i<1000000;i++) { if(p[i]==0) { for(j=2*i;j<=1000000;j+=i) { p[j]=1; } } } while(test) { scanf("%lld",&n); x=sqrt(n); if((x*x==n)&&(p[x]==0)) { ...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
95ec1d8e3e1135fdc23cd71cd1e391f3
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include<stdio.h> #include<math.h> int main() { long long i, n, a, b; scanf("%I64d", &n); while( n-- ) { scanf("%I64d", &a); b = sqrt(a*1.0); for( i = 2; i*i <= b; i++) { if( b%i ==0) break; } if(i*i>b && b*b==a && a>1) printf("YES\n"); else printf("NO\n"); } return 0; }
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
2e4130f79349028fe3cfa0ad3c89a619
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include <stdio.h> #include <math.h> int main() { int t,i,j; short primes[1000001]={0}; for (i=2;i<1001;i++) { if (primes[i]==0) { for (j=i*i;j<1000001;j+=i) { primes[j]=1; } } } scanf("%d",&t); while(t--) { long long int sqr,i; long long int n; scanf("%lld",&n); sqr = sqrt(n); if (n==1) ...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
698625654d3e66cd0ea1250cdec2eaa1
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include<stdio.h> #include<math.h> #define SIZE 1000001 int arr[1000001]; int main(void) { long long i,j,n,num; arr[2]=1; for(i=3;i<SIZE;i+=2) arr[i]=1; for(i=3;i*i<SIZE;i+=2) { if(arr[i]) { for(j=3*i;j<SIZE;j+=2*i) arr[j]=0; } } scanf("%lld",&n); ...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
732998d96856f0ea24138a00c03fcaf5
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include<stdio.h> #include<math.h> int IsPrime(int x ) { if(x<=1) return 1; if(x==2) return 2; if(x%2==0) return 1; long long sRoot = sqrt(x*1.0); long long p; for( p=3; p<=sRoot; p+=2) { if(x%p==0) return 1; } return 2; } int mai...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
e8becf172ea3b6de5e113ee6b9497b3a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include<stdio.h> #include<math.h> main() { long long n,a,i; scanf("%lld",&n); while(n--) { int ok=0; scanf("%lld",&a); if(a%2==0 || a==1) { if(a==4) printf("YES\n"); else printf("NO\n"); } else { long long y=sqr...
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
C
6cebf9af5cfbb949f22e8b336bf07044
bdab84408a666688ec8ee3c68a9d61f0
GNU C
standard output
256 megabytes
train_003.jsonl
[ "binary search", "number theory", "implementation", "math" ]
1349105400
["3\n4 5 6"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
PASSED
1,300
standard input
2 seconds
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
["YES\nNO\nNO"]
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> #define MAXARR 1000000 bool is_prime[MAXARR]; void create_Eratosthenes(); int main() { create_Eratosthenes(); int n, i; long long int arr[MAXARR]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%I64d", &arr[i]); } for (i =...
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
C
d50bb59298e109b4ac5f808d24fef5a1
55d23413d2d3191bb1775ddf370e80fd
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation", "greedy", "math" ]
1479632700
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
PASSED
1,700
standard input
1 second
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
["2\n4 2", "2\n7 11"]
/* practice with Dukkha */ #include <stdio.h> #define N 200000 int main() { static char cc[N + 1]; static int ll[N], rr[N]; int n, a, b, k, p, i, c; scanf("%d%d%d%d%s", &n, &a, &b, &k, cc); k = 0; c = 0; for (p = -1, i = 0; i <= n; i++) if (i == n || cc[i] == '1') { ll[k] = p + 1; rr[k] = i - 1; c ...
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
C
d50bb59298e109b4ac5f808d24fef5a1
6806d2e1e3066b7992b921c9cb1d7a1f
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation", "greedy", "math" ]
1479632700
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
PASSED
1,700
standard input
1 second
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
["2\n4 2", "2\n7 11"]
#include<stdio.h> #include<stdlib.h> typedef unsigned u; char S[222222];u Q[222222],Qi; int main() { u n,a,b,i,j,k; scanf("%u%u%u%u%s",&n,&a,&b,&k,S); for(i=-1,j=0;++i<n;) { //printf("!%u \'%c\' %u\n",i,S[i],j); if(S[i]=='1')j=0; else if(++j==b) {Q[Qi++]=i;j=0;} //printf(">%u \'%c\' %u\n",i,S[i],j); } p...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
91dac79060ee7235c4268cb5aa14bf6e
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include<stdio.h> int main() { int n,m,i,i1,i2,u,d=-1,l,r=-1,num_B=0,ans; char map[100][101]; scanf("%d%d",&n,&m); getchar(); for(i=0;i<n;i++) { scanf("%s",&map[i][0]); getchar(); } for(i1=0,u=n,l=m;i1<n;i1++) for(i2=0;i2<m;i2++) if(map[i1][i2]=='B') { if(i1<u) u=i1; if(i2<l) l=i2; if(i1>d) d=i...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
b9d2522f574c6e76ed928778ad469df7
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include <stdio.h> #include <string.h> #include <math.h> int min( int a, int b ); int max( int a, int b ); int main( void ) { int n, m; int i, j; char matrix[105][105]; int row_min, row_max, col_min, col_max; while ( scanf("%d%d", &n, &m) != EOF ) { memset( matrix, 0, sizeof(matrix)...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
16e1465193ac8eaad23f6815e76ed1c8
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include<stdio.h> int main(void) { int N,M,Count,Counter,Left=-1,Right=-1,Top=-1,Bottom=-1,Black=0,White=0,Length,Width; char E[5]; scanf("%d%d",&N,&M); gets(E); char Board[N][M+1]; for(Count=0;Count<N;Count++) for(Counter=0;Counter<=M;Counter++) { scanf("%c",&Board[...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
f1e2ffd297142a2f1e275e0793d057d4
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include <stdio.h> #define MAX(a, b) ((a > b) ? a : b) int main(){ int n, m, i, j; int first_row = -1, last_row = -1, first_col = -1, last_col = -1, am = 0; scanf("%d %d", &n, &m); char a[n][m+1]; for(i = 0; i < n; i++){ scanf("%s", a[i]); for(j = 0; j < m; j++){ if(a[i][j] == 'B'){ if...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
1d67ceb2c04c39a93875cf9838ad5829
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int n,m,i,j,p,q,r,s,c; scanf("%d", &n); scanf("%d", &m); char a[1000][1000]; c=0; for(i=1;i<n+1;i++) { for(j=1;j<m+1;j++) { scanf(" %c", &a[i][j]); if(a[i][j]=='B') ...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
f6de02f7cff5893fbc1f101cb00e83c0
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include<stdio.h> int main() { int r,c,flag=0; scanf("%d%d",&r,&c); int t=10000,l=10000,ri=0,b=0,i,j,count = 0; char st[r][c]; for(i=0;i<r;i++) scanf("%s",st[i]); for(i=0;i<r;i++) { for(j=0;j<c;j++) { if(st[i][j] == 'B') { flag = 1;count++; if(i < t) t=i; if(i > b) b=i; if(j < l) l=...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
bc4b7d7a2c0d837f13fbc990d8051e83
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include <stdio.h> #define MAX 100 int get_black(int s[MAX][MAX], int tx, int bx, int ly, int ry) { int s1 = s[bx][ry]; int s2 = (ly - 1 < 0) ? 0 : s[bx][ly-1]; int s3 = (tx - 1 < 0) ? 0 : s[tx-1][ry]; int s4 = (ly - 1 < 0 || tx - 1 < 0) ? 0 : s[tx-1][ly-1]; return s1 - s2 - s3 + s4; } int main() { char a[MAX...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
c6f6c51cdf810984eccfa8c4c8ebdc89
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include <stdio.h> int main() { unsigned char n,m,min_n=0,min_m=0,max_n=0,max_m=0,temp_n=0,temp_m=0; int b=0,nb=0; char c; scanf("%d %d%c",&n,&m,&c); for(int i=0;i<n;i++) { temp_m=0; do { c=getchar(); temp_m++; if(c=='B') {...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
c648a01072edf04e54f05165e353965c
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include<stdio.h> #include<string.h> #include<limits.h> int main() { int n,m,i,j; char a[105][105]; int count=0; int minx=INT_MAX,miny=INT_MAX; int maxx=0,maxy=0; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) { for(j=0;j<=m;j++) { scanf("%c",&a[i][j]); if(a[i][j]=='B') { count++; if(i>maxy) m...
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.You are to determine the minimum possible nu...
Print the minimum number of cells needed to be painted black so that the black cells form a black square with sides parallel to the painting's sides. All the cells that do not belong to the square should be white. If it is impossible, print -1.
C
cd6bc23ea61c43b38c537f9e04ad11a6
a5b4c0d01b6b454a712ad0889fa7729a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "implementation" ]
1499791500
["5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW", "1 2\nBB", "3 3\nWWW\nWWW\nWWW"]
NoteIn the first example it is needed to paint 5 cells — (2, 2), (2, 3), (3, 2), (3, 3) and (4, 2). Then there will be a square with side equal to three, and the upper left corner in (2, 2).In the second example all the cells are painted black and form a rectangle, so it's impossible to get a square.In the third exampl...
PASSED
1,300
standard input
1 second
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the sizes of the sheet. The next n lines contain m letters 'B' or 'W' each — the description of initial cells' colors. If a letter is 'B', then the corresponding cell is painted black, otherwise it is painted white.
["5", "-1", "1"]
#include<stdio.h> #include<string.h> int main(){ int n,m,i,j; int s,x,z,y,bn=0; s=110;x=0;z=110;y=0; char a[110][110]; scanf("%d %d",&n,&m); for(i=1;i<=n;i++){ getchar(); for(j=1;j<=m;j++){ scanf("%c",&a[i][j]); if(a[i][j]=='B'){ if(i<s)s=i; if(i>x)x=i; if(j<z)z=j; if(j>y)y=j; bn++; ...
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements f0 and f1 are arbitrary fn + 2 = fn + 1 + fn for all n ≥ 0. You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements...
Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.
C
98348af1203460b3f69239d3e8f635b9
062cfa58f6be5aa89f76ab411086b3b7
GNU C11
standard output
512 megabytes
train_003.jsonl
[ "dp", "hashing", "math", "implementation", "brute force" ]
1456506900
["3\n1 2 -1", "5\n28 35 7 14 21"]
NoteIn the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.In the second sample, the optimal way to rearrange elements is , , , , 28.
PASSED
2,000
standard input
3 seconds
The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai. The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).
["3", "4"]
/* practice with Dukkha */ #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #define N 1000 #define M 100000 #define MD 0x7fffffff struct L { struct L *next; int key, val; } *mp[M]; long long X; int rand_(int n) { return (rand() * 76543LL + rand()) % n; } void init_rand() { struct timeval tv; gett...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
2dfa38a5370b5f15a5deae03f9993ce0
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> #ifdef DEBUG # define LOG(...) printf (__VA_ARGS__) #else # define LOG(...) #endif typedef struct vehicle { int n; int cap; } VEHICLE; int compare_vehicle (const void *a, const void *b) { return ((const VEHICLE*)b)->cap - ((const VEHICLE*)a)->cap; } VEHICLE kayak[100000];...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
e6f9d7b9651aee1c49f975c9749df72c
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include<stdio.h> #include<stdlib.h> void merge(int **w,int l,int r); void ms(int **w,int l,int r) { if(l<r) { ms(w,l,(l+r)/2); ms(w,((l+r)/2)+1,r); merge(w,l,r); } } void merge(int **w,int l,int r) { int l1,l2,j=0,k=0,i,t; int **a,**b; l2=r-((l+r)/2); l1=((l+r)/2)+1-l; a=(int**)calloc(l1,sizeof(int*)); ...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
bb9e74cf3230aeab608c41a3ed1c7008
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <string.h> #include <stdlib.h> void quicksort(int x[],int first,int last,int y[]){ int pivot,j,temp,i; if(first<last){ pivot=first; i=first; j=last; while(i<j){ while(x[i]>=x[pivot]&&i<last) i++; while(x[j]<x[pivot]) j--; if(i<j){ temp=x[i]; x[i]=x[j]; ...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
33534a689e801030af92ad138f720da1
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> struct boat{ int val; int pos; }; int compare(const void *a, const void *b) { struct boat *A = (struct boat*)a; struct boat *B = (struct boat*)b; return A->val - B->val; } int main() { int n,v,i,tmp,k=0,c=0,filled=0; scanf("%d %d", &n, &v); struct boat kayak[n], cat[n]...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
d0c150a4b2c40402486479c2b46fec00
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> struct boat{ int val; int pos; }; int compare(const void *a, const void *b) { struct boat *A = (struct boat*)a; struct boat *B = (struct boat*)b; return A->val - B->val; } int main() { int n,v,i,tmp,k=0,c=0,filled=0; scanf("%d %d", &n, &v); struct boat kayak[n+1], cat[...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
4e4e9abdf713eeaafb7189c5ed855eb5
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> #define KAY 1 #define CAT 2 #define MAXN 100000 struct rec { int type; int cap; int idx; }; struct rec kay[MAXN]; int kaynum = 0; struct rec cat[MAXN]; int catnum = 0; int n, v, i, t, p, ki, ci, ans = 0; int get_cap(struct rec a[], int len, int idx) { if (idx >= len) ret...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
f84b51efb6d3b0b436959be29051555d
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include<stdio.h> #include<stdlib.h> #include<math.h> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) void intSort(int d[],int s){int i=-1,j=s,k,t;if(s<=1)return;k=(d[0]+d[s-1])/2;for(;;){while(d[++i]<k);while(d[--j]>k);if(i>=j)break;t=d[i];d[i]=d[j];d[j]=t;}intSort(d,i);intSort(d+j+1,s-j-1);} void int...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
cdb335ebc3034cbafc508ee67d056d3c
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include<stdio.h> #include<stdlib.h> #include<math.h> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) void intSort(int d[],int s){int i=-1,j=s,k,t;if(s<=1)return;k=(d[0]+d[s-1])/2;for(;;){while(d[++i]<k);while(d[--j]>k);if(i>=j)break;t=d[i];d[i]=d[j];d[j]=t;}intSort(d,i);intSort(d+j+1,s-j-1);} void int...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
3682c65fc3f7dc006572a28fe3e5fa37
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ int t; int p; int pos; double r; }Vehicle; Vehicle V[100000]; int cmp(const void *a, const void *b){ if (((Vehicle*)a)->r <= ((Vehicle*)b)->r) return 1; else return -1; } int main() { int n, v, i, j, pos1, pos, d, dt, total; scanf("...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
61abc9d142ed5bbb6cca71b39803f7fd
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> typedef struct{ int p, i; } veh; veh ks[100005], cs[100005]; int acc_k[100005], acc_c[100005]; int cmp(const veh *a, const veh *b){ if(a->p > b->p) return -1; if(a->p < b->p) return 1; return 0; } int main(){ int n, vol; scanf("%d%d", &n, &vol); ...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
ffc1db11a00219d5cc34d01ab57e4081
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> #define min(a,b) a<b? a:b typedef struct Boat Boat; struct Boat { int cap; int id; }; int kSum[100010]; int rSum[100010]; Boat kayaks[100010]; Boat rans[100010]; int cmp(const void* a, const void* b) { return ((Boat*)b)->cap - ((Boat*)a)->cap; } int main() { in...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
e665e33f6662357dd7486b80a3a1f904
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> #define MAXN 100050 int n, m, nk, nb, kat[MAXN], bai[MAXN], numsb[MAXN], numsk[MAXN]; void readinp() { int i, t, p; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) { scanf("%d%d", &t, &p); if (t == 1) { numsb[nb] = i + 1; ...
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.
C
a1f98b06650a5755e784cd6ec6f3b211
83cf7992d19f1bc6e6154e677cef5366
GNU C
standard output
64 megabytes
train_003.jsonl
[ "sortings", "greedy" ]
1267963200
["3 2\n1 2\n2 7\n1 3"]
null
PASSED
1,900
standard input
2 seconds
The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi...
["7\n2"]
#include <stdio.h> #include <stdlib.h> typedef struct { char type; int capacity; int inputIndex; }VehicleSt; //冒泡,降序 void bubbleSort(VehicleSt *array, int length) { int i, j; VehicleSt temp; for(j=0; j<length-1; j++) { for(i=0; i < length-j-1; i++) { if(array[i...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
9848776bf209c6e3dceb85d4437cc53e
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include<stdio.h> #define MX 500001 long long int n,A[MX],ans; int main(){ //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); long long int i,x,j; scanf("%lld",&n); for(i=0;i<n;i++){scanf("%lld",&A[i]);} for(i=0;i<n;i++){A[i+n]=A[i];} x=A[0]; for(i=0;i<n;i++){if(x>A[i]...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
e987bad0f0e443f4944d5f3e02f7f1c5
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include <stdio.h> int main() { unsigned int n, temp, i, firstPos, lastPos, maxLen, min = 0xFFFFFFFF; long long int result; // зчитати кількість кольорів в n scanf("%u", &n); // зчитати кількості літрів кожного кольору, // знайти мінімальну з них та максимальну відстань між // баночками з однаковими мінімальн...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
8b40c6a4efe0a77a9701234500ca9765
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include<stdio.h> #include<conio.h> int main(){ int n , i, j,first_index =0 , last_index=0; scanf("%d",&n); long long a[n] , min = 1000000001 , num = 0,max = 0,max1=0; for(i=0;i<n;i++){ scanf("%lld",&a[i]); if(a[i] < min){ min = a[i]; first_index = i; last_index = i; ...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
ede1c9637e1bc04f699af3c59efd681c
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include<stdio.h> int main() { int n; long long temp; long long sum; long long first; long long len,lenf,mlen,value; int i; while(scanf("%d",&n)!=EOF) { value=-1; len=0; mlen=0; for(i=0;i<n;i++) { scanf("%I64d",&temp); if(temp<value||value==-1) { value=temp; lenf=i; } if(temp==v...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
ed4b8b3b01c10f8bb8c43e17d1a9a0ef
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include <stdio.h> #include <stdlib.h> int main() { int arr[200001],small; int n,i,j,first,last,diff,prev; long long ans=1; scanf("%d",&n); small= 1000000002; for (i=0; i<n; i++) { scanf("%d", &arr[i]); if (arr[i] < small) small = arr[i]; } first=-1; prev=-1; last=-1; diff=0; for (i=0; i<n; i++) { ...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
3d5e2586f2f9aea7a5b76490f154aed8
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
/* https://codeforces.com/contest/610/submission/20287326 (rainboy) */ #include <stdio.h> #define N 200000 #define INF 1000000001 int main() { static int aa[N]; int n, i, i_, min, max, cnt; scanf("%d", &n); min = INF; for (i = 0; i < n; i++) { scanf("%d", &aa[i]); if (min > aa[i]) { min = aa[i]; i_ = ...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
b4c7f2f1052e9f99a23c6894248eb567
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include <stdio.h> #include <stdlib.h> int main(){ long long int n; long long int arr[200001]={0}; scanf("%I64d",&n); long long int i; for(i=0;i<n;i++)scanf("%I64d",&arr[i]); long long int first=0,last=-1; long long int min=arr[first]; long long int len=0; long long int max=0; f...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
84bb5b9127a65b49aef42b0b50476cf5
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include<stdio.h> #include<stdlib.h> int main() { long long int n,s=0,i,min=1e9,l,r,max,c=0; scanf("%lld",&n); long long int ara[n]; for(i=0; i<n; i++) { scanf("%lld",&ara[i]); if(ara[i]<min) min=ara[i]; } s=n*min; l=0; while(ara[l]>min&&l<n) { ...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
a306edae7e2324ebecdc8fa45a9e360e
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include<stdio.h> int main() { long long int n,a[200001],i,m=1000000001,b[200001],max=0,x=0; scanf("%lld",&n); for(i=1;i<=n;i++) {scanf("%lld",&a[i]); if(m>a[i]) {m=a[i];} } for(i=1;i<=n;i++) {if(a[i]==m) {x++; b[x]=i; } } for(i=1;i<=x-1;i++) {if((b[i+1]...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
3fecce38c7e69532460906983cdbe135
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include<stdio.h> int main() { long long n,s=0,i,min=1e9,l,r,max,c=0; scanf("%lld",&n); long long ara[n]; for(i=0; i<n; i++) { scanf("%lld",&ara[i]); if(ara[i]<min) min=ara[i]; } s=n*min; l=0; while(ara[l]>min&&l<n) { c++; l++; } ...
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will st...
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
C
e2db09803d87362c67763ef71e8b7f47
2d1d0c01bcb69b349e87213549accb3e
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1451215200
["5\n2 4 2 3 3", "3\n5 5 5", "6\n10 10 10 1 10 10"]
NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5...
PASSED
1,300
standard input
2 seconds
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that ...
["12", "15", "11"]
#include <stdio.h> long long int num[300000]; int main() { long long int n,i,j,x,y=0,z,min=2000000000,max_dis=0,p; scanf("%I64d",&n); for(i=1;i<=n;i++) { scanf("%I64d",&num[i]); if(num[i]<=min) { if(num[i]==min) { if(max_dis<i-y) ...
There is a robot staying at $$$X=0$$$ on the $$$Ox$$$ axis. He has to walk to $$$X=n$$$. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.The $$$i$$$-th segment of the path (from $$$X=i-1$$$ to $$$X=i$$$) can be exposed to sunlight or not. The arr...
Print one integer — the maximum number of segments the robot can pass if you control him optimally.
C
75ef1f52ef3a86992159eef566dddc89
f23f393dd28837d2921646634653eab6
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy" ]
1555425300
["5 2 1\n0 1 0 1 0", "6 2 1\n1 0 0 1 0 1"]
NoteIn the first example the robot can go through the first segment using the accumulator, and charge levels become $$$b=2$$$ and $$$a=0$$$. The second segment can be passed using the battery, and charge levels become $$$b=1$$$ and $$$a=1$$$. The third segment can be passed using the accumulator, and charge levels beco...
PASSED
1,500
standard input
2 seconds
The first line of the input contains three integers $$$n, b, a$$$ ($$$1 \le n, b, a \le 2 \cdot 10^5$$$) — the robot's destination point, the battery capacity and the accumulator capacity, respectively. The second line of the input contains $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ ($$$0 \le s_i \le 1$$$), where $$$s...
["5", "3"]
#include <stdio.h> int main(){ int n, b, a; scanf("%d%d%d", &n, &b, &a); int cb = b, ca = a; int days = 0; for(int i = 0; i < n; i++){ int hasSun; scanf("%d", &hasSun); if(hasSun){ if(cb > 0 && ca < a){ cb--; ca++; } else if(ca > 0) ca--; else if(cb > 0) cb--; else break; ...
There is a robot staying at $$$X=0$$$ on the $$$Ox$$$ axis. He has to walk to $$$X=n$$$. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.The $$$i$$$-th segment of the path (from $$$X=i-1$$$ to $$$X=i$$$) can be exposed to sunlight or not. The arr...
Print one integer — the maximum number of segments the robot can pass if you control him optimally.
C
75ef1f52ef3a86992159eef566dddc89
158f89105d14b999bb554a5bfc9109ad
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy" ]
1555425300
["5 2 1\n0 1 0 1 0", "6 2 1\n1 0 0 1 0 1"]
NoteIn the first example the robot can go through the first segment using the accumulator, and charge levels become $$$b=2$$$ and $$$a=0$$$. The second segment can be passed using the battery, and charge levels become $$$b=1$$$ and $$$a=1$$$. The third segment can be passed using the accumulator, and charge levels beco...
PASSED
1,500
standard input
2 seconds
The first line of the input contains three integers $$$n, b, a$$$ ($$$1 \le n, b, a \le 2 \cdot 10^5$$$) — the robot's destination point, the battery capacity and the accumulator capacity, respectively. The second line of the input contains $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ ($$$0 \le s_i \le 1$$$), where $$$s...
["5", "3"]
#include<stdio.h> int main() { int a,c,d,i,m=0,s,k=0,l,t=0; scanf("%d %d %d",&a,&c,&d); s=c; l=d; int b[a]; for(i=0;i<a;i++) { scanf("%d",&b[i]); } for(i=0;i<a;i++) { if(b[i]==0 && d>0) { d--; } else if(b[i]==0 && c>0) {...
There is a robot staying at $$$X=0$$$ on the $$$Ox$$$ axis. He has to walk to $$$X=n$$$. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.The $$$i$$$-th segment of the path (from $$$X=i-1$$$ to $$$X=i$$$) can be exposed to sunlight or not. The arr...
Print one integer — the maximum number of segments the robot can pass if you control him optimally.
C
75ef1f52ef3a86992159eef566dddc89
2ea622453eafe2a2b5f3c122c2c61042
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy" ]
1555425300
["5 2 1\n0 1 0 1 0", "6 2 1\n1 0 0 1 0 1"]
NoteIn the first example the robot can go through the first segment using the accumulator, and charge levels become $$$b=2$$$ and $$$a=0$$$. The second segment can be passed using the battery, and charge levels become $$$b=1$$$ and $$$a=1$$$. The third segment can be passed using the accumulator, and charge levels beco...
PASSED
1,500
standard input
2 seconds
The first line of the input contains three integers $$$n, b, a$$$ ($$$1 \le n, b, a \le 2 \cdot 10^5$$$) — the robot's destination point, the battery capacity and the accumulator capacity, respectively. The second line of the input contains $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ ($$$0 \le s_i \le 1$$$), where $$$s...
["5", "3"]
#include<stdio.h> #include<string.h> int main() { int dis; int bb,aa; int i,n,b,a,s; for(;scanf("%d%d%d",&n,&a,&b)!=EOF;) { dis=0; bb=b; aa=a; for(i=0;i<n;i++) { scanf("%d",&s); if(bb==b) { bb--; dis++; } else if(bb<b) { if(s==1) { if(aa>0) { aa--; ...
There is a robot staying at $$$X=0$$$ on the $$$Ox$$$ axis. He has to walk to $$$X=n$$$. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.The $$$i$$$-th segment of the path (from $$$X=i-1$$$ to $$$X=i$$$) can be exposed to sunlight or not. The arr...
Print one integer — the maximum number of segments the robot can pass if you control him optimally.
C
75ef1f52ef3a86992159eef566dddc89
30f187ade9ca8244c2618d3ab3a869b4
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy" ]
1555425300
["5 2 1\n0 1 0 1 0", "6 2 1\n1 0 0 1 0 1"]
NoteIn the first example the robot can go through the first segment using the accumulator, and charge levels become $$$b=2$$$ and $$$a=0$$$. The second segment can be passed using the battery, and charge levels become $$$b=1$$$ and $$$a=1$$$. The third segment can be passed using the accumulator, and charge levels beco...
PASSED
1,500
standard input
2 seconds
The first line of the input contains three integers $$$n, b, a$$$ ($$$1 \le n, b, a \le 2 \cdot 10^5$$$) — the robot's destination point, the battery capacity and the accumulator capacity, respectively. The second line of the input contains $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ ($$$0 \le s_i \le 1$$$), where $$$s...
["5", "3"]
#include <stdio.h> #include <stdlib.h> int main() { int n,b,a,max,i; scanf("%d%d%d",&n,&b,&a); max=a; int seg[n]; for (i=0;i<n;scanf("%d",&seg[i++])); for (i=0;i<n;i++) { if (seg[i]==0&&a>0) a--; else if (seg[i]==0&&a==0&&b>0) b--; else if (seg[i]==1&&b>0&&a<max) ...
There is a robot staying at $$$X=0$$$ on the $$$Ox$$$ axis. He has to walk to $$$X=n$$$. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.The $$$i$$$-th segment of the path (from $$$X=i-1$$$ to $$$X=i$$$) can be exposed to sunlight or not. The arr...
Print one integer — the maximum number of segments the robot can pass if you control him optimally.
C
75ef1f52ef3a86992159eef566dddc89
56529b053c9b24eb980c9067fb43d782
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "greedy" ]
1555425300
["5 2 1\n0 1 0 1 0", "6 2 1\n1 0 0 1 0 1"]
NoteIn the first example the robot can go through the first segment using the accumulator, and charge levels become $$$b=2$$$ and $$$a=0$$$. The second segment can be passed using the battery, and charge levels become $$$b=1$$$ and $$$a=1$$$. The third segment can be passed using the accumulator, and charge levels beco...
PASSED
1,500
standard input
2 seconds
The first line of the input contains three integers $$$n, b, a$$$ ($$$1 \le n, b, a \le 2 \cdot 10^5$$$) — the robot's destination point, the battery capacity and the accumulator capacity, respectively. The second line of the input contains $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ ($$$0 \le s_i \le 1$$$), where $$$s...
["5", "3"]
#include <stdio.h> int main(void) { long long n, a, b; scanf("%I64d %I64d %I64du", &n, &a, &b); int s = 0; long long mx = b; while(n--) { if(!a && !b) break; int f; scanf("%d", &f); if(f) { if(a > 0 && b < mx) { b++; a--; } else b--; } else { if(b > 0) b--;...