When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
47 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
What do you mean by triggering detectors?
I don’t understand what you mean
Is the code triggering plagiarism detection?
Well, did you write it yourself?
I don’t think that is something that anyone can do better than you, tbh
Since they don’t know what the detection system looks for
for (int i = 0; i < n; ++i) {
if (shortestDist[i] < distTo[i]) {
return false;
}
}
🤔
isn't this a bit pointless as you just initialized them all to std::numeric_limits<int>::max()
And it is kida iffy in regards to rule 5
shortestDist[0] = 0; this is the only value that isn't the max value
!cheating
Aside from ethics and simply not caring for helping script kiddies, this content violates Discord's terms of service and we do not tolerate it.
well honestly I wouldn't say this is persay against rule 5
they did the work, they are just asking how to improve it
Since we can’t really tell if it is AI generated or not
Sorry, my bad
that is a fair point
honestly though, looking at this it's for the most part similar to what I would have written
Some style tips I can give though 🙂
like honestly nothing in this code at first glance jumps out to me as a huge issue
this is the main one I found a bit odd
I would just remove n and use G.size()
sure, but shortestdist[i] is never going to be less then distTo[i]
unless it's index 0
You can use a structured binding for u and v
yeah that would be significantly better ^
int n = G.size();
std::vector<int> shortestDist(n, std::numeric_limits<int>::max());
shortestDist[0] = 0;
also this might potentially crash for empty graphs 🤔
That would look like auto [u, v] = edge;
It’s UB at least
I think allocating a vector with size 0 is oaky but writing to it is a bit iffy
In general it’s poor style to shorten names (like shortestDist instead of shortestDistance)
wait but isn't this basically the same?
The code would be clearer if you made u a reference variable to shortestDist[edge.first] and w to a similar thing
But that might be just me 
but that code you linked is the exact same 🤔
mine wasn't a correction just pointing out issues in your code
the exact same :D
now this one:
for (int i = 0; i < numVertices; ++i) {
if (shortestDist[i] < distTo[i]) {
return false;
}
}
makes significantly more sense
I was thinking that you could simplify the if statement by putting shortestDist[u] into a variable and doing the same thing for the right hand side
auto x = shortestDist[v] + w;
if (shortestDist[u] > x) {
shortestDist[u] = x;
}
}```
Like this
And similar for u
It’s absolutely debatable whether that is an improvement
But I think it looks good 
👆
@vital turtle Has your question been resolved? If so, run !solved :)
sorry, I am working atm don't have to time to debug stuff like that sadly