ACM-ICPC Xi ' an live game J lol (violence)

Source: Internet
Author: User

Test instructions: Enter five lengths of 100 01 strings, choose from each string is a 1 position, any two string selection of the location can not be the same, the total number of cases, the answer is multiplied by the constant 531192758 and then the 1e9+7 modulo.


If the DFS complexity for the five strings is 10^10 steady T, then the contribution of the last string to the first four strings of Dfs is added directly to the final answer. The DFS parameters are the first X string and the fifth string where the sum of 1 is not selected.

The code is as follows

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <
String> #include <queue> using namespace std;
typedef pair<int,int>pp;
const int mod = 1E9+7;
Char he[5][105];
int vis[105];
Long long ans;
        void solve (int x,int sum) {if (x = = 4) {ans = (ans + sum)%mod;
    return; } for (int i = 0; i < i++) {if (he[x][i] = = ' 1 ' &&!vis[i]) {Vis[i] =
            1;
            if (he[4][i] = = ' 1 ') solve (x+1,sum-1);
            else solve (x+1,sum);
        Vis[i] = 0;
       }}} int main () {while (scanf ("%s", he[0])! = EOF) {for (int i = 1; i < 5; i++) scanf ("%s", He[i]);
       int su = 0;
       for (int i = 0; i < i++) {if (he[4][i] = = ' 1 ') Su + +;
       } ans = 0;
       memset (vis,0,sizeof (VIS));
       Solve (0,SU);
       Ans = ans * 531192758%mod;
   printf ("%lld\n", ans);
 }
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.