UVa 253 Dice Coloring

Source: Internet
Author: User

https://vjudge.net/problem/UVA-253

Test instructions: Enter the six-sided color of the two dice and determine if it is equivalent.

Idea: The most I think of is violence, but always wrong, do not know where is wrong. The second method is to appear in a dice in a pair of colors in the second dice also have, as long as three pairs of colors are matched successfully, then is equivalent.

1#include <iostream>2#include <string>3#include <cstring>4 using namespacestd;5 6 Charstr[ -];7 intvis[ -];8 intOK;9 Ten intMain () One { A     //freopen ("D:\\txt.txt", "R", stdin); -      while(Gets (str)! =NULL) -     { theOK =1; -memset (Vis,0,sizeof(Vis)); -          for(inti =0; I <3; i++) -          for(intj =6; J < A; J + +) +         { -             if(!vis[j] && str[i] = = Str[j] && str[5-I] = = str[ --J]) +             { AVIS[J] = vis[ --J] =1; at                  Break;//This break has to be added. -             } -         } -          for(inti =6; I < A; i++) -         { -             if(!Vis[i]) in             { -OK =0; tocout <<"FALSE"<<Endl; +                  Break; -             } the         } *         if(OK) cout <<"TRUE"<<Endl; $     }Panax Notoginseng     return 0; -}

With my violence, it's just wrong. Just keep it, and maybe I'll find out what's wrong in the future.

1#include <iostream>2#include <string>3#include <cstring>4 using namespacestd;5 6 Charstr[ -], s1[7], s2[7], s3[7], s4[7];7 intvis[ -];8 intOK;9 Ten voidSolveintcur) One { A     if(cur = =3) -     { -s3[6] =' /'; the          for(intK =0; K <3; k++) -         { -S4[k] = s3[k +3]; -S4[k +3] =S3[k]; +         } -s4[6] =' /'; +         if(!STRCMP (S1, s3) | |!strcmp (S1, S4)) A         { atOK =1; -         } -     } -     Else -     { -          for(inti =0; I <3; i++) in         { -             if(OK)return; to             if(!Vis[i]) +             { -S3[cur] =S2[i]; thes3[5-cur] = s2[5-i]; *Vis[i] =1; $Solve (cur +1);Panax NotoginsengVis[i] =0; -             } the         } +     } A } the  + intMain () - { $     //freopen ("D:\\txt.txt", "R", stdin); $      while(Gets (str)! =NULL) -     { -memset (Vis,0,sizeof(Vis)); thememcpy (S1, str,6); -memcpy (S2, str +6,6);Wuyis1[6] =' /'; thes2[6] =' /'; -OK =0; WuSolve0); -         if(OK) cout <<"TRUE"<<Endl; About         Elsecout <<"FALSE"<<Endl; $     } -     return 0; -}

UVa 253 Dice Coloring

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.