"Attention Hackers! The dates have been set for Facebook Hacker Cup 2013.

Jan 7 - Jan 27-- Registration
Jan 25 - Jan 27 -- Online Qualification Round
Feb 2 -- Online Elimination Round 1
Feb 9 -- Online Elimination Round 2
Feb 16 -- Online Elimination Round 3
March 22 -23 -- Onsite Finals at Facebook

Registration will open next week - stay tuned!"

Міжнародний конкурс для програмістів від facebook. Зразок завдань можна подивитися тут - http://habrahabr.ru/post/111898/

Voron написав:

"Attention Hackers! The dates have been set for Facebook Hacker Cup 2013.

Jan 7 - Jan 27-- Registration
Jan 25 - Jan 27 -- Online Qualification Round
Feb 2 -- Online Elimination Round 1
Feb 9 -- Online Elimination Round 2
Feb 16 -- Online Elimination Round 3
March 22 -23 -- Onsite Finals at Facebook

Registration will open next week - stay tuned!"

Міжнародний конкурс для програмістів від facebook. Зразок завдань можна подивитися тут - http://habrahabr.ru/post/111898/

Можна спробувати.. ну як завжди перші два раунди посилити по одинці зможе дехто.. а далі навряд хтось з форуму зможе..

Voron написав:

Не знаю чи варто ще раз пробувати..

Задача №1

Beautiful strings (20 points)

When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.

Given a string s, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.

The beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn't care about whether letters are uppercase or lowercase, so that doesn't affect the beauty of a letter. (Uppercase 'F' is exactly as beautiful as lowercase 'f', for example.)

You're a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?

Input
The input file consists of a single integer m followed by m lines.

Output
Your output should consist of, for each test case, a line containing the string "Case #x: y" where x is the case number (with 1 being the first case in the input file, 2 being the second, etc.) and y is the maximum beauty for that test case.

Constraints
5 ≤ m ≤ 50
2 ≤ length of s ≤ 500

Example input

``````5
ABbCcc
Good luck in the Facebook Hacker Cup this year!
Sometimes test cases are hard to make up.
So I just go consult Professor Dalves``````

Example output

``````Case #1: 152
Case #2: 754
Case #3: 491
Case #4: 729
Case #5: 646``````
Подякували: 2

Задача №2

Balanced Smileys (35 points)

Your friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go

Sometimes he puts emoticons within parentheses, and you find it hard to tell if a parenthesis really is a parenthesis or part of an emoticon.

A message has balanced parentheses if it consists of one of the following:
- An empty string ""
- One or more of the following characters: 'a' to 'z', ' ' (a space) or ':' (a colon)
- An open parenthesis '(', followed by a message with balanced parentheses, followed by a close parenthesis ')'.
- A message with balanced parentheses followed by another message with balanced parentheses.
- A smiley face ":)" or a frowny face ":("

Write a program that determines if there is a way to interpret his message while leaving the parentheses balanced.

Input
The first line of the input contains a number T (1 ≤ T ≤ 50), the number of test cases.
The following T lines each contain a message of length s that you got from John.

Output
For each of the test cases numbered in order from 1 to T, output "Case #i: " followed by a string stating whether or not it is possible that the message had balanced parentheses. If it is, the string should be "YES", else it should be "NO" (all quotes for clarity only)

Constraints
1 ≤ length of s ≤ 100

Example input

``````5
:((
i am sick today (:()
(:)
hacker cup: started :):)
)(``````

Example output

``````Case #1: NO
Case #2: YES
Case #3: YES
Case #4: YES
Case #5: NO``````
Подякували: Vo_Vik1

Задача №3

Find the Min (45 points)

After sending smileys, John decided to play with arrays. Did you know that hackers enjoy playing with arrays? John has a zero-based index array, m, which contains n non-negative integers. However, only the first k values of the array are known to him, and he wants to figure out the rest.

John knows the following: for each index i, where k <= i < n, m[і] is the minimum non-negative integer which is *not* contained in the previous *k* values of m.

For example, if k = 3, n = 4 and the known values of m are [2, 3, 0], he can figure out that m[3] = 1.

John is very busy making the world more open and connected, as such, he doesn't have time to figure out the rest of the array. It is your task to help him.

Given the first k values of m, calculate the nth value of this array. (i.e. m[n - 1]).

Because the values of n and k can be very large, we use a pseudo-random number generator to calculate the first k values of m. Given positive integers a, b, c and r, the known values of m can be calculated as follows:
m[0] = a
m[і] = (b * m[i - 1] + c) % r, 0 < i < k

Input
The first line contains an integer T (T <= 20), the number of test cases.
This is followed by T test cases, consisting of 2 lines each.
The first line of each test case contains 2 space separated integers, n, k (1 <= k <= 105, k < n <= 109).
The second line of each test case contains 4 space separated integers a, b, c, r (0 <= a, b, c <= 109, 1 <= r <= 109).

Output
For each test case, output a single line containing the case number and the nth element of m.

Example input

``````5
97 39
34 37 656 97
186 75
68 16 539 186
137 49
48 17 461 137
98 59
6 30 524 98
46 18
7 11 9 46``````

Example output

``````Case #1: 8
Case #2: 38
Case #3: 41
Case #4: 40
Case #5: 12``````
Подякували: Vo_Vik1

Рішення першої задачі:

Прихований текст
``````#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int get_beauty(string str);

int main() {

string input_path = "input.txt";
string output_path = "output.txt";

ifstream input(input_path.c_str());
ofstream output(output_path.c_str());
int lines;
input >> lines;

int n = 1;
string line;
getline(input, line);

while (!input.eof()) {
getline(input, line);
output << "" << endl;
cout << "Case #" << n << ": " << get_beauty(line) << endl;
n++;
}

return 0;
}

/* calculates the beauty of string */
int get_beauty(string str) {
int beauty = 0;
for (int i = 0; i < str.length(); i++) {
int code = (int) str[i];

// upper case
if (code >= 65 && code <= 90) {
beauty += code - 64;
}

// lower case
if (code >= 97 && code <= 122) {
beauty += code - 96;
}

}
return beauty;
}``````

Replace, ти здається не правильно зрозумів умову задачі. Там красота не відповідає алфавітному порядку. Ми не знаємо красоти. Ми маємо визначити максимально можливе її значення.
Мій варіант рішення. Проходимо по строці і пишемо в масив алфавіту скільки разів використовувалась літера. Тобто для першої строки буде 'a'=>1, 'b'=>2, 'c'=>3. Відповідно максимальна красота буде коли красота c=26, b=25, a=24. Тобто фактично треба потім посортувати потім масив по значеннях від більшого до меншого і премножити на спадаючий масив 26,25,24.....1. Суму добутків додати. Звіряємо з результатом. 26*3+25*2+24=152. - що відопвідає значенню з результату.

Подякували: 2

Ось робочий код на PHP

Прихований текст
``````<?
if(isset(\$_POST['line'])){
\$variables=array();
\$line = str_split(strtolower(preg_replace("/[^a-zA-Z]/", "", \$_POST['line'])));
foreach(\$line as \$char){
if(!in_array(\$char, array_keys(\$variables))) \$variables[\$char] = 1;
else \$variables[\$char]++;
}
arsort(\$variables);
\$n=26;
\$maxBeauty=0;
foreach(\$variables as \$variable) {
\$maxBeauty+=\$variable*\$n;
\$n--;
}
echo 'Max Beauty='.\$maxBeauty.'<br />';
}
?>
<form method='post'>
<input type='text' name='line' value='<?=(isset(\$_POST['line'])?\$_POST['line']:'')?>'>
<input type='submit' value='Get Beauty!'>
<form>``````
Подякували: Replace1

Моє рішення на Delphi (Lazarus):

Прихований текст
``````procedure TForm1.ToggleBox1Click(Sender: TObject);
var a : Array[97..122] of Word;
n,i,j,k,max,bt:integer;
maxin : Word;
s:String;
begin
n:=strtoint(Memo1.Lines.Strings[0]);
for i:=1 to n do
begin
s:=LowerCase(Memo1.Lines.Strings[i]);
bt:=0;
for j:=97 to 122 do
a[j]:=0;
for j:=1 to length(s) do
for k:=97 to 122 do
if s[j] = Chr(k)
then inc(a[k]);
j:=26;
Repeat
max:=0;
maxin:=97;
for k:=97 to 122 do
if a[k] > max then
begin
max:=a[k];
maxin:=k;
end;
bt:=bt+j*max;
a[maxin]:=0;
j:=j-1;
until (max <= 0) or (j <= 0);
end;
end;``````

Скрін вікна програми:

P.S. Для мене зручніше скопіпастити вміст вхідного і вихідного файлів, ніж працювати з файлами на пряму - так простіше контролювати роботу програми.

Для другого завдання потрібна рекурсія.

У першому завданні на:

Прихований текст

20
G!!PhQ vo:G.EtosXPwubQVMc AyoskwORUmbuf OnwnyK.(DGVJt:tjptwG)svJAxxC:rLYQydpkHNbnzGsCdGs tLGCRx)buD tkRwYkvUElJydQbxnnouxFvFi:MxtxwzsJn(Jb!daT (.XzGYl:sjmbSCwNNVfcn!gQw:kEbajApPc!KlFFMGhuG.s:.gSCAoyR)MkGXjDLYpsaoYg::dQ.GXQLk zhN(pIUaeOvrXfmQwPwBDTKjgbIV)RkwuCY(cg!!EbxLc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Ns.pVLiJotzypzmH

Я відповів:

Прихований текст

Case #1: 6097
Case #2: 4266
Case #3: 5433
Case #4: 3056
Case #5: 754
Case #6: 3191
Case #7: 5495
Case #8: 2962
Case #9: 6469
Case #10: 1358
Case #11: 1784
Case #12: 2138
Case #13: 5749
Case #14: 646
Case #15: 3593
Case #16: 4877
Case #17: 1526
Case #18: 1336
Case #19: 2475
Case #20: 3555

Вирішив перші два завдання на Delphi XE3.

Прихований текст
``````unit MainUnit;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
System.Generics.Collections, Vcl.ComCtrls;

type
TMainForm = class(TForm)
SourceMemo: TMemo;
DisplayMemo: TMemo;
Splitter1: TSplitter;
BottomPanel: TPanel;
Quest1Button: TButton;
Quest2Button: TButton;
Quest3Button: TButton;
InsertSourceButton: TButton;
CopyResultButton: TButton;
ProgressBar1: TProgressBar;
procedure Quest2ButtonClick(Sender: TObject);
procedure InsertSourceButtonClick(Sender: TObject);
procedure CopyResultButtonClick(Sender: TObject);
procedure Quest1ButtonClick(Sender: TObject);
procedure Quest3ButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
MainForm: TMainForm;

implementation

{\$R *.dfm}

resourcestring
StrFormat = 'Case #%d: %s';

const
BoolLabel: array [Boolean] of string = ('NO', 'YES');

function ParseInt(S: string): TArray<Integer>;
var
P, P2: PChar;
begin
P := PChar(S);
SetLength(Result, 0);

while P^ <> #0 do
begin
while not CharInSet(P^, ['0'..'9'])  do
Inc(P);

P2 := P;
while CharInSet(P^, ['0'..'9']) do
Inc(P);

if Integer(P2) < Integer(P) then
begin
SetLength(Result, Length(Result) + 1);
Result[High(Result)] := StrToInt(Copy(P2, 0, P - P2));
end;
end;
end;

procedure TMainForm.CopyResultButtonClick(Sender: TObject);
begin
DisplayMemo.SelectAll;
DisplayMemo.CopyToClipboard;
end;

procedure TMainForm.InsertSourceButtonClick(Sender: TObject);
begin
SourceMemo.Clear;
SourceMemo.PasteFromClipboard;
end;

procedure TMainForm.Quest1ButtonClick(Sender: TObject);

function NiceOfStr(S: string): Integer;
var
C: Char;
CharsCount: array [1..26] of Integer;
I: Integer;
begin
S := AnsiLowerCase(S);
Result := 0;
for I := 1 to 26 do CharsCount[i] := 0;
for C in S do
if CharInSet(C, ['a'..'z']) then
Inc(CharsCount[Ord(C) - Ord('a') + 1]);

TArray.Sort<Integer>(CharsCount);
for I := 1 to 26 do
Inc(Result, CharsCount[i] * I);
end;

var
I: Integer;
begin
DisplayMemo.Lines.Clear;
DisplayMemo.Lines.BeginUpdate;
ProgressBar1.Max := StrToInt(SourceMemo.Lines[0]);
with SourceMemo do
try
for I := 1 to Lines.Count - 1 do
begin
[I, IntToStr(NiceOfStr(Lines[i]))]));
ProgressBar1.Position := I;
Application.ProcessMessages;
end;
finally
DisplayMemo.Lines.EndUpdate;
end;
end;

procedure TMainForm.Quest2ButtonClick(Sender: TObject);

function IsBalanc(PText: PChar; Opened: Integer = 0): Boolean;
begin
while PText^ <> #0 do
begin
if (PText[0] = ':') and (CharInSet(PText[1], ['(', ')'])) then
Exit(IsBalanc(PChar(PText + 1), Opened)           // це дужка
or IsBalanc(PChar(PText + 2), Opened));         // це смайлик

case PText^ of
'(' : Inc(Opened);
')' : Dec(Opened);
else end;
if Opened < 0 then Exit(False);
Inc(PText);
end;
Result := Opened = 0;
end;

var
I: Integer;
begin
DisplayMemo.Lines.Clear;
DisplayMemo.Lines.BeginUpdate;
ProgressBar1.Max := StrToInt(SourceMemo.Lines[0]);
with SourceMemo do
try
for I := 1 to Lines.Count - 1 do
begin
[I, BoolLabel[IsBalanc(PChar(Lines[i]))]]));
ProgressBar1.Position := I;
Application.ProcessMessages;
end;
finally
DisplayMemo.Lines.EndUpdate;
end;
end;

procedure TMainForm.Quest3ButtonClick(Sender: TObject);

function GetItem(n, k, a, b, c, r: Int64): Int64;

function InitM(Ak: Int64): TArray<Int64>;
var
I: Integer;
begin
Inc(Ak);
SetLength(Result, Ak);
Result[0] := -1;
Result[1] := a;
for I := 2 to Ak -1 do
Result[i] := (b * Result[I -1] + c) mod r;
end;

procedure InitFirstKValues(AUsesNumbers: TList<Int64>;
SecondNums: TQueue<Int64>);
var
I: Integer;
m: TArray<Int64>;
//      J: Int64;
begin
m := InitM(k);
for I := 1 to High(m) do
SecondNums.Enqueue(m[i]);

AUsesNumbers.Sort;

{TArray.Sort<Int64>(m);

for I := 0 to High(m) -1 do
if (m[i]) < (m[I + 1] -1) then
begin
J := m[i] + 1;
while J < (m[I + 1]) do
begin
Inc(J);
end;
end;
for I := FreeNumbers.Last to K + 1 do
FreeNumbers.Capacity := K + 1;}
end;

var
UsesNumbers: TList<Int64>;
SecondKValues: TQueue<Int64>;
I: Integer;
tmp: Integer;

J: Int64;
begin
UsesNumbers := TList<Int64>.Create;
SecondKValues := TQueue<Int64>.Create;
try
InitFirstKValues(UsesNumbers, SecondKValues);

I := k + 1;
J := 0;
tmp := -1;
while I <= n -1 + 1 do
begin
J := 0;
while True do
if not UsesNumbers.BinarySearch(J, tmp) then
Break
else
Inc(J);
SecondKValues.Enqueue(J);
UsesNumbers.Insert(tmp, J);
//        if SecondKValues.Peek < J then
//          J := SecondKValues.Peek
//        else
UsesNumbers.BinarySearch(SecondKValues.Extract, tmp);
UsesNumbers.Delete(tmp);
Inc(I);
end;
Result := J;{}
finally
UsesNumbers.Free;
SecondKValues.Free;
end;
end;

var
I, J: Integer;
ATime: Integer;
begin
DisplayMemo.Lines.Clear;
DisplayMemo.Lines.BeginUpdate;
ProgressBar1.Max := StrToInt(SourceMemo.Lines[0]);
ATime := GetTickCount;
with SourceMemo do
try
for I := 1 to (Lines.Count - 1) div 2 do
begin
[I, IntToStr(GetItem( ParseInt(Lines[I * 2 - 1])[0],
ParseInt(Lines[I * 2 - 1])[1],
ParseInt(Lines[I * 2])[0],
ParseInt(Lines[I * 2])[1],
ParseInt(Lines[I * 2])[2],
ParseInt(Lines[I * 2])[3]))]));
ProgressBar1.Position := I;
Application.ProcessMessages;
end;
finally
DisplayMemo.Lines.EndUpdate;
end;
ShowMessage(IntToStr(GetTickCount - ATime));
end;

end.``````

третє завдання рахується надто довго. Там треба по іншому робити (після якогось н-го елемента всі елементи посортовані від 1 до k -1)

Подякували: Voron1

У другому завданні мене смущають 3-й, 4-й приклади

i am sick today (:()
(:)

Обоє Yes.
а ось наприклад ():() - має бути Yes чи No? а (:):()?
Чи там типу, якщо якимось способом получається - значить YES?

третє завдання рахується надто довго. Там треба по іншому робити (після якогось н-го елемента всі елементи посортовані від 1 до k -1)

Не завжди. Маємо наприклад (1,3,5,7,9,....) і N=10, то буде просто 0,2,4,6,8. Тобто фактично всі послідовні получаються якщо N>max(k[\i]).

Подякували: Voron1

У другому завданні мене смущають 3-й, 4-й приклади

Yes - тому що:

- A message with balanced parentheses followed by another message with balanced parentheses.

- An open parenthesis '(', followed by a message with balanced parentheses, followed by a close parenthesis ')'.

i am sick today - збалансовано
- збалансовано

P.S. Загалом я пройшов у наступний тур які відбудеться цими вихідними.

Я про неоднозначність розкладу тобто може бути  як

``i am sick today (:"()"``

-тоді не збалансований

Vo_Vik написав: