제출 #566882

#제출 시각아이디문제언어결과실행 시간메모리
566882Turkhuu밀림 점프 (APIO21_jumps)C++17
컴파일 에러
0 ms0 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; const int inf = 1000000; int n; vector<int> a; vector<vector<int>> g; void init(int N, vector<int> H){ n = N; a = H; g.resize(n); for(int i = 0; i < n; i++){ int l = i - 1, r = i + 1; while(l >= 0 && a[l] <= a[i]) l--; while(r < n && a[r] <= a[i]) r++; if(l >= 0) g[i].push_back(l); if(r < n) g[i].push_back(r); ] } int minimum_jumps(int A, int B, int C, int D){ queue<int> q; vector<int> d(n); for(int i = A; i <= B; i++){ d[i] = 0; q.push(i); } while(!q.empty()){ int i = q.front(); q.pop(); if(C <= i && i <= D){ return d[i]; } for(int j : g[i]){ if(d[i] + 1 < d[j]){ d[j] = d[i] + 1; q.push(j); } } } return -1; }

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

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:18:5: error: expected primary-expression before ']' token
   18 |     ]
      |     ^
jumps.cpp:20:46: error: a function-definition is not allowed here before '{' token
   20 | int minimum_jumps(int A, int B, int C, int D){
      |                                              ^
jumps.cpp:41:1: error: expected '}' at end of input
   41 | }
      | ^
jumps.cpp:8:32: note: to match this '{'
    8 | void init(int N, vector<int> H){
      |                                ^