답안 #671765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671765 2022-12-13T17:53:38 Z Hacv16 코끼리 (Dancing Elephants) (IOI11_elephants) C++17
컴파일 오류
0 ms 0 KB
//#include "elephants.h"
#include<bits/stdc++.h>
 
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
using namespace std;
 
typedef long long ll;
const int MAX = 2e6 + 15;
 
int n, l, pos[MAX];
vector<int> x;
 
void init(int n_, int l_, int x_[]){
  n = n_, l = l_;
  x.resize(n);

  for(int i = 0; i < n; i++)
     x[i] = x_[i], pos[i] = x[i];
}

vector<int> Merge(vector<int>& x, vector<int>& y, vector<int>& z){
  vector<int> aux(sz(x) + sz(y)), ret(sz(x) + sz(y) + sz(z));

  merge(all(x), all(y), aux.begin());
  merge(all(aux), all(z), ret.begin());

  return ret;
}
 
int update(int i, int y){ 
  vector<int> a, b, c;

  int id = 0;
  while(x[id] < pos[i]) id++;

  for(int j = 0; j < id; j++)
    a.push_back(x[j]);

  for(int j = id + 1; j < n; j++)
    b.push_back(x[j]);

  c.push_back(y);

  vector<int> aux = Merge(a, b, c);
  swap(aux, x);

  int ans = 0, r = -1;
 
  for(int j = 0; j < n; j++) 
    if(x[j] > r) ans++, r = x[j] + l;
 
  pos[i] = y;

  return ans;
}

int main(){
  init(4, 10, X);
 
  cout << update(2, 16) << '\n';
  cout << update(1, 25) << '\n';
  cout << update(3, 35) << '\n';
  cout << update(0, 38) << '\n';
  cout << update(2, 0) << '\n';
 
  return 0;
}

Compilation message

elephants.cpp: In function 'std::vector<int> Merge(std::vector<int>&, std::vector<int>&, std::vector<int>&)':
elephants.cpp:24:19: error: 'sz' was not declared in this scope; did you mean 'z'?
   24 |   vector<int> aux(sz(x) + sz(y)), ret(sz(x) + sz(y) + sz(z));
      |                   ^~
      |                   z
elephants.cpp:26:9: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   26 |   merge(all(x), all(y), aux.begin());
      |         ^~~
      |         std::filesystem::perms::all
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from elephants.cpp:2:
/usr/include/c++/10/bits/fs_fwd.h:148:7: note: 'std::filesystem::perms::all' declared here
  148 |       all  =  0777,
      |       ^~~
elephants.cpp: In function 'int main()':
elephants.cpp:60:15: error: 'X' was not declared in this scope
   60 |   init(4, 10, X);
      |               ^