"BZOJ-1923" alien thousand-legged insect Gaussian elimination element + XOR equations

Source: Internet
Author: User
Tags bitset

1923: [Sdoi2010] alien foot worm time limit:10 Sec Memory limit:64 MB
submit:766 solved:485
[Submit] [Status] [Discuss] Description input the first line is a two positive integer N, M. Next M-line, in order to give Charles this m-time using the "Point foot machine" statistical results. Each line contains a "01" string and a number, separated by a space. The "01" string in turn indicates whether each worm is put into the machine: if the first character is "0" then the worm that is numbered I is not put in, "1" is already put. The following numbers are the results of the statistics of the Insect Foot mod 2. Due to the accuracy of NASA's experimental machines, the data is guaranteed to be inconsistent. That is, the given data must have a solution. Output has a n+1 line when there is a unique solution to the given data, the first line outputs a positive integer k not exceeding m, indicating that the unique solution can be determined at the end of the K-Statistic, and then the next N-line answers each thousand-foot worm's identity, and if the odd number of feet outputs "? y7m#" (Martian text) Earth. " If there are multiple solutions to the input data, the output is "cannot determine". All outputs are not quoted, please note the case when outputting. Sample Input3 5
011 1
110 1
101 0
111 1
010 1Sample Output4
Earth
? y7m#
EarthHINT

For 20% of data, meet n=m≤20;
For 40% of data, meet n=m≤500;
For 70% of data, meet n≤500,m≤1,000;
For 100% of data, meet n≤1,000,m≤2,000.

==========================================================
Please do not submit!

Source

First round Day1

Solution

The topic description is very clear, is to give some equations, solve the equations

General solution to the problem of the type of equation common way: Gaussian elimination of the hard solution/transformation model using the shortest circuit/transformation model to utilize the network flow

The following two kinds of not how to contact, so here can only consider the Gaussian elimination of the hard solution, the general equations to change the solution to the different or better.

Here to learn some of the bitset skills, in fact, not very skilled, and then look at the Bitset

Code
#include <iostream>#include<cstdio>#include<cmath>#include<algorithm>#include<bitset>#include<cstring>#include<cstdlib>using namespaceStd;bitset<1005> a[ .];intb[ .],n,m,ans;Chars[ .];intGauss () { for(intI=1; i<=n; i++)        {            intj=i;  while(J<=m &&!) A[j][i]) J + +; if(j==m+1)return 0; Ans=Max (ANS,J);            Swap (a[i],a[j]);  for(intk=1; k<=m; k++)                if(I!=k &&A[k][i]) A[K]^=A[i]; }    return 1;}intMain () {scanf ("%d%d",&n,&m);  for(intI=1; i<=m; i++) {scanf ("%s%d",s,&B[i]);  for(intj=0; j<=n-1; J + +) a[i][j+1]=s[j]-'0'; A[i][n+1]=B[i]; }    intok=Gauss (); if(! OK) {puts ("cannot determine");return 0;} printf ("%d\n", ans);  for(intI=1; i<=n; i++)        if(a[i][n+1]) puts ("? y7m#"); ElsePuts"Earth"); return 0;}

"BZOJ-1923" alien thousand-legged insect Gaussian elimination element + XOR equations

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.