답안 #869226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869226 2023-11-03T14:27:38 Z sleepntsheep Paths (BOI18_paths) C++17
0 / 100
222 ms 158804 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")

using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
#define N 300005

int n, m, k, c[N];
ll d[2][N][33],z;
array<int, 2> el[N];

int main()
{
    ShinLena;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) cin >> c[i], d[0][i][1<<--c[i]] = 1;
    for (int i = 0; i < m; ++i) cin >> el[i][0] >> el[i][1];
    for (int i = 1; i <= k; ++i)
    {
        for (int j = 0; j < m; ++j) for (int s = 0; s < (1<<k); ++s)  d[i&1][j][s] = 0;
        for (int j = 0; j < m; ++j)
        {
            auto [u, v] = el[j];
            for (int J = 2; J--; swap(u, v))
                for (int s = 0; s < (1<<k); ++s) 
                {
                    ll X = !((s>>c[v])&1)*d[!(i&1)][u][s];
                    d[i&1][v][s|(1<<c[v])] += X, z += X;
                }
        }
    }

    cout << z;

    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Incorrect 1 ms 6492 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 158544 KB Output is correct
2 Correct 72 ms 158588 KB Output is correct
3 Incorrect 222 ms 158804 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Incorrect 1 ms 6492 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -