Submission #635963

# Submission time Handle Problem Language Result Execution time Memory
635963 2022-08-27T13:29:26 Z ahmed_shafik Geppetto (COCI15_geppetto) C++17
80 / 80
2 ms 316 KB
#include <bits/stdc++.h>
#define ahmed_is_fast             \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define ld long double
#define cc(n) cout << n << "\n"
#define ccc(n) cout << n << ' '
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mx(a, b) a = max(a, b)
#define mn(a, b) a = min(a, b)
#define mem(a, b) memset(a, b, sizeof(a))
#define f(a) a.first
#define s(a) a.second
#define lcm(a, b) (a * b) / __gcd(a, b)
#define sp(x) setprecision(x)
using namespace std;
const ll mx=21;
ll n,m;
vector<ll> arr[mx];
bool u[mx];
ll rec(ll x)
{
    if(x==n)
    {
        return 1;
    }
    ll r=rec(x+1);
    bool ok=1;
    for (auto v: arr[x])
    if (u[v]) ok = 0;

  if (ok){
    u[x] = 1;
    r += rec(x+1);
    u[x] = 0;
  }

  return r;
}
void ahmed()
{
    
    cin>>n>>m;
    for(ll i=0; i<m; i++)
    {
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        arr[x].push_back(y);
        arr[y].push_back(x);
    }
    cout<<rec(0)<<endl;
}
bool AHMED = false;
int main()
{
    ahmed_is_fast;
    ll t = 1;
    if (AHMED)
    {
        cin >> t;
    }
    while (t--)
    {
        ahmed();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct