Giter VIP home page Giter VIP logo

stanfordacm's Issues

Incorrect result on an example graph

Hi
I tried the code with the following edge costs:

int cost3[][] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 2, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 2, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 2, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 1}, { 0, 0, 0, 0, 0, 0, 0, 0, 0} };
and the following edge capacities:
`int cap3[][] = { { 0, 1, 1, 1, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, INF, 0, 0, INF, 0 },
{ 0, 0, 0, 0, 0, INF, 0, INF, 0 },
{ 0, 0, 0, 0, 0, 0, INF, INF, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, INF },
{ 0, 0, 0, 0, 0, 0, 0, 0, INF },
{ 0, 0, 0, 0, 0, 0, 0, 0, INF },
{ 0, 0, 0, 0, 0, 0, 0, 0, 2 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }

    };`

Your code gave the result 1 2, whereas, I think the result should be 2 2.
I am trying to represent a directed graph here. It is best visualized as an n-partite graph. In the first column, you have node 0, in the second column you have nodes 1, 2 and 3. In the third column, you have nodes 4, 5, 6 and 7. In the last column you have node 8.
Node 0 has edges to nodes 1, 2 and 3 with 0 edge cost and infinite edge capacity. Node 1 has edges to nodes 4 and 7. The edge from 1 to 4 has edge cost 2 and infinite capacity, whereas the edge from 1 to 7 has edge cost 0 and infinite capacity. Node 2 has similar edges to nodes 5 and 7. Node 3 has similar edges to nodes 6 and 7. Nodes 4, 5 and 6 have edges to node 8 with cost 0 and infinite capacity. Node 7 has an edge to node 8 with cost 1 and capacity 2.

LongestIncreasingSubsequence Bug

The following code prints 5 3 4.

int main() {
  auto res = LongestIncreasingSubsequence(vector<int>({5,6,2,3,4}));
  for (auto i : res)
      cout << i << " ";
  cout << endl;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.