Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8603481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:20:05+00:00 2026-06-12T02:20:05+00:00

This is with reference to the ‘graph existence’ problem – http://acm.mipt.ru/judge/problems.pl?problem=110 . Can someone

  • 0

This is with reference to the ‘graph existence’ problem – http://acm.mipt.ru/judge/problems.pl?problem=110. Can someone explain why there is no tree in example 1 but there is a tree in example 2? In both examples, vertices 0, 1, 2 and 3 are connected to each other. Here is the problem statement and examples for your reference:

You are given a matrix of distances in a graph.
You should check whether this graph could be a tree or set of trees (forest).
Edge length is 0 or positive integer.

Input: The first line contains number of vertices N.
Next N lines contains matrix (only left bottom triangle of matrix).
Distance -1 corresponds to infinite distance.

Output: Output YES or NO. If YES, then next lines should contains list of edges
of the tree (any tree (forest) with given distance matrix).
Each edge is coded by two identifiers of it's ends.
Vertex identifiers are numbers 0, 1, ..., N-1.

Input#1
4
0 
1 0
1 1 0
1 1 1 0

Output#1
NO

Input#2
5
0 
1 0
2 1 0
3 2 1 0
-1 -1 -1 -1 0

Output#2
YES
0 1
1 2
2 3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:20:06+00:00Added an answer on June 12, 2026 at 2:20 am

    The problem is not very well translated from its Russian original.

    The given matrix is not the matrix of edges in the graph as one might conclude, but a distance matrix. Each edge probably has weight of 1, but I am not entirely sure has a nonnegative weight. One has to check if the matrix can be realized by a tree or a forest.

    That is in the first example all vertices are connected, but the second example can be realized the graph looks like:

        Example 2:
        (0) - (1) - (2) - (3)  (4) 
    

    The graph in example 1 is

        Example 1:
        (0) - (1) - (2) - (3)
         |_____|_____|     |     
         |     |___________|
         |_________________|
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when i search for open source for domain checker, i got this reference http://www.codeproject.com/KB/aspnet/DataScraping.aspx
Goetz's Java Concurrency in Practice , page 41, mentions how this reference can escape
Can I do this without reference to the object in the constructor? In other
According to this reference http://code.google.com/apis/chart/interactive/docs/gallery/linechart.html , tooltip.trigger = 'none' turns off tooltips on a
I found this reference that will update all fields in a word document. http://www.gmayor.com/installing_macro.htm
I've used the this reference to display the line graph By above code, graph
I am using this reference http://www.openjs.com/articles/ajax/ajax_file_upload/response_data.php for ajax uploader ,its working absolutely fine for
If I have this reference variable: float* image How can I get the length
I'm not interested in call or apply to change the this reference. Just for
I have a large non static JAVA function, which uses this reference at several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.