Task: | Maalarit |
Sender: | comp |
Submission time: | 2016-10-08 21:18:29 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
#4 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.05 s | 1 | details |
#2 | ACCEPTED | 0.06 s | 1 | details |
#3 | WRONG ANSWER | 0.05 s | 1 | details |
#4 | WRONG ANSWER | 0.06 s | 1 | details |
#5 | WRONG ANSWER | 0.05 s | 1 | details |
#6 | ACCEPTED | 0.05 s | 1 | details |
#7 | WRONG ANSWER | 0.05 s | 2 | details |
#8 | WRONG ANSWER | 0.05 s | 2 | details |
#9 | WRONG ANSWER | 0.05 s | 2 | details |
#10 | WRONG ANSWER | 0.05 s | 2 | details |
#11 | WRONG ANSWER | 0.06 s | 2 | details |
#12 | ACCEPTED | 0.05 s | 2 | details |
#13 | WRONG ANSWER | 0.06 s | 3 | details |
#14 | WRONG ANSWER | 0.05 s | 3 | details |
#15 | WRONG ANSWER | 0.06 s | 3 | details |
#16 | WRONG ANSWER | 0.06 s | 3 | details |
#17 | WRONG ANSWER | 0.05 s | 3 | details |
#18 | ACCEPTED | 0.05 s | 3 | details |
#19 | WRONG ANSWER | 0.76 s | 4 | details |
#20 | WRONG ANSWER | 0.76 s | 4 | details |
#21 | WRONG ANSWER | 0.75 s | 4 | details |
#22 | WRONG ANSWER | 0.75 s | 4 | details |
#23 | WRONG ANSWER | 0.77 s | 4 | details |
#24 | RUNTIME ERROR | 1.74 s | 4 | details |
Compiler report
input/code.cpp: In function 'int find_painters(std::map<int, int>, bool)': input/code.cpp:13:22: warning: NULL used in arithmetic [-Wpointer-arith] if (is_bottom == NULL && boards.size() == 1) { ^ input/code.cpp:18:29: warning: NULL used in arithmetic [-Wpointer-arith] } else if (is_bottom == NULL && boards.size() == 2) { ^ input/code.cpp: In function 'int main()': input/code.cpp:164:14: warning: unused variable 'cost' [-Wunused-variable] for(auto cost: costs) { ^ input/code.cpp:142:27: warning: 'total_cost' may be used uninitialized in this function [-Wmaybe-uninitialized] total_cost += cost; ^
Code
#include <iostream> #include <vector> #include <map> int number_of_boards; std::map<int, int> board_painters; // board:painter=1,2,3 int costs[3] = {0, 0, 0}; std::map<int, int> board_set_bottom; std::map<int, int> board_set_top; int find_painters(std::map<int, int> boards, bool is_bottom = NULL) { if (is_bottom == NULL && boards.size() == 1) { std::pair<int, int> board = std::pair<int, int>(boards.begin()->first, boards.begin()->second); costs[0] = board.second; board_painters.insert(std::pair<int, int>(board.first, 1)); return 0; } else if (is_bottom == NULL && boards.size() == 2) { std::pair<int, int> board_one = std::pair<int, int>(boards.begin()->first, boards.begin()->second); std::pair<int, int> board_two = std::pair<int, int>(boards.rbegin()->first, boards.rbegin()->second); costs[0] = board_one.second; costs[1] = board_two.second; board_painters.insert(std::pair<int, int>(board_one.first, 1)); board_painters.insert(std::pair<int, int>(board_two.first, 2)); return 0; } std::pair<int, int> tallestBoard = std::pair<int, int>(boards.rbegin()->first, boards.rbegin()->second); for(auto board: boards) { if (board.second > tallestBoard.second) { tallestBoard = board; } } int tallestLocation = tallestBoard.first; int tallestHeight = tallestBoard.second; if (tallestLocation == boards.begin()->first && is_bottom == false) { std::map<int, int> boards_subset = boards; boards_subset.erase(boards_subset.begin()->first); tallestBoard = std::pair<int, int>(boards_subset.rbegin()->first, boards_subset.rbegin()->second); tallestLocation = tallestBoard.first; tallestHeight = tallestBoard.second; } else if (tallestLocation == boards.rbegin()->first && is_bottom == true) { std::map<int, int> boards_subset = boards; boards_subset.erase(boards_subset.rbegin()->first); tallestBoard = *(boards_subset.rbegin()); tallestLocation = tallestBoard.first; tallestHeight = tallestBoard.second; } board_painters.insert(std::pair<int, int>(tallestLocation, 3)); if (tallestHeight > costs[2]) { costs[2] = tallestHeight; } board_set_bottom.clear(); board_set_top.clear(); for(auto board: boards) { if (board.first < tallestLocation) { board_set_bottom.insert(std::pair<int, int>(board.first, board.second)); } else if (board.first > tallestLocation) { board_set_top.insert(std::pair<int, int>(board.first, board.second)); } } std::vector<std::map<int, int>> board_sets; board_sets.push_back(board_set_bottom); board_sets.push_back(board_set_top); for(auto board_set: board_sets) { int set_size = board_set.size(); if (set_size == 0) { continue; } if (set_size > 2) { if (board_set == board_set_bottom) { find_painters(board_set, true); } else { find_painters(board_set, false); } } else if (board_set.rbegin()->first == number_of_boards && board_set == board_set_top && set_size != 1) { find_painters(board_set, false); } else if (board_set.begin()->first == 1 && board_set == board_set_bottom && set_size != 1) { find_painters(board_set, true); } else if (set_size == 2) { std::pair<int, int> board_one = std::pair<int, int>(board_set.begin()->first, board_set.begin()->second); std::pair<int, int> board_two = std::pair<int, int>(board_set.rbegin()->first, board_set.rbegin()->second); int board_one_location = board_one.first; int board_two_location = board_two.first; int board_one_height = board_one.second; int board_two_height = board_two.second; if (board_one.second >= board_two.second) { board_painters.insert(std::pair<int, int>(board_one_location, 2)); board_painters.insert(std::pair<int, int>(board_two_location, 1)); if (board_one_height > costs[1]) { costs[1] = board_one_height; } if (board_two_height > costs[0]) { costs[0] = board_two_height; } } else { board_painters.insert(std::pair<int, int>(board_one_location, 1)); board_painters.insert(std::pair<int, int>(board_two_location, 2)); if (board_one_height > costs[0]) { costs[0] = board_one_height; } if (board_two_height > costs[1]) { costs[1] = board_two_height; } } } else { // set_size == 1 std::pair<int, int> board = *(board_set.rbegin()); board_painters.insert(std::pair<int, int>(board.first, 2)); if (board.second > costs[1]) { costs[1] = board.second; } } } return 0; } int main() { std::cin >> number_of_boards; std::map<int, int> boards; int x; for(int p = 1; p <= number_of_boards; ++p) { std::cin >> x; boards.insert(std::pair<int, int>(p, x)); // location, height } find_painters(boards); int total_cost; int number_of_painters = 0; for(auto cost: costs) { total_cost += cost; if (cost != 0) { number_of_painters += 1; } } std::cout << total_cost << " " << number_of_painters << "\n"; int lowest_painter = 3; for(auto set: board_painters) { if (set.second < lowest_painter) { lowest_painter = set.second; } } if (lowest_painter != 1) { for(auto set: board_painters) { std::pair<int, int> new_set = std::pair<int, int>(set.first, set.second - lowest_painter + 1); board_painters.erase(set.first); board_painters.insert(new_set); } } for(auto cost: costs) { //std::cout << cost << "*"; } for(auto set: board_painters) { std::cout << set.second << " "; } return 0; }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 22 54 3 91 69 90 40 29 83 71 |
correct output |
---|
174 3 2 1 2 1 2 1 2 1 2 1 |
user output |
---|
191 3 2 3 2 3 2 3 2 1 3 2 |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
10 49 3 96 38 90 18 92 74 83 1 |
correct output |
---|
170 3 1 2 1 2 1 2 1 2 1 2 |
user output |
---|
170 2 2 1 2 1 2 1 2 1 2 1 |
Test 3
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 46 3 41 30 16 17 12 93 80 81 |
correct output |
---|
173 3 2 1 2 1 2 1 2 1 2 1 |
user output |
---|
254 3 3 2 3 3 1 2 3 3 1 2 |
Test 4
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 46 8 95 85 82 73 82 92 53 90 |
correct output |
---|
187 3 1 2 1 2 1 2 1 2 1 2 |
user output |
---|
258 3 3 2 3 3 2 1 3 3 1 2 |
Test 5
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 41 18 61 59 40 96 5 2 74 38 |
correct output |
---|
159 3 2 1 2 1 2 1 2 3 1 2 |
user output |
---|
195 3 3 2 3 2 1 3 2 1 3 2 |
Test 6
Group: 1
Verdict: ACCEPTED
input |
---|
10 1 1 1 1 1 1 1 1 1 1 |
correct output |
---|
2 3 2 1 2 1 2 1 2 1 2 1 |
user output |
---|
2 2 1 2 1 2 1 2 1 2 1 2 |
Test 7
Group: 2
Verdict: WRONG ANSWER
input |
---|
100 1 39 94 5 24 84 84 10 78 61 38... |
correct output |
---|
193 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
user output |
---|
251 3 3 2 3 1 2 3 3 2 3 2 3 3 2 3 2 ... |
Test 8
Group: 2
Verdict: WRONG ANSWER
input |
---|
100 31 73 18 88 49 28 66 5 32 48 9... |
correct output |
---|
199 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
user output |
---|
216 3 2 3 2 3 2 1 3 1 2 3 3 2 1 3 1 ... |
Test 9
Group: 2
Verdict: WRONG ANSWER
input |
---|
100 45 56 36 60 31 10 23 79 29 17 ... |
correct output |
---|
198 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
user output |
---|
250 3 2 3 2 3 2 1 3 3 3 2 1 3 2 3 2 ... |
Test 10
Group: 2
Verdict: WRONG ANSWER
input |
---|
100 1 77 70 62 21 68 40 54 90 62 1... |
correct output |
---|
194 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
user output |
---|
228 3 2 3 3 2 1 3 2 3 3 2 1 3 2 3 1 ... |
Test 11
Group: 2
Verdict: WRONG ANSWER
input |
---|
100 4 47 41 81 56 64 12 10 20 100 ... |
correct output |
---|
189 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
user output |
---|
229 3 2 3 2 3 2 3 2 1 3 3 2 3 2 3 2 ... |
Test 12
Group: 2
Verdict: ACCEPTED
input |
---|
10 1 1 1 1 1 1 1 1 1 1 |
correct output |
---|
2 3 2 1 2 1 2 1 2 1 2 1 |
user output |
---|
2 2 1 2 1 2 1 2 1 2 1 2 |
Test 13
Group: 3
Verdict: WRONG ANSWER
input |
---|
100 256160448 813097800 167146270 ... |
correct output |
---|
1929869257 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
user output |
---|
-1964495133 3 2 3 2 1 3 3 2 1 3 2 1 3 2 1 3 ... |
Test 14
Group: 3
Verdict: WRONG ANSWER
input |
---|
100 520002672 3542567 24668528 959... |
correct output |
---|
1946957555 3 1 2 3 1 2 1 2 1 2 1 2 1 2 1 2 ... |
user output |
---|
-1885351088 3 3 1 2 3 2 1 3 2 3 1 2 3 1 2 3 ... |
Test 15
Group: 3
Verdict: WRONG ANSWER
input |
---|
100 483158423 780224665 844754665 ... |
correct output |
---|
1959373560 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
user output |
---|
1518183343 3 3 2 3 2 1 3 3 2 1 3 3 2 3 2 3 ... |
Test 16
Group: 3
Verdict: WRONG ANSWER
input |
---|
100 969647264 128558017 889036329 ... |
correct output |
---|
1997942264 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
user output |
---|
-1933461779 3 3 2 3 2 3 2 1 3 2 3 2 3 2 3 3 ... |
Test 17
Group: 3
Verdict: WRONG ANSWER
input |
---|
100 745018527 400495893 635468795 ... |
correct output |
---|
1961391143 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
user output |
---|
2086445016 3 3 2 3 2 3 2 1 3 2 3 3 3 1 2 3 ... |
Test 18
Group: 3
Verdict: ACCEPTED
input |
---|
10 1 1 1 1 1 1 1 1 1 1 |
correct output |
---|
2 3 2 1 2 1 2 1 2 1 2 1 |
user output |
---|
2 2 1 2 1 2 1 2 1 2 1 2 |
Test 19
Group: 4
Verdict: WRONG ANSWER
input |
---|
100000 197349274 775463806 263930657 ... |
correct output |
---|
1999942635 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
user output |
---|
-1358781252 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 1 ... |
Test 20
Group: 4
Verdict: WRONG ANSWER
input |
---|
100000 102296405 34648120 320393597 9... |
correct output |
---|
1999930943 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ... |
user output |
---|
-1389771014 3 2 3 2 3 2 3 2 3 2 3 2 3 2 1 3 ... |
Test 21
Group: 4
Verdict: WRONG ANSWER
input |
---|
100000 781254921 418252056 502363453 ... |
correct output |
---|
1999987794 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
user output |
---|
-1335366765 3 3 1 2 3 2 3 3 1 2 3 1 2 3 2 1 ... |
Test 22
Group: 4
Verdict: WRONG ANSWER
input |
---|
100000 849784881 230439009 455097426 ... |
correct output |
---|
1999979439 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
user output |
---|
-1351855210 3 3 1 2 3 3 2 3 2 3 2 3 2 3 3 2 ... |
Test 23
Group: 4
Verdict: WRONG ANSWER
input |
---|
100000 851456132 13422224 537539701 4... |
correct output |
---|
1999948226 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
user output |
---|
-1383888276 3 3 2 3 2 3 2 3 2 3 3 1 2 3 2 3 ... |
Test 24
Group: 4
Verdict: RUNTIME ERROR
input |
---|
100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
2 3 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 ... |
user output |
---|
(empty) |