제출 #1172323

#제출 시각아이디문제언어결과실행 시간메모리
1172323crafticatToll (BOI17_toll)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;


#define F0R(i, n) for (ll i= 0 ; i< n;i++)
#define FOR(i,j,n) for (ll i = j; i< n;i++)

template<typename T>
using V = vector<T>;
using vi = V<ll>;
using pi = pair<ll,ll>;
ll k, n, m, o;
using ll = long long;

constexpr ll INF = 1e9 + 7;

V<V<vi>> base;

V<vi> combine(V<vi> a, V<vi> b) {
    V<vi> c(k, vi(k, INF));
    F0R(i, k) {
        F0R(j, k) {
            F0R(l, k) {
                c[i][l] = min(c[i][l], a[i][j] + b[j][l]);
            }
        }
    }
    return c;
}

struct Seg
{
    Seg *left = nullptr, *right = nullptr;
    ll l, r, mid;
    V<vi> to;

    Seg(ll l, ll r) : l(l), r(r), mid((l + r) / 2) {
        if (r -l > 1) {
            left = new Seg(l, mid);
            right = new Seg(mid, r);
            to = combine(left->to, right->to);
        } else {
            to = base[l];
        }
    }

    V<vi> q(ll a, ll b) {
        if (b <= l or a >= r) return {};
        if (a<=l and b>= r) {
            return to;
        }

        auto r1 = left->q(a,b);
        auto r2 = right->q(a,b);
        if (r1.empty()) return r2;
        if (r2.empty()) return r1;

        return combine(r1, r2);
    }
};

int main() {
    cin >> k >> n >> m >> o;
    base.resize((n + 1) / k, V<vi>(k, vi(k, INF)));

    F0R(i, m) {
        ll a, b, c; cin >> a >> b >> c;
        base[a / k][a % k][b % k] = c;
    }

    Seg* seg = new Seg(0, (n  +1) / k);

    F0R(i, o) {
        ll a, b; cin >> a >> b;
        auto r = seg->q(a / k, b / k);
        if (r.empty() or r[a % k][b % k] >= INF)
            cout << "-1" << "\n";
        else {
            cout << r[a % k][b % k] << "\n";
        }
    }
}

컴파일 시 표준 에러 (stderr) 메시지

toll.cpp:11:14: error: 'll' was not declared in this scope
   11 | using vi = V<ll>;
      |              ^~
toll.cpp:11:16: error: template argument 1 is invalid
   11 | using vi = V<ll>;
      |                ^
toll.cpp:12:17: error: 'll' was not declared in this scope
   12 | using pi = pair<ll,ll>;
      |                 ^~
toll.cpp:12:20: error: 'll' was not declared in this scope
   12 | using pi = pair<ll,ll>;
      |                    ^~
toll.cpp:12:22: error: template argument 1 is invalid
   12 | using pi = pair<ll,ll>;
      |                      ^
toll.cpp:12:22: error: template argument 2 is invalid
toll.cpp:13:1: error: 'll' does not name a type
   13 | ll k, n, m, o;
      | ^~
toll.cpp:18:5: error: 'vi' was not declared in this scope
   18 | V<V<vi>> base;
      |     ^~
toll.cpp:18:5: error: template argument 1 is invalid
toll.cpp:18:7: error: template argument 1 is invalid
   18 | V<V<vi>> base;
      |       ^~
toll.cpp:20:3: error: 'vi' was not declared in this scope
   20 | V<vi> combine(V<vi> a, V<vi> b) {
      |   ^~
toll.cpp:20:5: error: template argument 1 is invalid
   20 | V<vi> combine(V<vi> a, V<vi> b) {
      |     ^
toll.cpp:20:17: error: 'vi' was not declared in this scope
   20 | V<vi> combine(V<vi> a, V<vi> b) {
      |                 ^~
toll.cpp:20:19: error: template argument 1 is invalid
   20 | V<vi> combine(V<vi> a, V<vi> b) {
      |                   ^
toll.cpp:20:26: error: 'vi' was not declared in this scope
   20 | V<vi> combine(V<vi> a, V<vi> b) {
      |                          ^~
toll.cpp:20:28: error: template argument 1 is invalid
   20 | V<vi> combine(V<vi> a, V<vi> b) {
      |                            ^
toll.cpp: In function 'int combine(int, int)':
toll.cpp:21:7: error: 'vi' was not declared in this scope
   21 |     V<vi> c(k, vi(k, INF));
      |       ^~
toll.cpp:21:9: error: template argument 1 is invalid
   21 |     V<vi> c(k, vi(k, INF));
      |         ^
toll.cpp:21:13: error: 'k' was not declared in this scope
   21 |     V<vi> c(k, vi(k, INF));
      |             ^
toll.cpp:21:26: error: expression list treated as compound expression in initializer [-fpermissive]
   21 |     V<vi> c(k, vi(k, INF));
      |                          ^
toll.cpp:25:18: error: invalid types 'int[ll {aka long long int}]' for array subscript
   25 |                 c[i][l] = min(c[i][l], a[i][j] + b[j][l]);
      |                  ^
toll.cpp:25:32: error: invalid types 'int[ll {aka long long int}]' for array subscript
   25 |                 c[i][l] = min(c[i][l], a[i][j] + b[j][l]);
      |                                ^
toll.cpp:25:41: error: invalid types 'int[ll {aka long long int}]' for array subscript
   25 |                 c[i][l] = min(c[i][l], a[i][j] + b[j][l]);
      |                                         ^
toll.cpp:25:51: error: invalid types 'int[ll {aka long long int}]' for array subscript
   25 |                 c[i][l] = min(c[i][l], a[i][j] + b[j][l]);
      |                                                   ^
toll.cpp: At global scope:
toll.cpp:36:7: error: 'vi' was not declared in this scope
   36 |     V<vi> to;
      |       ^~
toll.cpp:36:9: error: template argument 1 is invalid
   36 |     V<vi> to;
      |         ^
toll.cpp:48:7: error: 'vi' was not declared in this scope
   48 |     V<vi> q(ll a, ll b) {
      |       ^~
toll.cpp:48:9: error: template argument 1 is invalid
   48 |     V<vi> q(ll a, ll b) {
      |         ^
toll.cpp: In constructor 'Seg::Seg(ll, ll)':
toll.cpp:44:22: error: invalid types 'int[ll {aka long long int}]' for array subscript
   44 |             to = base[l];
      |                      ^
toll.cpp: In member function 'int Seg::q(ll, ll)':
toll.cpp:56:16: error: request for member 'empty' in 'r1', which is of non-class type 'int'
   56 |         if (r1.empty()) return r2;
      |                ^~~~~
toll.cpp:57:16: error: request for member 'empty' in 'r2', which is of non-class type 'int'
   57 |         if (r2.empty()) return r1;
      |                ^~~~~
toll.cpp: In function 'int main()':
toll.cpp:64:12: error: 'k' was not declared in this scope
   64 |     cin >> k >> n >> m >> o;
      |            ^
toll.cpp:64:17: error: 'n' was not declared in this scope; did you mean 'yn'?
   64 |     cin >> k >> n >> m >> o;
      |                 ^
      |                 yn
toll.cpp:64:22: error: 'm' was not declared in this scope; did you mean 'tm'?
   64 |     cin >> k >> n >> m >> o;
      |                      ^
      |                      tm
toll.cpp:64:27: error: 'o' was not declared in this scope
   64 |     cin >> k >> n >> m >> o;
      |                           ^
toll.cpp:65:10: error: request for member 'resize' in 'base', which is of non-class type 'int'
   65 |     base.resize((n + 1) / k, V<vi>(k, vi(k, INF)));
      |          ^~~~~~
toll.cpp:65:32: error: 'vi' was not declared in this scope
   65 |     base.resize((n + 1) / k, V<vi>(k, vi(k, INF)));
      |                                ^~
toll.cpp:65:34: error: template argument 1 is invalid
   65 |     base.resize((n + 1) / k, V<vi>(k, vi(k, INF)));
      |                                  ^