Usaco-1.3-combo-pass

Source: Internet
Author: User

Water problems, extreme water, list, but be careful, start to judge that the use of a cycle, actually changed from 249 to 250, after a long time to understand, conditional reuse is conditional. Although the code looks pretty, the result is not correct.

I jumped back to the first layer from the fifth layer. I don't know why:

/*ID: qq104801LANG: C++TASK: comboQQ:104804687*/#include <iostream>#include <fstream>#include <cstring>#include <vector>#include <queue>#include <stack>#include <algorithm>#include <cmath>using namespace std;#define loop(i,n) for(int i=0;i<(n);i++)#define loop2(i,n) for(int i=1;i<=(n);i++)const int maxn=205;const int inf=1<<30;struct combo_key{  int x,y,z;}key[2];int n,ans;bool close(int a,int b){  if(abs(a-b)<=2)return true;  if(abs(a-b)>=n-2)return true;  return false;}void test(){     freopen("combo.in","r",stdin);    freopen("combo.out","w",stdout);   cin>>n;    loop(i,2)      cin>>key[i].x>>key[i].y>>key[i].z;  ans=0;  loop2(i,n)    loop2(j,n)      loop2(k,n)                               if((close(i,key[0].x) && close(j,key[0].y) && close(k,key[0].z))           ||(close(i,key[1].x) && close(j,key[1].y) && close(k,key[1].z)))            ans++;   cout<<ans<<endl;  }int main () {            test();            return 0;}

Test data:

USACO TrainingGrader Results     15 users onlineCHN/6 TWN/1 USA/8USER: cn tom [qq104801]TASK: comboLANG: C++Compiling...Compile: OKExecuting...   Test 1: TEST OK [0.005 secs, 3376 KB]   Test 2: TEST OK [0.005 secs, 3376 KB]   Test 3: TEST OK [0.008 secs, 3376 KB]   Test 4: TEST OK [0.005 secs, 3376 KB]   Test 5: TEST OK [0.005 secs, 3376 KB]   Test 6: TEST OK [0.008 secs, 3376 KB]   Test 7: TEST OK [0.008 secs, 3376 KB]   Test 8: TEST OK [0.011 secs, 3376 KB]   Test 9: TEST OK [0.008 secs, 3376 KB]   Test 10: TEST OK [0.019 secs, 3376 KB]All tests OK.Your program (‘combo‘) produced all correct answers! This is your submission #2 for this problem. Congratulations!Here are the test data inputs:------- test 1 [length 15 bytes] ----501 2 35 6 7------- test 2 [length 14 bytes] ----11 1 11 1 1------- test 3 [length 14 bytes] ----41 2 32 3 4------- test 4 [length 15 bytes] ----109 9 93 3 3------- test 5 [length 18 bytes] ----5049 50 150 1 2------- test 6 [length 18 bytes] ----955 6 770 80 90------- test 7 [length 22 bytes] ----100100 100 1001 1 1------- test 8 [length 21 bytes] ----1001 50 1002 51 99------- test 9 [length 22 bytes] ----1001 100 991 100 98------- test 10 [length 18 bytes] ----100100 1 24 5 6Keep up the good work!Thanks for your submission!
View code

 

Usaco-1.3-combo-pass

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.