Task: | Merkkijono |
Sender: | Pauli Kauro |
Submission time: | 2020-02-09 12:39:29 +0200 |
Language: | C++11 |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 16 |
#2 | ACCEPTED | 26 |
#3 | ACCEPTED | 58 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.01 s | 2, 3 | details |
#6 | ACCEPTED | 0.01 s | 2, 3 | details |
#7 | ACCEPTED | 0.01 s | 2, 3 | details |
#8 | ACCEPTED | 0.01 s | 2, 3 | details |
#9 | ACCEPTED | 0.01 s | 2, 3 | details |
#10 | ACCEPTED | 0.01 s | 2, 3 | details |
#11 | ACCEPTED | 0.01 s | 3 | details |
#12 | ACCEPTED | 0.01 s | 3 | details |
#13 | ACCEPTED | 0.01 s | 3 | details |
#14 | ACCEPTED | 0.01 s | 3 | details |
#15 | ACCEPTED | 0.01 s | 3 | details |
#16 | ACCEPTED | 0.01 s | 3 | details |
#17 | ACCEPTED | 0.01 s | 3 | details |
#18 | ACCEPTED | 0.01 s | 3 | details |
#19 | ACCEPTED | 0.01 s | 3 | details |
#20 | ACCEPTED | 0.01 s | 3 | details |
#21 | ACCEPTED | 0.01 s | 3 | details |
#22 | ACCEPTED | 0.01 s | 3 | details |
#23 | ACCEPTED | 0.01 s | 3 | details |
#24 | ACCEPTED | 0.01 s | 3 | details |
#25 | ACCEPTED | 0.01 s | 3 | details |
#26 | ACCEPTED | 0.01 s | 3 | details |
Code
#include <bits/stdc++.h> using namespace std; using ll = long long; string s; ll n; ll lastpos[8]; vector<ll> nums {1, 3, 5, 7}; string nums_str = "01234567"; bool haku(ll k) { if (k == n) return true; for (ll num : nums) { if (k - lastpos[num] - 1 < num) continue; ll old = lastpos[num]; lastpos[num] = k; s.push_back(nums_str[num]); if (haku(k + 1)) return true; s.pop_back(); lastpos[num] = old; } return false; } int main() { cin >> n; fill_n(lastpos, 8, -100); haku(0); cout << s << endl; return 0; }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
2 |
correct output |
---|
13 |
user output |
---|
13 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
131 |
user output |
---|
131 |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
4 |
correct output |
---|
1317 |
user output |
---|
1315 |
Test 5
Group: 2, 3
Verdict: ACCEPTED
input |
---|
5 |
correct output |
---|
13171 |
user output |
---|
13151 |
Test 6
Group: 2, 3
Verdict: ACCEPTED
input |
---|
6 |
correct output |
---|
131713 |
user output |
---|
131513 |
Test 7
Group: 2, 3
Verdict: ACCEPTED
input |
---|
7 |
correct output |
---|
1317131 |
user output |
---|
1315131 |
Test 8
Group: 2, 3
Verdict: ACCEPTED
input |
---|
8 |
correct output |
---|
13171315 |
user output |
---|
13151317 |
Test 9
Group: 2, 3
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
131713151 |
user output |
---|
131513171 |
Test 10
Group: 2, 3
Verdict: ACCEPTED
input |
---|
10 |
correct output |
---|
1317131513 |
user output |
---|
1315131713 |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
11 |
correct output |
---|
13171315131 |
user output |
---|
13151317131 |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
12 |
correct output |
---|
131713151317 |
user output |
---|
131513171315 |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
13 |
correct output |
---|
1317131513171 |
user output |
---|
1315131713151 |
Test 14
Group: 3
Verdict: ACCEPTED
input |
---|
14 |
correct output |
---|
13171315131713 |
user output |
---|
13151317131513 |
Test 15
Group: 3
Verdict: ACCEPTED
input |
---|
15 |
correct output |
---|
131713151317131 |
user output |
---|
131513171315131 |
Test 16
Group: 3
Verdict: ACCEPTED
input |
---|
16 |
correct output |
---|
1317131513171315 |
user output |
---|
1315131713151317 |
Test 17
Group: 3
Verdict: ACCEPTED
input |
---|
17 |
correct output |
---|
13171315131713151 |
user output |
---|
13151317131513171 |
Test 18
Group: 3
Verdict: ACCEPTED
input |
---|
18 |
correct output |
---|
131713151317131513 |
user output |
---|
131513171315131713 |
Test 19
Group: 3
Verdict: ACCEPTED
input |
---|
19 |
correct output |
---|
1317131513171315131 |
user output |
---|
1315131713151317131 |
Test 20
Group: 3
Verdict: ACCEPTED
input |
---|
20 |
correct output |
---|
13171315131713151317 |
user output |
---|
13151317131513171315 |
Test 21
Group: 3
Verdict: ACCEPTED
input |
---|
40 |
correct output |
---|
131713151317131513171315131713... |
user output |
---|
131513171315131713151317131513... |
Test 22
Group: 3
Verdict: ACCEPTED
input |
---|
128 |
correct output |
---|
131713151317131513171315131713... |
user output |
---|
131513171315131713151317131513... Truncated |
Test 23
Group: 3
Verdict: ACCEPTED
input |
---|
582 |
correct output |
---|
131713151317131513171315131713... |
user output |
---|
131513171315131713151317131513... Truncated |
Test 24
Group: 3
Verdict: ACCEPTED
input |
---|
891 |
correct output |
---|
131713151317131513171315131713... |
user output |
---|
131513171315131713151317131513... Truncated |
Test 25
Group: 3
Verdict: ACCEPTED
input |
---|
999 |
correct output |
---|
131713151317131513171315131713... |
user output |
---|
131513171315131713151317131513... Truncated |
Test 26
Group: 3
Verdict: ACCEPTED
input |
---|
1000 |
correct output |
---|
131713151317131513171315131713... |
user output |
---|
131513171315131713151317131513... Truncated |