View Code of Problem 14

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <stack>
#include <map>
#include <set>
#include <queue>
using namespace std;
const int maxv=100,INF=1<<30;
int G[maxv][maxv];

int main()
{
    #ifdef  ONLINE_JUDGE
    #else
    freopen("1.txt","r",stdin);
    #endif
    int n,m;
    int index=0;
    while(cin>>n)
    {
        index++;
        cin>>m;
        if(n==0&&m==0) return 0;
        fill(G,G+maxv*maxv,INF);
        while(m--)
        {
            int a,b,c;
            cin>>a>>b>>c;
            if(G[a][b]>c)
            {
                G[a][b]=c;
                G[b][a]=c;
            }
        }
        int w,e;
        cin>>w>>e;
        int ans=0;
        while(w--)
        {
            int a,b;
            cin>>a>>b;
            ans+=G[a][b];
            if(b==e) break;
        }
        cout<<"Case #"<<index<<": "<<ans;
        cout<<endl;
    }



    return 0;
}

/*
In file included from /usr/include/c++/4.9/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.9/ios:40,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from Main.cc:1:
/usr/include/c++/4.9/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[100]; _Tp = int; typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/4.9/bits/stl_algobase.h:740:14:   required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[100]; _Tp = int]'
Main.cc:29:31:   required from here
/usr/include/c++/4.9/bits/stl_algobase.h:704:11: error: incompatible types in assignment of 'const int' to 'int [100]'
  *__first = __tmp;
           ^
*/

Double click to view unformatted code.


Back to problem 14