Submission #107297

# Submission time Handle Problem Language Result Execution time Memory
107297 2019-04-23T07:35:12 Z kuroni Duathlon (APIO18_duathlon) C++14
5 / 100
40 ms 640 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int N = 11;

int n, m, u, v;
long long ans = 0;
bool vis[N][1 << N];
vector<int> adj[N];

bool get_ans(int st, int mi, int en)
{
    for (int i = 0; i <= n; i++)
        for (int j = 0; j < (1 << n + 1); j++)
            vis[i][j] = false;
    vis[st][1 << st] = true;
    for (int msk = 0; msk < (1 << n + 1); msk++)
        for (int ls = 1; ls <= n; ls++)
            if (vis[ls][msk])
            {
                if (ls == en && (msk >> mi & 1))
                    return true;
                for (int &v : adj[ls])
                    if (!(msk >> v & 1))
                        vis[v][msk ^ (1 << v)] = true;
            }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    while (m--)
    {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            for (int k = 1; k <= n; k++)
                if (i != j && i != k && j != k)
                    ans += get_ans(i, j, k);
    cout << ans;
}

Compilation message

count_triplets.cpp: In function 'bool get_ans(int, int, int)':
count_triplets.cpp:17:37: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
         for (int j = 0; j < (1 << n + 1); j++)
                                   ~~^~~
count_triplets.cpp:20:37: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
     for (int msk = 0; msk < (1 << n + 1); msk++)
                                   ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 33 ms 384 KB Output is correct
8 Correct 21 ms 384 KB Output is correct
9 Correct 26 ms 512 KB Output is correct
10 Correct 29 ms 404 KB Output is correct
11 Correct 35 ms 384 KB Output is correct
12 Correct 28 ms 384 KB Output is correct
13 Correct 22 ms 400 KB Output is correct
14 Correct 21 ms 384 KB Output is correct
15 Correct 31 ms 396 KB Output is correct
16 Correct 38 ms 412 KB Output is correct
17 Correct 19 ms 384 KB Output is correct
18 Correct 22 ms 384 KB Output is correct
19 Correct 26 ms 384 KB Output is correct
20 Correct 28 ms 436 KB Output is correct
21 Correct 28 ms 396 KB Output is correct
22 Correct 24 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 10 ms 384 KB Output is correct
26 Correct 40 ms 400 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
29 Correct 27 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 11 ms 384 KB Output is correct
32 Correct 23 ms 384 KB Output is correct
33 Correct 12 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 28 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 33 ms 384 KB Output is correct
8 Correct 21 ms 384 KB Output is correct
9 Correct 26 ms 512 KB Output is correct
10 Correct 29 ms 404 KB Output is correct
11 Correct 35 ms 384 KB Output is correct
12 Correct 28 ms 384 KB Output is correct
13 Correct 22 ms 400 KB Output is correct
14 Correct 21 ms 384 KB Output is correct
15 Correct 31 ms 396 KB Output is correct
16 Correct 38 ms 412 KB Output is correct
17 Correct 19 ms 384 KB Output is correct
18 Correct 22 ms 384 KB Output is correct
19 Correct 26 ms 384 KB Output is correct
20 Correct 28 ms 436 KB Output is correct
21 Correct 28 ms 396 KB Output is correct
22 Correct 24 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 10 ms 384 KB Output is correct
26 Correct 40 ms 400 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
29 Correct 27 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 11 ms 384 KB Output is correct
32 Correct 23 ms 384 KB Output is correct
33 Correct 12 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 28 ms 384 KB Output is correct
36 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 33 ms 384 KB Output is correct
8 Correct 21 ms 384 KB Output is correct
9 Correct 26 ms 512 KB Output is correct
10 Correct 29 ms 404 KB Output is correct
11 Correct 35 ms 384 KB Output is correct
12 Correct 28 ms 384 KB Output is correct
13 Correct 22 ms 400 KB Output is correct
14 Correct 21 ms 384 KB Output is correct
15 Correct 31 ms 396 KB Output is correct
16 Correct 38 ms 412 KB Output is correct
17 Correct 19 ms 384 KB Output is correct
18 Correct 22 ms 384 KB Output is correct
19 Correct 26 ms 384 KB Output is correct
20 Correct 28 ms 436 KB Output is correct
21 Correct 28 ms 396 KB Output is correct
22 Correct 24 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 10 ms 384 KB Output is correct
26 Correct 40 ms 400 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
29 Correct 27 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 11 ms 384 KB Output is correct
32 Correct 23 ms 384 KB Output is correct
33 Correct 12 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 28 ms 384 KB Output is correct
36 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 33 ms 384 KB Output is correct
8 Correct 21 ms 384 KB Output is correct
9 Correct 26 ms 512 KB Output is correct
10 Correct 29 ms 404 KB Output is correct
11 Correct 35 ms 384 KB Output is correct
12 Correct 28 ms 384 KB Output is correct
13 Correct 22 ms 400 KB Output is correct
14 Correct 21 ms 384 KB Output is correct
15 Correct 31 ms 396 KB Output is correct
16 Correct 38 ms 412 KB Output is correct
17 Correct 19 ms 384 KB Output is correct
18 Correct 22 ms 384 KB Output is correct
19 Correct 26 ms 384 KB Output is correct
20 Correct 28 ms 436 KB Output is correct
21 Correct 28 ms 396 KB Output is correct
22 Correct 24 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 10 ms 384 KB Output is correct
26 Correct 40 ms 400 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
29 Correct 27 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 11 ms 384 KB Output is correct
32 Correct 23 ms 384 KB Output is correct
33 Correct 12 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 28 ms 384 KB Output is correct
36 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Halted 0 ms 0 KB -