제출 #550872

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

#define pb push_back
#define f first
#define s second
#define pi acos(-1)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll oo = 1e18;
const ld eps = (ld)1 / oo;
const ll N = 2e5 + 100;
const ll M = 25;

vector <vector <vector <pair<int, ll> > > > binpow;
vector <ll> str;
vector <int> s, p, w, l;
int n;

void init(int n1, vector <int> s1, vector <int> p1, vector <int> w1, vector <int> l1)
{
    n = n1;
    s = s1, p = p1, w = w1, l = l1;
    for (ll i = 0; i < n; i++) str.pb(s[i]);
    str.pb(0);
    sort(str.begin(), str.end());
    str.resize(unique(str.begin(), str.end()) - str.begin());
    binpow.resize(str.size());
    for (ll i = 0; i < str.size(); i++)
    {
        binpow[i].resize(n + 1);
        for (ll j = 0; j <= n; j++) binpow[i][j].resize(M);
        for (ll j = 0; j < n; j++)
          if (s[j] > str[i]) binpow[i][j][0] = {l[j], p[j]};
          else               binpow[i][j][0] = {w[j], s[j]};
        binpow[i][n][0] = {n, 0};
        for (ll c = 1; c < M; c++)
        {
            for (ll j = 0; j <= n; j++)
            {
                ll nx = binpow[i][j][c - 1].f;
                binpow[i][j][c].f = binpow[i][nx][c - 1].f;
                binpow[i][j][c].s = binpow[i][j][c - 1].s + binpow[i][nx][c - 1].s;
            }
        }
    }
    str.pb(oo);
}

ll simulate(int x, ll y1)
{
    ll y = y1;
    for (int i = 0; i < str.size(); i++)
    {
        if (y < str[i])
        {
            for (int j = M - 1; j >= 0; j--)
                if (y + binpow[i - 1][x][j].s < str[i]) y += binpow[i - 1][x][j].s, x = binpow[i - 1][x][j].f;
            if (x == n) return y;
            if (y > s[x])
            {
                y += s[x];
                x = w[x];
            }
            else
            {
                y += p[x];
                x = l[x];
            }
        }
    }
}

//int main()
//{
//    srand(time(NULL));
//    ll n, q;
//    cin >> n >> q;
//    vector <int> a(n), b(n), c(n), d(n);
//    for (ll i = 0; i < n; i++) cin >> a[i];
//    for (ll i = 0; i < n; i++) cin >> b[i];
//    for (ll i = 0; i < n; i++) cin >> c[i];
//    for (ll i = 0; i < n; i++) cin >> d[i];
//    init(n, a, b, c, d);
//    while (q--)
//    {
//        ll x, z;
//        cin >> x >> z;
//        cout << simulate(x, z) << endl;
//    }
//}
/*
1
4
-100000 -100000 100000 -100000 -100000 100000
-100000 -100000 100000 -100000 -100000 100000
-100000 -100000 100000 -100000 -100000 100000
-100000 -100000 100000 -100000 -100000 100000
*/

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

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:32:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (ll i = 0; i < str.size(); i++)
      |                    ~~^~~~~~~~~~~~
dungeons.cpp: In function 'll simulate(int, ll)':
dungeons.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for (int i = 0; i < str.size(); i++)
      |                     ~~^~~~~~~~~~~~
dungeons.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
/usr/bin/ld: /tmp/ccOK9CD1.o: in function `main':
grader.cpp:(.text.startup+0x440): undefined reference to `simulate(int, int)'
collect2: error: ld returned 1 exit status