Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lista6;
- import java.util.*;
- import java.lang.*;
- import java.io.*;
- public class Sendingemail {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int n=in.nextInt();
- List<Aresta>[] vertices = new ArrayList[n]<>;
- int m=in.nextInt();
- for(int i=0; i<m; i++) {
- int vertice1=in.nextInt();
- int vertice2=in.nextInt();
- int pesoAresta=in.nextInt();
- if(vertices[vertice1] == null) {
- vertices[vertice1] = new ArrayList<Vertice>();
- }
- if(vertices[vertice2] == null) {
- vertices[vertice2] = new ArrayList<Vertice>();
- }
- vertices[vertice1].add(new Aresta(vertice2,pesoAresta));
- }
- }
- }
- class Aresta{
- int a,peso;
- public Aresta(int a,int peso) {
- this.a=a;
- this.peso=peso;
- }
- }
- class Vertice{
- int pos,cost;
- public Vertice(int pos, int cos) {
- this.pos=pos;
- this.cost=cos;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement