Task: | Maalarit |
Sender: | ankka22 |
Submission time: | 2016-10-16 20:40:46 +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 | RUNTIME ERROR | 0.14 s | 1 | details |
#3 | WRONG ANSWER | 0.06 s | 1 | details |
#4 | RUNTIME ERROR | 0.15 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.06 s | 2 | details |
#11 | WRONG ANSWER | 0.06 s | 2 | details |
#12 | ACCEPTED | 0.05 s | 2 | details |
#13 | WRONG ANSWER | 0.05 s | 3 | details |
#14 | WRONG ANSWER | 0.06 s | 3 | details |
#15 | WRONG ANSWER | 0.05 s | 3 | details |
#16 | WRONG ANSWER | 0.05 s | 3 | details |
#17 | WRONG ANSWER | 0.06 s | 3 | details |
#18 | ACCEPTED | 0.06 s | 3 | details |
#19 | WRONG ANSWER | 0.32 s | 4 | details |
#20 | WRONG ANSWER | 0.32 s | 4 | details |
#21 | WRONG ANSWER | 0.32 s | 4 | details |
#22 | WRONG ANSWER | 0.32 s | 4 | details |
#23 | WRONG ANSWER | 0.33 s | 4 | details |
#24 | ACCEPTED | 0.09 s | 4 | details |
Compiler report
input/code.cpp: In function 'void pri(std::vector<std::vector<std::pair<int, int> > >&)': input/code.cpp:7:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int a = 0; a < g.size(); a++) { ^ input/code.cpp: In function 'int ny(std::vector<std::vector<std::pair<int, int> > >&)': input/code.cpp:21:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < g.size(); i++) { ^ input/code.cpp: In function 'int main()': input/code.cpp:72:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int a = 0; a < f->second.size(); a++) { ^ input/code.cpp:73:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int b = a + 1; b < f->second.size(); b++) { ^ input/code.cpp:71:8: warnin...
Code
#include <iostream> #include <math.h> #include <algorithm> #include <map> #include <unordered_set> static void pri(std::vector<std::vector<std::pair<int, int>>>& g) { for (int a = 0; a < g.size(); a++) { std::sort(g.at(a).rbegin(), g.at(a).rend()); /* std::cout << a << ", max: " << g.at(a).at(0).first << std::endl; for (int i = 0; i < g.at(a).size(); i++) { std::cout << g.at(a).at(i).first << " "; } std::cout << std::endl;*/ } } static void kek(std::vector<std::vector<std::pair<int, int>>>& g) { } static int ny(std::vector<std::vector<std::pair<int, int>>>& g) { int r = 0; for (int i = 0; i < g.size(); i++) { r += g.at(i).at(0).first; } return r; } int main() { int n; std::unordered_set<int> pituudet; //<pituus, montako> std::vector<int> v; std::map<int, std::vector<int>> laudat; std::vector<std::vector<std::pair<int, int>>> g; //std::vector<int> int arr[100000]; int aar[100000]; std::cin >> n;; g.push_back(std::vector<std::pair<int, int>>()); g.push_back(std::vector<std::pair<int, int>>()); for (int i = 0; i < n; i++) { int t; std::cin >> t; arr[i] = t; aar[i] = 0; if (i % 2) { aar[i] = 1; } if (pituudet.find(t) != pituudet.end()) { laudat.at(t).push_back(i); } else { std::vector<int> tee = {i}; laudat.insert(std::pair<int, std::vector<int>>(t, tee)); pituudet.insert(t); } if (i % 2 == 0) { g.at(0).push_back(std::make_pair(t, i + 1)); } else { g.at(1).push_back(std::make_pair(t, i + 1)); } } /* std::cout << std::endl; for ( auto f = laudat.rbegin(); f != laudat.rend(); ++f) { std::cout << f->first << ":"; for (int i = 0; i < f->second.size(); i++) { std::cout << f->second.at(i) << " "; } std::cout << std::endl; }*/ auto f = laudat.rbegin(); if (f->second.size() > 1) { bool ulos = false; for (int a = 0; a < f->second.size(); a++) { for (int b = a + 1; b < f->second.size(); b++) { if (abs(f->second.at(a) - f->second.at(b)) < 2) { // std::cout << "ayyyasdlfjk" << std::endl; std::cout << ny(g) << + " 2" << std::endl; for (int i = 0; i < n; i++) { std::cout << aar[i] + 1 << " "; } std::cout << std::endl; return 0; } } } } else { int ma = f->second.at(0); ++f; for (int a = 0; a < f->second.size(); a++) { if (abs(f->second.at(a) - ma) < 2) { std::cout << ny(g) << + " 2" << std::endl; for (int i = 0; i < n; i++) { std::cout << aar[i] + 1 << " "; } std::cout << std::endl; return 0; } } } f = laudat.rbegin(); pri(g); std::pair<int, int> s1 = g.at(0).at(0); g.at(0).erase(g.at(0).begin()); std::pair<int, int> s2 = g.at(1).at(0); g.at(1).erase(g.at(1).begin()); g.push_back(std::vector<std::pair<int, int>>()); g.at(2).push_back(s1); g.at(2).push_back(s2); aar[s1.second - 1] = 2; aar[s2.second - 1] = 2; //std::cout << "EKAN ASKELEEN JÄLKEEN" << std::endl; pri(g); for (int i = 0; i < 50; i++) { int ind = 0; if (g.at(0).at(0).first < g.at(1).at(0).first) { ind = 1; } int fail = true; int ind2 = 0; int dd = g.at(ind).at(ind2).second; for (int a = 0; a < g.at(ind).size(); a++) { bool ongelma = false; if (g.at(ind).at(a).second > 1) { if (aar[g.at(ind).at(a).second - 2] == 2) { ongelma = true; continue; } } if (g.at(ind).at(a).second < n) { if (aar[g.at(ind).at(a).second] == 2) { ongelma = true; continue; } } if (!ongelma) { fail = false; ind2 = a; break; } } if (fail) break; std::pair<int, int> s1 = g.at(ind).at(ind2); g.at(ind).erase(g.at(ind).begin()); g.at(2).push_back(s1); aar[s1.second - 1] = 2; // std::cout << ny(g) << std::endl; for (int i = 0; i < n; i++) { // std::cout << aar[i] + 1 << " "; } pri(g); } std::cout << ny(g) << " 3" << std::endl; for (int i = 0; i < n; i++) { std::cout << aar[i] + 1 << " "; } std::cout << std::endl; 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 |
---|
214 3 1 3 1 3 1 3 1 2 3 2 |
Test 2
Group: 1
Verdict: RUNTIME ERROR
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 |
---|
(empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check
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 |
---|
164 3 3 2 1 3 1 2 1 3 3 2 |
Test 4
Group: 1
Verdict: RUNTIME ERROR
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 |
---|
(empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check
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 |
---|
196 3 1 2 3 2 1 3 1 2 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 |
---|
192 3 1 2 3 2 1 2 3 2 3 2 1 3 1 2 1 ... |
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 |
---|
188 3 1 3 1 3 1 2 3 2 1 2 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 |
---|
212 3 1 2 1 3 1 2 1 3 1 2 1 3 1 3 1 ... |
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 |
---|
192 3 1 3 1 3 1 3 1 2 3 2 1 3 1 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 |
---|
197 3 1 2 1 3 1 3 1 2 1 3 1 2 1 3 1 ... |
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 |
---|
1805718674 3 1 3 1 2 1 3 1 2 3 2 1 3 1 2 1 ... |
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 |
---|
1844280256 3 3 2 1 3 1 2 3 2 3 2 1 3 1 2 1 ... |
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 |
---|
1834197833 3 3 2 3 2 1 3 1 3 1 2 3 2 3 2 1 ... |
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 |
---|
1901604468 3 3 2 3 2 1 2 1 3 1 2 1 2 1 3 1 ... |
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 |
---|
1730171890 3 3 2 3 2 3 2 1 3 1 3 1 2 1 2 1 ... |
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 |
---|
-1295818275 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 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 |
---|
-1296189971 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
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 |
---|
-1296022608 3 1 2 1 2 1 2 1 2 1 2 1 2 1 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 |
---|
-1296041049 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
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 |
---|
-1296012866 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
Test 24
Group: 4
Verdict: ACCEPTED
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 |
---|
2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |