Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Dij. Algo
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include <bits/stdc++.h> using namespace std; int main() { int nodes; cin >> nodes; vector<pair<int, int>> graph[nodes]; int edges; cin >> edges; for(int i = 0; i < edges; i++) { int u, v, w; cin >> u >> v >> w; pair<int, int> adjacent; adjacent.first = v - 1; adjacent.second = w; graph[u - 1].push_back(adjacent); } for(int i = 0; i < nodes; i++) { cout << i + 1; for(int j = 0; j < graph[i].size(); j++) { cout << " -> " << graph[i][j].first + 1; } cout << endl; } return 0; }
g++
8 15 1 2 9 1 6 14 1 7 15 2 3 24 3 5 2 3 8 19 4 3 6 4 8 6 5 4 11 5 8 16 6 3 18 6 5 30 6 7 5 7 5 20 7 8 44
Show compiler warnings
[
+
] Compiler args
[
-
]
Show input
Compilation time: 1.64 sec, absolute running time: 0.08 sec, cpu time: 0.01 sec, memory peak: 3 Mb, absolute service time: 1,72 sec
edit mode
|
history
|
discussion
1 -> 2 -> 6 -> 7 2 -> 3 3 -> 5 -> 8 4 -> 3 -> 8 5 -> 4 -> 8 6 -> 3 -> 5 -> 7 7 -> 5 -> 8 8