1 solutions

  • 1
    @ 2024-6-1 16:16:48

    #include

    const int N(26); struct Book { int a,b; }book[26]; int n,ans; bool use[N];

    void DFS(int now) { if(now==n+1) { ans++; return ; } if(!use[book[now].a]) { use[book[now].a]=1; DFS(now+1); use[book[now].a]=0; } if(!use[book[now].b]) { use[book[now].b]=1; DFS(now+1); use[book[now].b]=0; } }

    int Presist() { scanf("%d",&n); for(int i=1; i<=n; ++i) scanf("%d%d",&book[i].a,&book[i].b); DFS(1); if(!n) ans=0; printf("%d\n",ans); return 0; }

    int Aptal=Presist(); int main(int argc,char*argv[]){;}

    • 1

    Information

    ID
    647
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    2
    Tags
    # Submissions
    22
    Accepted
    12
    Uploaded By