hiho week 220 register

Ended

Participants:659

Verdict:Accepted
Score:100 / 100
Submitted:2018-09-15 20:59:59

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <vector>
#include <string>
using namespace std;
bool visited[8];
char str[20];
void dfs(int nums, int len, int n)
{
    if (nums == n)
    {
        str[len] = '\0';
        std::cout << str + 1 << std::endl;
        return;
    }
    //'-'
    if (str[len - 1] != '-')
    {
        str[len] = '-';
        dfs(nums, len + 1, n);
    }
    for (int i = 1; i <= n; i++)
    {
        if (visited[i]) continue;
        if (str[len - 1] == '-' || str[len - 1] < (i + '0'))
        {
            str[len] = (i + '0');
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX