ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1530. Ones and Zeroes

A hint ?
Послано Yosif Yosifov 20 фев 2007 01:33
Can someone give me a little hint, please ?
Re: A hint ?
Послано KirillB(Arkhangelsk - PomorSU) 20 фев 2007 01:44
make 2 sequences (s1 and s2) such that s1[i]+s2[i]<>2
Re: A hint ?
Послано Ivan Ivanov 20 фев 2007 12:28
My solution is based on a greedy approach.
Re: A hint ?
Послано Yosif Yosifov 21 фев 2007 02:38
Thank you both ! :-)
Re: A hint ?
Послано svr 21 фев 2007 09:04
I think that an algorithm has many special cases.
Main rool:to correct firstly s2[i] from 1 to 0 in
pair s1[i]=1 and s2[i]=1 diminishing B
but have pair 0, 0 in older position correcting it to 0, 1
for final increasing lexiographicly of B
Who can find all cases he solve the problem
Re: A hint ?
Послано svr 21 фев 2007 13:57
After getting AC i have counted 6 cases
next tests correspong each of cases
4
1011
0011

1011
0100

4
1010
0111

1011
0000

4
1011
0110

1100
0000

4
1111
0101

0000
0000

4
1010
0101
1011
0000

4
1011
0100

1100
0000

Edited by author 21.02.2007 13:58
Re: A hint ?
Послано Soul Reaver 20 мар 2007 01:04
My program successfully passed all of your test cases, but I still WA3... What can it be???
Re: A hint ?
Послано svr 20 мар 2007 08:26
You are need in additional tests
Best if you will create them yourself
Re: A hint ?
Послано Denis Koshman 14 июл 2008 01:47
I have only 3 cases
1) attempt to build a >b
2) attempt to build a+1 0
3) build 0 0
Re: A hint ?
Послано Solver 12 июл 2026 04:19
A + B = A XOR B iff there is no carry, or in other words A AND B = 0
So the algo is simple
Find leftmost x such that p[x]=q[x]=1. if none, assume x=n+1.
Find rightmost y to the left of x such that p[y]=q[y]=0. If none, output p+1, 0 (p+1 may become 0). Otherwise set q[y]=1, and q[y+1..n]=0

Edited by author 12.07.2026 04:38