답안 #155964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155964 2019-10-02T10:36:54 Z Minnakhmetov 오벨리스크 (NOI14_obelisk) C++14
컴파일 오류
0 ms 0 KB
nclude <bits/stdc++.h>
   
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
 
using namespace std;
 
struct E {
    int to, w;
};
 
const int N = 11, M = 1e5, INF = 1e9;
vector<pair<int, int>> v[M];
vector<E> g[M];
int s[M];
ll d[M];
 
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int m, k, sx, sy, ex, ey;
    cin >> k >> m >> sx >> sy >> ex >> ey;
 
    v[k].push_back({sx, sy});
    v[0].push_back({ex, ey});
 
    for (int i = k - 1; i > 0; i--) {
        int h;
        cin >> h;
 
        while (h--) {
            int x, y;
            cin >> x >> y;
            v[i].push_back({x, y});
        }
    }
 
    for (int i = 0; i < k; i++) {
        s[i + 1] = s[i] + v[i].size();
    }
 
    for (int i = k; i > 0; i--) {
        for (int x = 0; x < v[i].size(); x++) {
            for (int y = 0; y < v[i - 1].size(); y++) {
                int d = abs(v[i][x].first - v[i - 1][y].first) +
                        abs(v[i][x].second - v[i - 1][y].second);
                g[x + s[i]].push_back({y + s[i - 1], d});
            }
        }
    }
 
    // for (int i = 0; i < M; i++) {
    //     for (E e : g[i]) {
    //         cout << i + 1 << " " << e.to + 1 << " " << e.w << "\n";
    //     }
    // }
 
    priority_queue<pair<int, int>, 
                   vector<pair<int, int>>, 
                   greater<pair<int, int>>> q;
                   
    fill(d, d + M, INF);
    d[s[k]] = 0;
    q.push({0, s[k]});
 
    while (!q.empty()) {
        auto p = q.top();
        q.pop();
        if (p.first > d[p.second])
            continue;
        int node = p.second;
 
        for (E e : g[node]) {
            if (d[e.to] > d[node] + e.w) {
                d[e.to] = d[node] + e.w;
                q.push({d[e.to], e.to});
            }
        }
    }
 
    cout << d[0] << "\n";
 
    return 0;
}

Compilation message

obelisk.cpp:1:1: error: 'nclude' does not name a type
 nclude <bits/stdc++.h>
 ^~~~~~
obelisk.cpp:13:1: error: 'vector' does not name a type
 vector<pair<int, int>> v[M];
 ^~~~~~
obelisk.cpp:14:1: error: 'vector' does not name a type
 vector<E> g[M];
 ^~~~~~
obelisk.cpp: In function 'int main()':
obelisk.cpp:19:5: error: 'ios_base' has not been declared
     ios_base::sync_with_stdio(0);
     ^~~~~~~~
obelisk.cpp:20:5: error: 'cin' was not declared in this scope
     cin.tie(0);
     ^~~
obelisk.cpp:20:5: note: suggested alternative: 'main'
     cin.tie(0);
     ^~~
     main
obelisk.cpp:25:5: error: 'v' was not declared in this scope
     v[k].push_back({sx, sy});
     ^
obelisk.cpp:46:25: error: 'abs' was not declared in this scope
                 int d = abs(v[i][x].first - v[i - 1][y].first) +
                         ^~~
obelisk.cpp:48:17: error: 'g' was not declared in this scope
                 g[x + s[i]].push_back({y + s[i - 1], d});
                 ^
obelisk.cpp:59:5: error: 'priority_queue' was not declared in this scope
     priority_queue<pair<int, int>, 
     ^~~~~~~~~~~~~~
obelisk.cpp:59:20: error: 'pair' was not declared in this scope
     priority_queue<pair<int, int>, 
                    ^~~~
obelisk.cpp:59:20: note: suggested alternative: 'main'
     priority_queue<pair<int, int>, 
                    ^~~~
                    main
obelisk.cpp:59:25: error: expected primary-expression before 'int'
     priority_queue<pair<int, int>, 
                         ^~~
obelisk.cpp:63:5: error: 'fill' was not declared in this scope
     fill(d, d + M, INF);
     ^~~~
obelisk.cpp:63:5: note: suggested alternative: 'all'
     fill(d, d + M, INF);
     ^~~~
     all
obelisk.cpp:65:5: error: 'q' was not declared in this scope
     q.push({0, s[k]});
     ^
obelisk.cpp:74:20: error: 'g' was not declared in this scope
         for (E e : g[node]) {
                    ^
obelisk.cpp:82:5: error: 'cout' was not declared in this scope
     cout << d[0] << "\n";
     ^~~~