Submission #921302

#TimeUsernameProblemLanguageResultExecution timeMemory
921302salmonAncient Books (IOI17_books)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; pair<int,int> expand_range(int l, int r, int h){ int l1 = min(l,h); int r1 = max(r,h); while(l1 != l || r1 != r){ if(l1 != l){ l--; l1 = min(l1,l[parent[l]); r1 = max(r1,r[parent[l]); } else{ r++; l1 = min(l1,l[parent[r]); r1 = max(l1,r[parent[r]); } } return {l,r}; } long long minimum_walk(vector<int> p, int s) { int parent[1100100]; int v[1100100]; bool done[1100100]; int l[1100100]; int r[1100100]; int l1 = s; int r1 = s; int l2 = s; int r2 = s; long long int some = 0; int N = p.size(); for(int i = 0; i < N; i++){ done[i] = false; } for(int i = 0; i < N; i++){ if(done[i]) continue; l[i] = i; r[i] = i; parent[i] = i; int j = p[i]; some += abs(i - j); while(j != i){ int temp = j; parent[j] = i; done[j] = true; r[i] = max(r[i],j); j = p[j]; some += abs(temp - j); } } l2 = l[parent[s]]; r2 = r[parent[s]]; while(l1 != l2 || r1 != r2){ if(l1 != l2){ l1--; l2 = min(l2,l[parent[l1]); r2 = max(r2,r[parent[l1]); } else{ r1++; l2 = min(l2,l[parent[r1]); r2 = max(r2,r[parent[r1]); } } int l3l = l1; int r3l = r1; int l3r = l1; int r3r = r1; while(l1 != 0 && r1 != N - 1){ int coft = 0; l3l = l1; r3l = r1; l3r = l1; r3r = r1; while(r1 < r3l && l3r < l1){ coft += 2; if(l3l >= 0){ pair<int,int> ii = expand_range(l3l-1,r3l,l3l); l3l = ii.first; r3l = ii.second; } if(r3r < N){ ii = expand_range(l3r,r3r,r3r+1); } if(l3l >= 0 && r3r < N){ sum += coft; break; } } sum += coft; l1 = min(l3l,l1); l1 = min(l3r,l1); r1 = max(r31,r1); r1 = max(r3r,r1); } return soom; }

Compilation message (stderr)

books.cpp: In function 'std::pair<int, int> expand_range(int, int, int)':
books.cpp:11:27: error: 'parent' was not declared in this scope
   11 |             l1 = min(l1,l[parent[l]);
      |                           ^~~~~~
books.cpp:11:36: error: expected ']' before ')' token
   11 |             l1 = min(l1,l[parent[l]);
      |                                    ^
      |                                    ]
books.cpp:12:36: error: expected ']' before ')' token
   12 |             r1 = max(r1,r[parent[l]);
      |                                    ^
      |                                    ]
books.cpp:16:27: error: 'parent' was not declared in this scope
   16 |             l1 = min(l1,l[parent[r]);
      |                           ^~~~~~
books.cpp:16:36: error: expected ']' before ')' token
   16 |             l1 = min(l1,l[parent[r]);
      |                                    ^
      |                                    ]
books.cpp:17:36: error: expected ']' before ')' token
   17 |             r1 = max(l1,r[parent[r]);
      |                                    ^
      |                                    ]
books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:67:37: error: expected ']' before ')' token
   67 |             l2 = min(l2,l[parent[l1]);
      |                                     ^
      |                                     ]
books.cpp:68:37: error: expected ']' before ')' token
   68 |             r2 = max(r2,r[parent[l1]);
      |                                     ^
      |                                     ]
books.cpp:72:37: error: expected ']' before ')' token
   72 |             l2 = min(l2,l[parent[r1]);
      |                                     ^
      |                                     ]
books.cpp:73:37: error: expected ']' before ')' token
   73 |             r2 = max(r2,r[parent[r1]);
      |                                     ^
      |                                     ]
books.cpp:102:17: error: 'ii' was not declared in this scope
  102 |                 ii = expand_range(l3r,r3r,r3r+1);
      |                 ^~
books.cpp:106:17: error: 'sum' was not declared in this scope
  106 |                 sum += coft;
      |                 ^~~
books.cpp:111:9: error: 'sum' was not declared in this scope
  111 |         sum += coft;
      |         ^~~
books.cpp:116:18: error: 'r31' was not declared in this scope; did you mean 'r3r'?
  116 |         r1 = max(r31,r1);
      |                  ^~~
      |                  r3r
books.cpp:120:12: error: 'soom' was not declared in this scope
  120 |     return soom;
      |            ^~~~
books.cpp:27:9: warning: unused variable 'v' [-Wunused-variable]
   27 |     int v[1100100];
      |         ^