Submission #204606

#TimeUsernameProblemLanguageResultExecution timeMemory
204606cgiosyJakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
ㅁ#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false);cin.tie(nullptr); int N, M, st=0, ed=0; cin>>N>>M; vector<vector<int>> A(N); for(int i=0; i<N; i++) { int x, m; cin>>x>>m; if(i==0) st=x; else if(i==1) ed=x; if(max(x, N-1-x)>=m) A[x].push_back(m); } for(auto&v:A) { sort(rbegin(v), rend(v)); v.erase(unique(begin(v), end(v)), end(v)); } vector<int> D(N, INT_MAX); vector<vector<int>> Q(N+1); int qs=1, k=0, n=0; Q[0].push_back(st); D[st]=0; while(qs) { for(int x:Q[k]) if(D[x]==n) { if(x==ed) { cout<<n; return 0; } for(int m:A[x]) { for(int i=x+m, j=k+1, d=n+1; i<N; i+=m, j=j==N ? 0 : j+1, d++) if(d<D[i]) { D[i]=d, Q[j].push_back(i), qs++; if(binary_search(rbegin(A[i]), rend(A[i]), m)) break; } for(int i=x-m, j=k+1, d=n+1; i>=0; i-=m, j=j==N ? 0 : j+1, d++) if(d<D[i]) { D[i]=d, Q[j].push_back(i), qs++; if(binary_search(rbegin(A[i]), rend(A[i]), m)) break; } } } qs-=Q[k].size(); Q[k].clear(); k=k==N ? 0 : k+1; ++n; } cout<<-1; }

Compilation message (stderr)

skyscraper.cpp:1:1: error: stray '\343' in program
 ㅁ#include <bits/stdc++.h>
 ^
skyscraper.cpp:1:2: error: stray '\205' in program
 ㅁ#include <bits/stdc++.h>
  ^
skyscraper.cpp:1:3: error: stray '\201' in program
 ㅁ#include <bits/stdc++.h>
   ^
skyscraper.cpp:1:4: error: stray '#' in program
 ㅁ#include <bits/stdc++.h>
    ^
skyscraper.cpp:1:5: error: 'include' does not name a type; did you mean '__has_include'?
 ㅁ#include <bits/stdc++.h>
     ^~~~~~~
     __has_include
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:5:2: error: 'ios_base' has not been declared
  ios_base::sync_with_stdio(false);cin.tie(nullptr);
  ^~~~~~~~
skyscraper.cpp:5:35: error: 'cin' was not declared in this scope
  ios_base::sync_with_stdio(false);cin.tie(nullptr);
                                   ^~~
skyscraper.cpp:5:35: note: suggested alternative: 'main'
  ios_base::sync_with_stdio(false);cin.tie(nullptr);
                                   ^~~
                                   main
skyscraper.cpp:8:2: error: 'vector' was not declared in this scope
  vector<vector<int>> A(N);
  ^~~~~~
skyscraper.cpp:8:16: error: expected primary-expression before 'int'
  vector<vector<int>> A(N);
                ^~~
skyscraper.cpp:14:6: error: 'max' was not declared in this scope
   if(max(x, N-1-x)>=m) A[x].push_back(m);
      ^~~
skyscraper.cpp:14:6: note: suggested alternative: 'main'
   if(max(x, N-1-x)>=m) A[x].push_back(m);
      ^~~
      main
skyscraper.cpp:14:24: error: 'A' was not declared in this scope
   if(max(x, N-1-x)>=m) A[x].push_back(m);
                        ^
skyscraper.cpp:16:13: error: 'A' was not declared in this scope
  for(auto&v:A) {
             ^
skyscraper.cpp:17:8: error: 'rbegin' was not declared in this scope
   sort(rbegin(v), rend(v));
        ^~~~~~
skyscraper.cpp:17:19: error: 'rend' was not declared in this scope
   sort(rbegin(v), rend(v));
                   ^~~~
skyscraper.cpp:17:19: note: suggested alternative: 'ed'
   sort(rbegin(v), rend(v));
                   ^~~~
                   ed
skyscraper.cpp:17:3: error: 'sort' was not declared in this scope
   sort(rbegin(v), rend(v));
   ^~~~
skyscraper.cpp:17:3: note: suggested alternative: 'short'
   sort(rbegin(v), rend(v));
   ^~~~
   short
skyscraper.cpp:18:18: error: 'begin' was not declared in this scope
   v.erase(unique(begin(v), end(v)), end(v));
                  ^~~~~
skyscraper.cpp:18:28: error: 'end' was not declared in this scope
   v.erase(unique(begin(v), end(v)), end(v));
                            ^~~
skyscraper.cpp:18:28: note: suggested alternative: 'ed'
   v.erase(unique(begin(v), end(v)), end(v));
                            ^~~
                            ed
skyscraper.cpp:18:11: error: 'unique' was not declared in this scope
   v.erase(unique(begin(v), end(v)), end(v));
           ^~~~~~
skyscraper.cpp:18:11: note: suggested alternative: 'union'
   v.erase(unique(begin(v), end(v)), end(v));
           ^~~~~~
           union
skyscraper.cpp:21:9: error: expected primary-expression before 'int'
  vector<int> D(N, INT_MAX);
         ^~~
skyscraper.cpp:22:16: error: expected primary-expression before 'int'
  vector<vector<int>> Q(N+1);
                ^~~
skyscraper.cpp:24:2: error: 'Q' was not declared in this scope
  Q[0].push_back(st); D[st]=0;
  ^
skyscraper.cpp:24:22: error: 'D' was not declared in this scope
  Q[0].push_back(st); D[st]=0;
                      ^
skyscraper.cpp:27:16: error: 'cout' was not declared in this scope
    if(x==ed) { cout<<n; return 0; }
                ^~~~
skyscraper.cpp:28:14: error: 'A' was not declared in this scope
    for(int m:A[x]) {
              ^
skyscraper.cpp:31:23: error: 'rbegin' was not declared in this scope
      if(binary_search(rbegin(A[i]), rend(A[i]), m)) break;
                       ^~~~~~
skyscraper.cpp:31:37: error: 'rend' was not declared in this scope
      if(binary_search(rbegin(A[i]), rend(A[i]), m)) break;
                                     ^~~~
skyscraper.cpp:31:37: note: suggested alternative: 'ed'
      if(binary_search(rbegin(A[i]), rend(A[i]), m)) break;
                                     ^~~~
                                     ed
skyscraper.cpp:31:9: error: 'binary_search' was not declared in this scope
      if(binary_search(rbegin(A[i]), rend(A[i]), m)) break;
         ^~~~~~~~~~~~~
skyscraper.cpp:35:23: error: 'rbegin' was not declared in this scope
      if(binary_search(rbegin(A[i]), rend(A[i]), m)) break;
                       ^~~~~~
skyscraper.cpp:35:37: error: 'rend' was not declared in this scope
      if(binary_search(rbegin(A[i]), rend(A[i]), m)) break;
                                     ^~~~
skyscraper.cpp:35:37: note: suggested alternative: 'ed'
      if(binary_search(rbegin(A[i]), rend(A[i]), m)) break;
                                     ^~~~
                                     ed
skyscraper.cpp:35:9: error: 'binary_search' was not declared in this scope
      if(binary_search(rbegin(A[i]), rend(A[i]), m)) break;
         ^~~~~~~~~~~~~
skyscraper.cpp:44:2: error: 'cout' was not declared in this scope
  cout<<-1;
  ^~~~