ソースコード 拡げる

Copy
```#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF (LLONG_MAX/2)
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

ll N, M;
ll c,a,b,r;
ll G[100005][100005];
ll mincost[100020];
bool used[100005];

ll prim(){
rep(i, N){
mincost[i] = INF;
used[i] = false;
}

mincost[0] = 0;
ll res = 0;

while(true){
int v = -1;
rep(u, N)
if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;

if(v == -1) break;
used[v] = true;
res += mincost[v];

rep(u, N){
mincost[u] = min(mincost[u], G[v][u]);
}
}
return res;

}

int main(){
cin >> N >> M;
rep(i, N+1) rep(j, N+1) G[i][j] = INF;
rep(i, N){
scanf("%lld", &c);
G[N][i] = G[i][N] = c;
}
rep(i, M){
scanf("%lld%lld%lld", &a, &b, &r); a--; b--;
G[a][b] = G[b][a] = r;
}
N++;
printf("%lld\n", prim());
return 0;
}
```

#### 提出情報

提出日時 2014-09-28 02:03:16+0900 C - 高橋君と国家 raven38 C++ (G++ 4.6.4) 0 1586 Byte CE

#### コンパイルエラー

```./Main.cpp: In function ‘int main()’:
./Main.cpp:72:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:76:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
/tmp/cc5bFxXS.o: In function `prim()':
Main.cpp:(.text+0x3): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5bFxXS.o
/tmp/cc5bFxXS.o: In function `main':
Main.cpp:(.text.startup+0x2): relocation truncated to fit: R_X86_64_32 against symbol `N' defined in .bss section in /tmp/cc5bFxXS.o
Main.cpp:(.text.startup+0x16): relocation truncated to fit: R_X86_64_32 against symbol `M' defined in .bss section in /tmp/cc5bFxXS.o
Main.cpp:(.text.startup+0x25): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc5bFxXS.o
Main.cpp:(.text.startup+0x86): relocation truncated to fit: R_X86_64_32 against ...```