Thanks for pointing out the error.
thanks for considering the subtask and giving the solution for that also
Why my solution is giving TLE . I have done the same thing
https://www.codechef.com/viewsolution/48385136
Their loss
Consider the test input:
2
3 4 2
1 1
3 1
1 2
2 3
2 1
2 4
3 2
3 4
1 3
3 3
2 2
1 4
3 4 2
1 1
3 1
1 2
2 3
2 1
2 4
3 2
3 4
1 3
3 3
2 2
1 4
Great Editorial. I must say, CC’s Editorails are better than CF’s in some rated contests.
Kudos !!!
what is its output
It’s just the sample input from the Problem Statement, repeated, so:
Bob
Bob
and what should be the correct output for this
Alice
Win at turn # 33 for: Alice:
B B A A A A B
B B A A A B A
B B A[A]A B B
B A B B A B .
. A B A B A A
can someone explain why I am getting runtime error.
Oh sorry
No problem; thanks!
Edit:
Out-of-bounds access on the sample test input:
[simon@simon-laptop][17:59:46]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh
Compiling maxistein-TICTACTO.cpp
+ g++ -std=c++14 maxistein-TICTACTO.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv -fno-sanitize-recover
maxistein-TICTACTO.cpp: In function ‘Triplet gcdExtended(long long int, long long int)’:
maxistein-TICTACTO.cpp:33:36: warning: conversion to ‘__gnu_cxx::__enable_if<true, double>::__type {aka double}’ from ‘long long int’ may alter its value [-Wconversion]
myans.y=ans.x - floor(a/b)*ans.y;
~~~~^
maxistein-TICTACTO.cpp:33:17: warning: conversion to ‘__gnu_cxx::__enable_if<true, double>::__type {aka double}’ from ‘long long int’ may alter its value [-Wconversion]
myans.y=ans.x - floor(a/b)*ans.y;
~~~~^
maxistein-TICTACTO.cpp:33:19: warning: conversion to ‘long long int’ from ‘__gnu_cxx::__enable_if<true, double>::__type {aka double}’ may alter its value [-Wfloat-conversion]
myans.y=ans.x - floor(a/b)*ans.y;
~~~~~~^~~~~~~~~~~~~~~~~~
maxistein-TICTACTO.cpp: In function ‘int gcd(long long int, long long int)’:
maxistein-TICTACTO.cpp:38:12: warning: conversion to ‘int’ from ‘long long int’ may alter its value [-Wconversion]
return a;
^
+ set +x
Successful
[simon@simon-laptop][17:59:51]
[~/devel/hackerrank/otherpeoples]>echo "1
3 4 2
1 1
3 1
1 2
2 3
2 1
2 4
3 2
3 4
1 3
3 3
2 2
1 4" | ./a.out
maxistein-TICTACTO.cpp:81:46: runtime error: index 4 out of bounds for type 'int [*]'
Edit2:
Also, potentially, this:
int temp[n+1][n+1];
See e.g. c - Getting a stack overflow exception when declaring a large array - Stack Overflow
(but I’d fix the out-of-bounds access and re-submit before changing this bit - it might be a non-issue).
Oh, thank you so much !!!