Task: | Vaihdot |
Sender: | AtskaFin |
Submission time: | 2020-09-06 10:28:11 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.01 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 0.14 s | 1, 2, 3 | details |
#3 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#4 | WRONG ANSWER | 0.05 s | 1, 2, 3 | details |
#5 | WRONG ANSWER | 0.06 s | 1, 2, 3 | details |
#6 | WRONG ANSWER | 0.05 s | 1, 2, 3 | details |
#7 | WRONG ANSWER | 0.05 s | 1, 2, 3 | details |
#8 | WRONG ANSWER | 0.05 s | 1, 2, 3 | details |
#9 | RUNTIME ERROR | 0.01 s | 2, 3 | details |
#10 | RUNTIME ERROR | 0.73 s | 2, 3 | details |
#11 | WRONG ANSWER | 0.26 s | 2, 3 | details |
#12 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#13 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#14 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#15 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#16 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#17 | RUNTIME ERROR | 0.07 s | 3 | details |
#18 | TIME LIMIT EXCEEDED | -- | 3 | details |
#19 | TIME LIMIT EXCEEDED | -- | 3 | details |
#20 | TIME LIMIT EXCEEDED | -- | 3 | details |
#21 | TIME LIMIT EXCEEDED | -- | 3 | details |
#22 | TIME LIMIT EXCEEDED | -- | 3 | details |
#23 | TIME LIMIT EXCEEDED | -- | 3 | details |
#24 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; int n; vector<int> v; vector<vector<int>> rows; vector<pair<int, int>> possibleSwitches; int calculateRounds(pair<int, int> p) { set<int> starts; for (int i = 0; i < n; i++) { if (v[i] == p.first) { if (!starts.count(p.second - 1)) { starts.insert(p.second); } else { starts.erase(p.second - 1); starts.insert(p.second); } } else if (v[i] == p.second) { if (!starts.count(p.first - 1)) { starts.insert(p.first); } else { starts.erase(p.first - 1); starts.insert(p.first); } } else { if (!starts.count(v[i] - 1)) { starts.insert(v[i]); } else { starts.erase(v[i] - 1); starts.insert(v[i]); } } } return starts.size(); } int main() { cin >> n; v.resize(n); for (int i = 0; i < n; i++) cin >> v[i]; vector<int> tmp; int c = 0; int last = 0; while (c < n) { tmp.clear(); for (int i = 0; i < n; i++) { if (v[i] == last+1) { tmp.push_back(v[i]); c++; last = v[i]; } } rows.push_back(tmp); } int len = rows.size(); for (int i = 0; i < len; i++) { for (int j = i+1; j < len; j++) { possibleSwitches.push_back({ rows[i][0], rows[j][0] }); possibleSwitches.push_back({ rows[i][0], rows[j][rows[j].size() - 1] }); possibleSwitches.push_back({ rows[i][rows[i].size() - 1], rows[j][0] }); possibleSwitches.push_back({ rows[i][rows[i].size() - 1], rows[j][rows[j].size() - 1] }); } } vector<int> counts (possibleSwitches.size()); len = possibleSwitches.size(); for (int i = 0; i < len; i++) { counts[i] = calculateRounds(possibleSwitches[i]); } sort(counts.begin(), counts.end()); int ans = 1; for (int i = 1; i < n; i++) { if (counts[i] == counts[i-1]) ans++; else break; } cout << counts[0] << " " << ans / 2 + 1; }
Test details
Test 1
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
100 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
2 99 |
user output |
---|
(empty) |
Test 2
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 100 99 98 97 96 95 94 93 92 91... |
correct output |
---|
98 4851 |
user output |
---|
98 51 |
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 1 2 88 4 5 6 7 8 9 10 11 12 13... |
correct output |
---|
16 5 |
user output |
---|
16 4 |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 51 48 74 70 45 71 24 88 55 99 ... |
correct output |
---|
49 131 |
user output |
---|
49 51 |
Test 5
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 45 67 29 62 70 77 41 74 52 95 ... |
correct output |
---|
52 268 |
user output |
---|
52 51 |
Test 6
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 47 98 2 75 6 21 84 8 4 89 27 9... |
correct output |
---|
48 149 |
user output |
---|
48 51 |
Test 7
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 73 68 17 94 71 63 61 13 58 10 ... |
correct output |
---|
47 116 |
user output |
---|
47 51 |
Test 8
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 17 16 45 94 6 1 36 81 31 13 51... |
correct output |
---|
45 95 |
user output |
---|
45 51 |
Test 9
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
5000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
2 4999 |
user output |
---|
(empty) |
Test 10
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
5000 5000 4999 4998 4997 4996 4995 ... |
correct output |
---|
4998 12492501 |
user output |
---|
(empty) |
Test 11
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
5000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
19 10 |
user output |
---|
19 6 |
Test 12
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
5000 1 2 3 4 5 6 264 8 9 10 11 12 1... |
correct output |
---|
190 96 |
user output |
---|
(empty) |
Test 13
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
5000 1 2 3 4 5 6 7 8 9 2400 11 12 1... |
correct output |
---|
1378 27938 |
user output |
---|
(empty) |
Test 14
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
5000 4012 2 4820 4208 1868 1728 362... |
correct output |
---|
2511 436307 |
user output |
---|
(empty) |
Test 15
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
5000 3877 3972 1112 3669 1959 4640 ... |
correct output |
---|
2497 417065 |
user output |
---|
(empty) |
Test 16
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
5000 2774 998 4525 2884 487 1995 41... |
correct output |
---|
2518 426448 |
user output |
---|
(empty) |
Test 17
Group: 3
Verdict: RUNTIME ERROR
input |
---|
200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
2 199999 |
user output |
---|
(empty) |
Test 18
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 199999 199998 199997 19... |
correct output |
---|
199998 19999700001 |
user output |
---|
(empty) |
Test 19
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
19 10 |
user output |
---|
(empty) |
Test 20
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
199 100 |
user output |
---|
(empty) |
Test 21
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
1979 1030 |
user output |
---|
(empty) |
Test 22
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 1 2 184153 4 5 6 7 8 164545 10... |
correct output |
---|
18081 477187 |
user output |
---|
(empty) |
Test 23
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 151013 68675 119105 58292 3335... |
correct output |
---|
86328 318722426 |
user output |
---|
(empty) |
Test 24
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 11562 33356 106752 170825 2723... |
correct output |
---|
99873 663048119 |
user output |
---|
(empty) |