Uoj #56. "WC2014" Non-deterministic machine

Source: Internet
Author: User
Tags cmath

Test instructions: Give an output file for input.

1. Satisfy the desired input file is a graph, n points, M edge, the algorithm used is K (k in the output file given)

2. Algorithm is graph theory algorithm?!k basically → two-digit number, if the 10-digit number is the same, the basic algorithm may be the same.

3. Give an executable file that can run its own created data in the terminal to guess the algorithm.

4. You can not give a picture of the heavy edge, but there is self-ring, Benquan <=2*10^4

  5.P is a given parameter in the given output file, and this parameter is determined by the graph you have created, in the form of a calculation.

Dig a hole first ... Feeling is a very interesting structure +XJB problem, assuming that the WC, I can engage in 2 half an hour to answer, then ...

   

Muffled roll big thick

(1) The popular 01 matrix, coupled with the example of the sample, is a (I,J) indicates whether there is an I-to-j edge meaning.

  

1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <vector>5#include <cstdlib>6#include <cmath>7#include <cstring>8 using namespacestd;9 #defineMAXN 10010Ten #defineLLG Long Long One #defineYyj (a) freopen (a ".", "R", stdin), Freopen (a ". Out", "w", stdout); A LLG n,m; - intMain () - { theYyj"nm1"); -Cin>>N; -LLG tot=0; -      for(Llg i=1; i<=n;i++) +          for(Llg j=1; j<=n;j++) -         { + LLG x; A             //tot++; atCin>>x; -             if(x) tot++; -             if(x) cout<<i<<" "<<j<<"1"<<Endl; -         } -cout<<tot; -     return 0; in}
View Code

(2) The algorithm number k=10, the new graph theory algorithm, casually makes a diagram to use to give the program to try to find is to 1 as the origin point of the single source shortest, p is the number of sides.

Consider how to construct:

1. It is obvious that one point points to each point the edge of a required weight satisfies the condition of the shortest path, but the number of edges is only n-1, that is, p '!=p, can get 4 points.

2. Follow the above procedure to get the program a test correctness found GG, I did not see Benquan <=2*10^4, OK, according to the shortest short-circuit length ordered, according to the order from the small arrival, if less than 2*10^4 direct and a point connected, otherwise found before the processing point, Moreover, the weight of the current point minus the weighted value of the processed point is less than the one with the least weight in the 2*10^4, taking into account the limit of P, the point after the point of the connected edge of the least weighted value that has been processed and the edge that is connected to the point to be processed will not have an effect on the answer.

    

1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <vector>5#include <cstdlib>6#include <cmath>7#include <cstring>8 using namespacestd;9 #defineMAXN 10010Ten #defineLLG Long Long One #defineYyj (a) freopen (a ".", "R", stdin), Freopen (a ". Out", "w", stdout); A LLG n,m,p,k; - BOOLD[MAXN][MAXN]; -  the structnode - { - LLG P,val; - }A[MAXN]; + BOOLcmpConstNode&a,ConstNODE&AMP;B) {returna.val<B.val;} - intMain () + { AYyj"nm2"); atCin>>n>>k>>p; -      for(Llg i=1; i<=n;i++) -     { -a[i].p=i; -Cin>>A[i].val; -     } inSort (A +1, a+n+1, CMP); -p-=N; top++; +      for(Llg i=2; i<=n;i++) -     { the LLG J; *          for(j=1; j<i;j++)  $             if(a[i].val-a[j].val<=20000) Panax Notoginseng             { -cout<<a[j].p<<" "<<a[i].p<<" "<<a[i].val-a[j].val<<Endl; the                  Break; +             } AJ + +; the          while(p>0&& j<i) +         { -p--; $cout<<a[j].p<<" "<<a[i].p<<" "<<20000<<Endl; $J + +; -         } -     } the     return 0; -}
View Code

(3) algorithm number k=11, well, similar to the shortest way, but this point is still more to try, at first I think is to find the different path of each point of the shortest number, I do not construct ah, and then to try a few sets of data after the discovery:

The shortest path between all points is desired, but it is not related to Benquan, that is, Benguanme considers 1,p as the number of sides.

Meditation..... There's no way. To fight a violent, think of the optimization obviously the equivalent of 1 points in the matrix (x, y) must be connected to an edge. Then there are 400 1. P is also 400, think about it obviously, and even after all the 1 side of the answer is OK.

  

1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <vector>5#include <cstdlib>6#include <cmath>7#include <cstring>8 using namespacestd;9 #defineMAXN 10010Ten #defineLLG Long Long One #defineYyj (a) freopen (a ".", "R", stdin), Freopen (a ". Out", "w", stdout); A LLG n,m,p,k; - BOOLD[MAXN][MAXN]; -  the structnode - { - LLG P,val; - }A[MAXN]; + BOOLcmpConstNode&a,ConstNODE&AMP;B) {returna.val<B.val;} - intMain () + { AYyj"Nm3"); atCin>>n>>k>>p; -cout<<n<<" "<<p<<" "<<k<<Endl; -      for(Llg i=1; i<=n;i++) -     { -          for(Llg j=1; j<=n;j++) -         { in LLG x; -Cin>>x; to             if(x==1) cout<<i<<" "<<j<<"2333"<<Endl; +         } -     } the     return 0; *}
View Code

(4)

(5)

(6)

(7)

(8)

(9)

(10)

Uoj #56. "WC2014" Non-deterministic machine

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.