You are not logged in. Please login at www.codechef.com to post your questions!

×

November Cook-Off

My solution of ONCHESS I got the error.

asked 20 Nov '17, 00:15

gautamcse27's gravatar image

2★gautamcse27
375
accept rate: 0%

edited 20 Nov '17, 07:24

2

Mate,

Improve formatting or provide solution link. :)

(20 Nov '17, 00:16) taran_14076★

Please format your code properly. Select whole code and press Ctrl + K to format it.

(20 Nov '17, 00:17) vatsalsura2★

Please use a better title for asking questions.

link

answered 20 Nov '17, 13:32

admin's gravatar image

0★admin ♦♦
19.7k350498541
accept rate: 35%

How are you removing details of players who are paired?

That's where ur solution is failing i guess. (May be at other points too, can't tell because of bad formatting)

PS:Improve formatting, only then others would be able to help

link

answered 20 Nov '17, 00:26

taran_1407's gravatar image

6★taran_1407
3.8k2383
accept rate: 22%

edited 20 Nov '17, 00:27

You didn't check if rating of j is compatible with i. i.e.

mini[i]<=rating[j]&&rating[j]<=maxi[i]

Also the first if condition is not necessary, you don't need to check constraints of input.

link

answered 20 Nov '17, 00:37

nilesh3105's gravatar image

5★nilesh3105
716210
accept rate: 31%

edited 20 Nov '17, 00:47

1)Timings must be exactly equal, change that line to if(time[i]==time[j])

2)(israted[i]=="rated"||israted[i]=="unrated")&&(israted[j]=="rated"||israted[j]=="unrated")) is always true, you should check whether both are either "rated" or "unrated"

Why are you checking the constraints? The inputs will always satisfy the constraints. Remove unnecessary lines.

Read the question 100 times and then start writing code for it !!!

link

answered 20 Nov '17, 00:43

ramini's gravatar image

2★ramini
615
accept rate: 8%

edited 20 Nov '17, 00:47

1

Reading this Q 100 times is a pain though....

(20 Nov '17, 02:08) vijju123 ♦♦4★

Read the question 100 times and the competition over!!

(21 Nov '17, 06:02) kunnu1202★

please anyone help me !! i have solved this que but it shows wrong answer and i am not able to find any error in my solution... i had also solved the que POLY of NOV challenge for 2nd subtask.. why this happens to me.. please give me some tricks or a way to know where i am wrong...

code for ONCHESS https://www.codechef.com/viewsolution/16321625

#include <iostream>
using namespace std;

struct abc{
    int r;
    int mn;
    int mx;
    int ch; 
};

typedef struct abc s;

int main() 
{
    int T,n,tmp,i,j;
    char str[8];
    cin >> T ;
    while(T--)
    {
        cin >> n ;
        s a[n];
        for(i=0;i<8;i++)
        {
            str[i]=0;
        }
        for(i=0;i<n;i++)
        {
            cin >> a[i].r >> a[i].mn >> a[i].mx >> tmp >> str ;
            if(tmp%2)
            {
                if(tmp%3)
                a[i].ch=0;
                else
                a[i].ch=4;
            }
            else
            {
                if(tmp%4)
                a[i].ch=8;
                else
                a[i].ch=12;
            }
            if(str[0]=='u')
            {
                a[i].ch += 16;
            }
            for(j=0;j<8;j++)
            {
            str[j]=0;
            }
            cin >> str;
            if(str[0]=='r')
            {
                a[i].ch +=2;
                    for(j=0;j<i;j++)
                    {
                        if(a[j].ch%4==2)
                        {
                          if(a[i].r >= a[j].mn && a[i].r <= a[j].mx && a[j].r >= a[i].mn && a[j].r <= a[i].mx )
                          {
                            a[j].ch=-500;
                            a[i].ch=-500;
                            cout << j+1 << endl ;
                            break;
                          }      
                        }
                    }
               if(j!=i)     
               continue;     
            }
            else 
            {
                a[i].ch+=1;  
                if(str[0]=='b')
                a[i].ch*=(-1);
                    for(j=0;j<i;j++)
                    {   
                        if(a[i].ch + a[j].ch == 0)
                        {
                          if(a[i].r >= a[j].mn && a[i].r <= a[j].mx && a[j].r >= a[i].mn && a[j].r <= a[i].mx)  
                          {
                              a[j].ch=-500;
                              a[i].ch=-500;
                              cout << j+1 << endl ; 
                              break;
                          }       
                        }
                    }
               if(j!=i)     
               continue;     
            }    
            cout << "wait" << endl;
        }
    }
    return 0;
}
link

answered 20 Nov '17, 01:57

smit_mandavia's gravatar image

1★smit_mandavia
11
accept rate: 0%

edited 20 Nov '17, 01:59

i had also solved the que POLY of NOV challenge for 2nd subtask.. why this happens to me..

Of what relevance is this line here?

(20 Nov '17, 02:09) vijju123 ♦♦4★

@vijju123 I think he's trying to say that he solved a very hard "poly" problem(Show off) but why he couldn't solve this problem!!

(20 Nov '17, 09:14) kunnu1202★

He solved it only for 30 points, which was easily available on internet. Whats there to show off lol :/

(20 Nov '17, 10:18) vijju123 ♦♦4★

It was on the internet? Dang I missed the chance (ಥـْـِـِـِـْಥ)

(21 Nov '17, 07:34) kunnu1202★

You can try looking at this solution. It is almost as same as yours.

https://www.codechef.com/viewsolution/16320877

link

answered 20 Nov '17, 10:07

shreybatra's gravatar image

3★shreybatra
92
accept rate: 0%

***

> strong text

***Hey, YOU can go through my codes.It is very simple.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int i,j,n,rat[102]={0},min[102]={0},max[102]={0},t[102]={0};
        char israt[102][10],col[102][10],b[10]="black",w[10]="white",ran[10]="random";
        cin>>n;
        for(i=1;i<=n;i++) cin>>rat[i]>>min[i]>>max[i]>>t[i]>>israt[i]>>col[i];
        int check[102]={0};
        for(i=1;i<=n;i++)
        {
            int flag=0;
            if(i==1) cout<<"wait"<<endl;
            else
            {
                for(j=1;j<i; j++)
                {
                    if( (rat[j] <=max[i]) && (rat[j] >=min[i]) && (rat[i] <=max[j]) && (rat[i] >=min[j]) && (t[i]==t[j]) && (strcmp(israt[i],israt[j])==0) && check[j]==0)
                    {
                        if((strcmp(col[i],ran)==0 && strcmp(col[j],ran)==0) || (strcmp(col[j],b)==0 && strcmp(col[i],w)==0 ) || (strcmp(col[j],w)==0 && strcmp(col[i],b)==0))
                        {
                        flag=1;
                        cout<<j<<endl;
                        check[j]=1;
                        check[i]=1;
                        break;
                        }
                        else continue;
                    }
                    else continue;
                }
                if(flag==0) cout<<"wait"<<endl;
            }
        }

    }
    return 0;
}
link

answered 20 Nov '17, 13:48

fad_coder00000's gravatar image

1★fad_coder00000
11
accept rate: 0%

edited 20 Nov '17, 16:46

vijju123's gravatar image

4★vijju123 ♦♦
15.2k11859

@vijju123 , Can u tell me what have u edited in this code ?? I have submitted this code & it worked fine.

(27 Nov '17, 02:10) fad_coder000001★

I fixed the formatting. It was appearing very clumsy if you recall, no new lines and stuff.

(27 Nov '17, 02:36) vijju123 ♦♦4★

ohhh, thanx

(27 Nov '17, 14:36) fad_coder000001★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×530

question asked: 20 Nov '17, 00:15

question was seen: 752 times

last updated: 27 Nov '17, 14:36