답안 #14634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14634 2015-05-24T05:55:47 Z nosiar 관광 (NOI14_sightseeing) C++
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <numeric>
#include <limits>

using namespace std;

int v, e, q;
vector<pair<int,int>> edge[500050];
int ans[500050];
int main() { 
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
ios::sync_with_stdio(false); //int tests; cin >> tests; while (tests--)
{
    cin >> v >> e  >> q;
    for (int i = 0; i < e; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edge[a].push_back({ c, b });
        edge[b].push_back({ c, a });
    }
    priority_queue<pair<int, pair<int, int>>> pq;
    for (auto e : edge[0])
    {
        pq.push({ e.first, { 0, e.second } });
    }
    memset(ans, -1, sizeof(ans));
    ans[0] = 987654321;
    while (!pq.empty())
    {
        auto e = pq.top(); pq.pop();
        if (ans[e.second.second] == -1)
        {
            ans[e.second.second] = min(ans[e.second.first], e.first);
            for (auto ee : edge[e.second.second])
            {
                if (ans[ee.second] == -1)
                    pq.push({ ee.first, { e.second.second, ee.second } });
            }
        }
    }
    for (int i = 0; i < q; ++i)
    {
        int x; cin >> x;
        cout << ans[x - 1] << endl;
    }
}}

Compilation message

sightseeing.cpp:15:20: error: ‘>>’ should be ‘> >’ within a nested template argument list
 vector<pair<int,int>> edge[500050];
                    ^
sightseeing.cpp: In function ‘int main()’:
sightseeing.cpp:29:27: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         edge[a].push_back({ c, b });
                           ^
sightseeing.cpp:29:35: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         edge[a].push_back({ c, b });
                                   ^
sightseeing.cpp:30:27: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         edge[b].push_back({ c, a });
                           ^
sightseeing.cpp:30:35: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         edge[b].push_back({ c, a });
                                   ^
sightseeing.cpp:32:43: error: ‘>>’ should be ‘> >’ within a nested template argument list
     priority_queue<pair<int, pair<int, int>>> pq;
                                           ^
sightseeing.cpp:33:10: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat]
     for (auto e : edge[0])
          ^
sightseeing.cpp:33:15: error: ‘e’ does not name a type
     for (auto e : edge[0])
               ^
sightseeing.cpp:37:5: error: expected ‘;’ before ‘memset’
     memset(ans, -1, sizeof(ans));
     ^
sightseeing.cpp:38:23: error: expected ‘)’ before ‘;’ token
     ans[0] = 987654321;
                       ^
sightseeing.cpp:41:9: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat]
         auto e = pq.top(); pq.pop();
         ^
sightseeing.cpp:41:14: error: ‘e’ does not name a type
         auto e = pq.top(); pq.pop();
              ^
sightseeing.cpp:42:19: error: request for member ‘second’ in ‘e’, which is of non-class type ‘int’
         if (ans[e.second.second] == -1)
                   ^
sightseeing.cpp:44:19: error: request for member ‘second’ in ‘e’, which is of non-class type ‘int’
             ans[e.second.second] = min(ans[e.second.first], e.first);
                   ^
sightseeing.cpp:44:46: error: request for member ‘second’ in ‘e’, which is of non-class type ‘int’
             ans[e.second.second] = min(ans[e.second.first], e.first);
                                              ^
sightseeing.cpp:44:63: error: request for member ‘first’ in ‘e’, which is of non-class type ‘int’
             ans[e.second.second] = min(ans[e.second.first], e.first);
                                                               ^
sightseeing.cpp:45:18: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat]
             for (auto ee : edge[e.second.second])
                  ^
sightseeing.cpp:45:23: error: ‘ee’ does not name a type
             for (auto ee : edge[e.second.second])
                       ^
sightseeing.cpp:50:9: error: expected ‘;’ before ‘}’ token
         }
         ^
sightseeing.cpp:50:9: error: expected primary-expression before ‘}’ token
sightseeing.cpp:50:9: error: expected ‘;’ before ‘}’ token
sightseeing.cpp:50:9: error: expected primary-expression before ‘}’ token
sightseeing.cpp:50:9: error: expected ‘)’ before ‘}’ token
sightseeing.cpp:50:9: error: expected primary-expression before ‘}’ token