답안 #209701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209701 2020-03-15T09:39:36 Z gratus907 Paths (BOI18_paths) C++17
70 / 100
551 ms 101244 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]!=-1)
        return memo[r][use];
    if (use & (1<<color[r]))
        return memo[r][use] = 0;
    int cur = use;
    use |= (1<<color[r]);
    int res = 1;
    for (auto it:G[r])
    {
        res += dfs(it, use);
    }
    memo[r][cur] = res;
    return memo[r][cur];
}
int32_t main()
{
    usecppio
    memset(memo,-1,sizeof(memo));
    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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 83320 KB Output is correct
2 Correct 46 ms 83320 KB Output is correct
3 Correct 47 ms 83320 KB Output is correct
4 Correct 47 ms 83320 KB Output is correct
5 Correct 47 ms 83320 KB Output is correct
6 Correct 47 ms 83368 KB Output is correct
7 Correct 48 ms 83320 KB Output is correct
8 Correct 46 ms 83320 KB Output is correct
9 Correct 48 ms 83320 KB Output is correct
10 Correct 48 ms 83320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 90536 KB Output is correct
2 Correct 106 ms 92664 KB Output is correct
3 Correct 456 ms 100728 KB Output is correct
4 Correct 180 ms 95096 KB Output is correct
5 Correct 162 ms 95072 KB Output is correct
6 Correct 301 ms 97860 KB Output is correct
7 Correct 474 ms 100600 KB Output is correct
8 Correct 418 ms 101240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 83320 KB Output is correct
2 Correct 46 ms 83320 KB Output is correct
3 Correct 47 ms 83320 KB Output is correct
4 Correct 47 ms 83320 KB Output is correct
5 Correct 47 ms 83320 KB Output is correct
6 Correct 47 ms 83368 KB Output is correct
7 Correct 48 ms 83320 KB Output is correct
8 Correct 46 ms 83320 KB Output is correct
9 Correct 48 ms 83320 KB Output is correct
10 Correct 48 ms 83320 KB Output is correct
11 Correct 121 ms 90536 KB Output is correct
12 Correct 106 ms 92664 KB Output is correct
13 Correct 456 ms 100728 KB Output is correct
14 Correct 180 ms 95096 KB Output is correct
15 Correct 162 ms 95072 KB Output is correct
16 Correct 301 ms 97860 KB Output is correct
17 Correct 474 ms 100600 KB Output is correct
18 Correct 418 ms 101240 KB Output is correct
19 Correct 125 ms 93304 KB Output is correct
20 Correct 99 ms 92668 KB Output is correct
21 Correct 457 ms 100728 KB Output is correct
22 Correct 168 ms 95096 KB Output is correct
23 Correct 161 ms 95096 KB Output is correct
24 Correct 296 ms 97896 KB Output is correct
25 Correct 461 ms 100732 KB Output is correct
26 Correct 411 ms 101244 KB Output is correct
27 Correct 107 ms 92616 KB Output is correct
28 Correct 141 ms 94784 KB Output is correct
29 Correct 551 ms 100860 KB Output is correct
30 Correct 390 ms 97252 KB Output is correct
31 Correct 413 ms 97384 KB Output is correct
32 Correct 551 ms 100728 KB Output is correct
33 Correct 46 ms 83320 KB Output is correct
34 Correct 47 ms 83320 KB Output is correct
35 Correct 46 ms 83320 KB Output is correct
36 Correct 45 ms 83320 KB Output is correct
37 Correct 47 ms 83324 KB Output is correct
38 Correct 46 ms 83320 KB Output is correct
39 Correct 45 ms 83320 KB Output is correct
40 Correct 45 ms 83320 KB Output is correct
41 Correct 47 ms 83320 KB Output is correct
42 Correct 46 ms 83320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 83320 KB Output is correct
2 Incorrect 67 ms 85496 KB Output isn't correct
3 Halted 0 ms 0 KB -