Language: C

#include <stdio.h>
#include <limits.h>
 
#define WHITE 1
#define BLACK 2
#define NIL -2
 
int A[101][101], pi[101], w[101][101], n;
 
prim(){
  int mincost, u, v, i;
  int color[n], d[n];
 
  for(u=0; u<n; u++){
    d[u] = INT_MAX;
    pi[u] = NIL;
    color[u] = WHITE;
  }
 
  d[0] = 0;
 
  while(1){
    mincost = INT_MAX;
    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
    mincost = d[i];
    u = i;
      }
    }
     
    if(mincost == INT_MAX){
      break;
    }
 
    color[u] = BLACK;
     
    for(v=0; v<n; v++){
      if(color[v] != BLACK && w[u][v] < d[v] && w[u][v] != -1){
    pi[v] = u;
    d[v] = w[u][v];
      }
    }
 
  }
 
} 
 
   
int main(){
  int i, j, sum=0;
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d", &A[i][j]);
      w[i][j] = A[i][j];
    }
  }
 
  prim();
 
  for(i=0; i<n; i++){
    if(w[i][pi[i]] != -1){
      sum += w[i][pi[i]];
    }
  }
 
  printf("%d\n", sum);
 
  return 0;
}
Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 6/6 	C 	CPU: 00.00 sec 	Memory: 676 KB 	Length: 954 B 	2015-07-10 10:47 	2015-07-10 10:47
Results for testcases
Case # 	Verdict 	CPU Time 	Memory 	In 	Out 	Case Name
Case #1: 	: Accepted 	00.00 sec 	612 KB 	234 B 	2 B 	test_case_1
Case #2: 	: Accepted 	00.00 sec 	620 KB 	1181 B 	3 B 	test_case_2
Case #3: 	: Accepted 	00.00 sec 	612 KB 	291 B 	5 B 	test_case_3
Case #4: 	: Accepted 	00.00 sec 	616 KB 	1641 B 	5 B 	test_case_4
Case #5: 	: Accepted 	00.00 sec 	644 KB 	10199 B 	5 B 	test_case_5
Case #6: 	: Accepted 	00.00 sec 	676 KB 	40786 B 	5 B 	test_case_6
< prev | 	1 	/ 	6 	| next > 	  		 : Accepted        00.00 sec        612 KB
 
Judge Input #1 ( in1.txt | 234 B) 		Judge Output #1 ( out1.txt | 2 B)

9
 -1 1 -1 13 -1 -1 -1 -1 -1
 1 -1 1 -1 11 -1 -1 -1 -1
 -1 1 -1 -1 -1 1 -1 -1 -1
 13 -1 -1 -1 1 -1 1 -1 -1
 -1 11 -1 1 -1 1 -1 4 -1
 -1 -1 1 -1 1 -1 -1 -1 7
 -1 -1 -1 1 -1 -1 -1 1 -1
 -1 -1 -1 -1 4 -1 1 -1 1
 -1 -1 -1 -1 -1 7 -1 1 -1

		

8

Comments
 
 Under Construction.
 
Categories
 
 
Free Tags
 
 
 
	   	
 

Aizu Online Judge
follow us on Twitter

About us

ContactSystem InfoThe University of Aizu
Tools

WEB Board ToolsVirtual ArenaAPI ReferenceTutorial
Links

ACM/ICPCACM/ICPC Asia JapanACM-ICPC OB/OG Alumni GroupPC KoshienJOI

AtCoderTopCoderCodeForces

Uva Online judgesACM-ICPC Live ArchivePKU JudgeOnline

Aizu IT Arena

Best viewed using Firefox, Google Chrome

Aizu Online Judge Version 1.0 ? 2004 - 2015 AIZU Competitive Programming Club (ICPCPC), Database Systems Lab. University of Aizu
 

Compiler output:
main.c:10:1: error: return type defaults to 'int' [-Wimplicit-int]
   10 | prim(){
      | ^~~~
main.c:73:1: error: unknown type name 'Compile'
   73 | Compile Error Logs:
      | ^~~~~~~
main.c:73:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Logs'
   73 | Compile Error Logs:
      |               ^~~~
main.c:79:6: error: stray '#' in program
   79 | Case #  Verdict         CPU Time        Memory  In      Out     Case Name
      |      ^
main.c:80:6: error: stray '#' in program
   80 | Case #1:        : Accepted      00.00 sec       612 KB  234 B   2 B     test_case_1
      |      ^
main.c:81:6: error: stray '#' in program
   81 | Case #2:        : Accepted      00.00 sec       620 KB  1181 B  3 B     test_case_2
      |      ^
main.c:82:6: error: stray '#' in program
   82 | Case #3:        : Accepted      00.00 sec       612 KB  291 B   5 B     test_case_3
      |      ^
main.c:83:6: error: stray '#' in program
   83 | Case #4:        : Accepted      00.00 sec       616 KB  1641 B  5 B     test_case_4
      |      ^
main.c:84:6: error: stray '#' in program
   84 | Case #5:        : Accepted      00.00 sec       644 KB  10199 B         5 B     test_case_5
      |      ^
main.c:85:6: error: stray '#' in program
   85 | Case #6:        : Accepted      00.00 sec       676 KB  40786 B         5 B     test_case_6
      |      ^
main.c:88:13: error: stray '#' in program
   88 | Judge Input #1 ( in1.txt | 234 B)               Judge Output #1 ( out1.txt | 2 B)
      |             ^
main.c:88:62: error: stray '#' in program
   88 | Judge Input #1 ( in1.txt | 234 B)               Judge Output #1 ( out1.txt | 2 B)
      |                                                              ^