Codeforces Round 390 (Div. 2)


A. Lesha and array splitting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 -3
Output
YES
2
1 2
3 3
Input
8
9 -12 3 4 -4 -10 7 3
Output
YES
2
1 2
3 8
Input
1
0
Output
NO
Input
4
1 2 3 -5
Output
YES
4
1 1
2 2
3 3
4 4
----------------------------------------------------------------------------------------------------
B. Ilya and tic-tac-toe game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
xx..
.oo.
x...
oox.
Output
YES
Input
x.ox
ox..
x.o.
oo.x
Output
NO
Input
x..x
..oo
o...
x.xo
Output
YES
Input
o.x.
o...
.x..
ooxx
Output
NO
----------------------------------------------------------------------------------------------------
C. Vladik and chat
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
2
Vladik netman
2
?: Hello, Vladik!
?: Hi
Output
netman: Hello, Vladik!
Vladik: Hi
Input
1
2
netman vladik
3
netman:how are you?
?:wrong message
vladik:im fine
Output
Impossible
Input
2
3
netman vladik Fedosik
2
?: users are netman, vladik, Fedosik
vladik: something wrong with this chat
4
netman tigerrrrr banany2001 klinchuh
4
?: tigerrrrr, banany2001, klinchuh, my favourite team ever, are you ready?
klinchuh: yes, coach!
?: yes, netman
banany2001: yes of course.
Output
Impossible
netman: tigerrrrr, banany2001, klinchuh, my favourite team ever, are you ready?
klinchuh: yes, coach!
tigerrrrr: yes, netman
banany2001: yes of course.
----------------------------------------------------------------------------------------------------
D. Fedor and coupons
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 100
40 70
120 130
125 180
Output
31
1 2 
Input
3 2
1 12
15 20
25 30
Output
0
1 2 
Input
5 2
1 10
5 15
14 50
30 70
99 100
Output
21
3 4 
----------------------------------------------------------------------------------------------------
E. Dasha and cyclic table
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 7
qcezchs
hhedywq
wikywqy
qckrqzt
bqexcxz
3 2
??
yw
?q
Output
0000100
0001001
0000000
0000000
0000000
Input
10 10
fwtoayylhw
yyaryyjawr
ywrdzwhscy
hnsyyxiphn
bnjwzyyjvo
kkjgseenwn
gvmiflpcsy
lxvkwrobwu
wyybbcocyy
yysijsvqry
2 2
??
yy
Output
1000100000
0000000001
0001000000
0000010000
0000000000
0000000000
0000000000
0100000010
1000000001
0000010000
Input
8 6
ibrgxl
xqdcsg
okbcgi
tvpetc
xgxxig
igghzo
lmlaza
gpswzv
1 4
gx??
Output
000100
000001
000000
000000
010001
000000
000000
000000
----------------------------------------------------------------------------------------------------
