Submission #209697

# Submission time Handle Problem Language Result Execution time Memory
209697 2020-03-15T09:29:09 Z gratus907 Paths (BOI18_paths) C++17
23 / 100
3000 ms 18680 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
using pii = pair <int, int>;
#define int ll
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;

int n, m, k;
int memo[303030][32];
vector <int> G[303030];
int color[303030];

int dfs(int r, int use)
{
    if (memo[r][use])
        return memo[r][use];
    use |= (1<<color[r]);
    int res = 1;
    for (auto it:G[r])
    {
        if (!(use & (1<<color[it])))
        {
            res += dfs(it, use);
        }
    }
    return (memo[r][use] = res);
}
int32_t main()
{
    usecppio
    cin >> n >> m >> k;
    for (int i = 1; i<=n; i++) cin >> color[i];
    for (int i = 0; i<m; i++)
    {
        int u, v; cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int ans = 0;
    for (int i = 1; i<=n; i++)
        ans += dfs(i, 0);
    cout << ans-n<< '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 9 ms 7544 KB Output is correct
3 Correct 9 ms 7416 KB Output is correct
4 Correct 9 ms 7416 KB Output is correct
5 Correct 9 ms 7544 KB Output is correct
6 Correct 9 ms 7548 KB Output is correct
7 Correct 9 ms 7416 KB Output is correct
8 Correct 9 ms 7544 KB Output is correct
9 Correct 9 ms 7416 KB Output is correct
10 Correct 10 ms 7416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3082 ms 18680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 9 ms 7544 KB Output is correct
3 Correct 9 ms 7416 KB Output is correct
4 Correct 9 ms 7416 KB Output is correct
5 Correct 9 ms 7544 KB Output is correct
6 Correct 9 ms 7548 KB Output is correct
7 Correct 9 ms 7416 KB Output is correct
8 Correct 9 ms 7544 KB Output is correct
9 Correct 9 ms 7416 KB Output is correct
10 Correct 10 ms 7416 KB Output is correct
11 Execution timed out 3082 ms 18680 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Execution timed out 3093 ms 10488 KB Time limit exceeded
3 Halted 0 ms 0 KB -