Submission #107295

# Submission time Handle Problem Language Result Execution time Memory
107295 2019-04-23T07:32:52 Z kuroni Duathlon (APIO18_duathlon) C++14
0 / 100
3 ms 512 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 (msk >> ls & 1)
            {
                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 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
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 3 ms 384 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 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 412 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 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -