Submission #1073348

#TimeUsernameProblemLanguageResultExecution timeMemory
1073348ProtonDecay314Text editor (CEOI24_editor)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int; // ! CAREFUL typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<ll, ll> pll; typedef pair<int, int> pi; typedef vector<bool> vb; #define fi first #define se second #define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false) #define pb push_back ll solve(ll n, ll sl, ll sc, ll el, ll ec, const vll& l) { vll prefl(n + 1, 0); for(ll i = 0; i < n; i++) { prefl[i + 1] = prefl[i] + l[i]; } ll totn = prefl[n]; vvll adj; for(ll i = 0; i < totn; i++) { vll adjr; adj.pb(adjr); } ll s = prefl[sl] + sc, e = prefl[el] + ec; for(ll li = 0; li < n; li++) { for(ll ci = 0; ci < l[li]; ci++) { ll ni = prefl[li] + ci; ll adji; // up if(li > 0) { adji = prefl[li - 1] + min(ci, l[li - 1] - 1); adj[ni].pb(adji); } // down if(li < n - 1) { adji = prefl[li + 1] + min(ci, l[li + 1] - 1); adj[ni].pb(adji); } // left if(li > 0 || ci > 0) { adji = ni - 1; adj[ni].pb(adji); } // right if(li < n - 1) { adji = ni + 1; adj[ni].pb(adji); } } } // Performing BFS vb vis(totn, false); queue<pll> q; q.push({s, 0}); ll ans = 0; while(!q.empty()) { auto [i, dist] = q.front(); if(vis[i]) continue; vis[i] = true; if(i == e) { ans = dist; break; } for(ll j : adj[i]) { q.push({j, dist + 1}); } } return ans; } int main() { IOS; ll n; cin >> n; ll sl, sc; ll el, ec; cin >> sl >> sc; cin >> el >> ec; sl--; sc--; el--; ec--; vll l(n, 0ll); for(ll& lv : l) { cin >> lv; lv++; // ! WARNING, already added one } cout << solve(n, sl, sc, el, ec, l) << endl; return 0; }

Compilation message (stderr)

Main.cpp:3:19: error: declaration does not declare anything [-fpermissive]
    3 | typedef long long int; // ! CAREFUL
      |                   ^~~
Main.cpp:4:16: error: 'll' was not declared in this scope
    4 | typedef vector<ll> vll;
      |                ^~
Main.cpp:4:18: error: template argument 1 is invalid
    4 | typedef vector<ll> vll;
      |                  ^
Main.cpp:4:18: error: template argument 2 is invalid
Main.cpp:8:14: error: 'll' was not declared in this scope; did you mean 'vll'?
    8 | typedef pair<ll, ll> pll;
      |              ^~
      |              vll
Main.cpp:8:18: error: 'll' was not declared in this scope; did you mean 'vll'?
    8 | typedef pair<ll, ll> pll;
      |                  ^~
      |                  vll
Main.cpp:8:20: error: template argument 1 is invalid
    8 | typedef pair<ll, ll> pll;
      |                    ^
Main.cpp:8:20: error: template argument 2 is invalid
Main.cpp:16:1: error: 'll' does not name a type; did you mean 'pll'?
   16 | ll solve(ll n, ll sl, ll sc, ll el, ll ec, const vll& l) {
      | ^~
      | pll
Main.cpp: In function 'int main()':
Main.cpp:97:5: error: 'll' was not declared in this scope; did you mean 'pll'?
   97 |     ll n;
      |     ^~
      |     pll
Main.cpp:98:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   98 |     cin >> n;
      |            ^
      |            yn
Main.cpp:100:7: error: expected ';' before 'sl'
  100 |     ll sl, sc;
      |       ^~~
      |       ;
Main.cpp:101:7: error: expected ';' before 'el'
  101 |     ll el, ec;
      |       ^~~
      |       ;
Main.cpp:102:12: error: 'sl' was not declared in this scope; did you mean 'se'?
  102 |     cin >> sl >> sc;
      |            ^~
      |            se
Main.cpp:102:18: error: 'sc' was not declared in this scope; did you mean 'se'?
  102 |     cin >> sl >> sc;
      |                  ^~
      |                  se
Main.cpp:103:12: error: 'el' was not declared in this scope
  103 |     cin >> el >> ec;
      |            ^~
Main.cpp:103:18: error: 'ec' was not declared in this scope
  103 |     cin >> el >> ec;
      |                  ^~
Main.cpp:108:17: error: expression list treated as compound expression in initializer [-fpermissive]
  108 |     vll l(n, 0ll);
      |                 ^
Main.cpp:110:16: error: found ':' in nested-name-specifier, expected '::'
  110 |     for(ll& lv : l) {
      |                ^
      |                ::
Main.cpp:110:13: error: 'lv' has not been declared
  110 |     for(ll& lv : l) {
      |             ^~
Main.cpp:115:13: error: 'solve' was not declared in this scope
  115 |     cout << solve(n, sl, sc, el, ec, l) << endl;
      |             ^~~~~
Main.cpp:117:5: error: expected primary-expression before 'return'
  117 |     return 0;
      |     ^~~~~~
Main.cpp:115:49: error: expected ')' before 'return'
  115 |     cout << solve(n, sl, sc, el, ec, l) << endl;
      |                                                 ^
      |                                                 )
  116 | 
  117 |     return 0;
      |     ~~~~~~                                       
Main.cpp:110:8: note: to match this '('
  110 |     for(ll& lv : l) {
      |        ^