Submission #649199

# Submission time Handle Problem Language Result Execution time Memory
649199 2022-10-09T15:16:27 Z boris_mihov NoM (RMI21_nom) C++17
0 / 100
0 ms 212 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <set>

typedef long long llong;
const int MAXN = 2000 + 10;
const int MOD  = 1e9 + 7;
const int INF  = 1e9;

int n, m;
int perm[MAXN];
int pos[MAXN];
void solve()
{
    int ans = 0;
    for (int i = 1 ; i <= n ; ++i)
    {
        perm[2*i - 1] = i;
        perm[2*i] = i;
    }
    
    do
    {
        bool valid = true;
        std::fill(pos + 1, pos + 1 + n, 0);
        for (int i = 1 ; i <= 2*n ; ++i)
        {
            if (pos[perm[i]] == 0)
            {
                pos[perm[i]] = i;
            } else
            {
                if ((i - pos[perm[i]]) % m == 0)
                {
                    valid = false;
                    break;
                }
            }
        }

        ans += valid;
    } while(std::next_permutation(perm + 1, perm + 1 + 2*n));
    std::cout << ans << '\n';
}

void read() 
{
    std::cin >> n >> m;
}

void fastIO()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

int main()
{
    fastIO();
    read();
    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -