Consider the test input:
1
12
1 2 3 4 5 6 7 8 9 10 11
19 17 18 16 15 14 13 12 11 10 9
Consider the test input:
1
12
1 2 3 4 5 6 7 8 9 10 11
19 17 18 16 15 14 13 12 11 10 9
That was intended for you, yes Which constraint does it violate (I didn’t actually do this problem :p)?
Whoops - silly me Try this one:
1
12
1 2 3 4 5 6 7 8 9 10 11 12
19 17 18 16 15 14 13 12 11 10 9 8
It fails on the following test input (hopefully I’ve gotten it right this time :)):
1
8
14 11 10 4 7 1 13 16
14 11 8 15 16 1 5 3
If we take a[0] % n and search for n - a[0] %n if its present in array b[I] % n we can get max 2 values else we take atmost two values which is smallest among them (if a[I] is zero we search for zero)
Correct me if I’m wrong
what does the term " pairwise distinct elements " means . Cant it simply be " distinct " ?
Or its just for confusing ?
It means if we take any two numbers from the array it should not be same
Consider the test input:
1
2
2 1
2 4
Hey @cherry0697 could you please help me with the solution of mine it’s giiving WA but I am trying to do the exact same thing.
Solution link : CodeChef: Practical coding for everyone
firstly there can be atmost two minIdx
and you are finding only one
Next you are trying to find minIdx
without knowing the minimum value ,i.e you are finiding both
minIdx
and maxv
in the same loop withouth knowing the value you need. This seems to be a logical error.
If there is any mistake in my interpretation of your code please correct me.
can someone please tell me what’s wrong with my solution :
https://www.codechef.com/viewsolution/49349820
Out of bounds access on the following test input:
1
9
12 8 15 5 1 2 3 13 4
3 14 5 16 2 7 4 18 13
[simon@simon-laptop][07:53:02]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh
Compiling rishabhpandey7-ARRT.cpp
+ g++ -std=c++14 rishabhpandey7-ARRT.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv -fno-sanitize-recover
rishabhpandey7-ARRT.cpp: In function ‘void solve()’:
rishabhpandey7-ARRT.cpp:39:12: warning: unused variable ‘rem’ [-Wunused-variable]
ll int rem = inf;
^~~
+ set +x
Successful
[simon@simon-laptop][07:53:11]
[~/devel/hackerrank/otherpeoples]>echo "1
9
12 8 15 5 1 2 3 13 4
3 14 5 16 2 7 4 18 13
" | ./a.out
/usr/include/c++/7/debug/vector:417:
Error: attempt to subscript container with out-of-bounds index 10, but
container only holds 9 elements.
Objects involved in the operation:
sequence "this" @ 0x0x7ffdbe2e57a0 {
type = std::__debug::vector<long long, std::allocator<long long> >;
}
Aborted (core dumped)
This line, according to gdb:
if ( (a[1]+b[ans3+1] && ans3+1<n)%n < (a[1]+b[ans+1] && ans+1<n)%n){
@ssjgz can you please elaborate why the output for the test case you mentioned
gives output
and not
And two possible index of b are ( 1 based ) 2 ang 8 .
This should explain everything you need.