problem with implementing this question of codechef

Pages: 1... 910111213

@all

My all substaks all clear in TWO FLOWERS accept only 1 subtask in all....
@ghostrideriit pm me
@ghostrideriit pm me

@ wasp

Bro, i m trying to clear my remaining 1 substask....

if i done i will discuss my algo ....

really it is just a 2 min. code and somewhat similar to sheokand and string ......
@all can anyone give me partial correct code for TWO FLOWERS. pm me please
Last edited on
@yobro please pm me
Last edited on
@yobro pm me also plz
@Wasp can you give me any code after vision problem if you done. pm me if you done any
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

#include <stdio.h>
#define V(x,y) ((((x) >= 0 && (x) < r) && ((y) >= 0 && (y) < c)) ? 1 : 0)

int A[100][100],curr,r,c;

void visit(int i, int j) {
    ++curr;
    A[i][j] = 0;
    /*if(V(i-1,j-1) && A[i-1][j-1])
        visit(i-1,j-1);*/
    if(V(i-1,j) && A[i-1][j])
        visit(i-1,j);
   /* if(V(i-1,j+1) && A[i-1][j+1])
        visit(i-1,j+1);*/
    if(V(i,j-1) && A[i][j-1])
        visit(i,j-1);
    if(V(i,j+1) && A[i][j+1])
        visit(i,j+1);
   /* if(V(i+1,j-1) && A[i+1][j-1])
        visit(i+1,j-1);*/
    if(V(i+1,j) && A[i+1][j])
        visit(i+1,j);
   /* if(V(i+1,j+1) && A[i+1][j+1])
        visit(i+1,j+1);*/
}

int main() {
    int i,j,max = 0;
    
    scanf("%d\n%d",&r,&c);
    for(i = 0; i < r; ++i)
        for(j = 0; j < c; ++j) 
        {  scanf("%d",&A[i][j]);
         if(A[i][j]==1||A[i][j]==2)
             A[i][j]=1;
         else
             A[i][j]=0;
         
         
        }
    
    for(i = 0; i < r; ++i)
        for(j = 0; j < c; ++j)
            if(A[i][j] == 1) {
                curr = 0;
                visit(i,j);
                if(curr > max)
                    max = curr;
            }
    printf("%d",max);
    return 0;
}






it gives me two test cases correct answer anyone find my error plz

1 0 WA
(0.000000)
1 1 AC
(0.000000)
1 2 WA
(0.000000)
1 3 WA
(0.000000)
1 4 AC
(0.000000)
Subtask Score: 0.00% Result - WA
2 5 WA
(0.010000)
2 6 RE (SIGSEGV)
(0.000000)
2 7 WA
(0.010000)
2 8 WA
(0.010000)
2 9 WA
(0.000000)
Subtask Score: 0.00% Result - WA
3 10 WA
(0.000000)
3 11 RE (SIGSEGV)
(0.010000)
3 12 WA
(0.010000)
3 13 WA
(0.010000)
3 14 WA
(0.010000)
Subtask Score: 0.00% Result - WA
Last edited on
has anyone done the two flower problem.
@ghostrideriit
have you done
if so then please provide the pseudocode please
if anyone give me partial or fully accepted code of last three problem then i will you Two flower pratial correct.

Home » June Challenge 2018 Division 2 » Two Flowers » Successful Submission
Successful Submission


Correct Answer
Execution Time: 0.21

Sub-Task Task # Result
(time)
1 0 AC
(0.190000)
1 1 AC
(0.180000)
1 2 AC
(0.210000)
1 3 AC
(0.210000)
1 4 AC
(0.200000)
Subtask Score: 20.00% Result - AC
2 5 RE (SIGSEGV)
(0.000000)
2 6 RE (SIGSEGV)
(0.010000)
2 7 RE (SIGSEGV)
(0.010000)
2 8 RE (SIGSEGV)
(0.010000)
2 9 RE (SIGSEGV)
(0.000000)
Subtask Score: 0.00% Result - RE
3 10 RE (SIGSEGV)
(0.010000)
3 11 RE (SIGSEGV)
(0.000000)
3 12 RE (SIGSEGV)
(0.010000)
3 13 RE (SIGSEGV)
(0.010000)
3 14 RE (SIGSEGV)
(0.000000)
Last edited on
those who are struggling to get partial correct for two flower then go to at https://www.hackerrank.com/challenges/connected-cell-in-a-grid/problem and try brute force to get answer.
tip1:- skip the diagonal condition
run while loop for 100 times combination of 1and other 100 and 2and other 100 and so on.
Last edited on
closed account (jy6DLyTq)
any hint for workways problem?
Nice one @ipg. :P
@ipg can u explain a bit little more
@iitkgpian In this question, we have to find the maximum area which contains only two values at most and these 2 values can be any value...So why are you substituting 1 and 2 as 1 and disregarding all the other values by putting it as 0?There is a high possibility that the largest area may contain any other type of flowers apart from 1 and 2...Or have I misinterpreted the question or your algorithm?
Last edited on
@honeybuzz, you are right. It's not necessary that we choose 1 and 2 only. There can be a much bigger area with other types as well. That is what makes it so difficult. :/
If any of you fellas still have problem with VISION question. Problems like, your code is passing the first test case only or your code is not working under original constraints then use one thing : cout.precision(15) after declaring the values of double a,b,c which are the coefficients of t.
Please guys, don't become a pimp for getting the points for questions. It's a request. This site is for helping you guys with any error in your code or getting some hints regarding the question but not the code of the whole question. I hope you guys will understand. :)
Keep hustling, Keep coding!
Last edited on
@ihavenoname yeah I though so...Else it would have been much easier...I don't understand why people are mixing it up with the hackerrank problem...
closed account (jy6DLyTq)
@quirky1234 can u provide some hints regarding ways to work problem
Pages: 1... 910111213