답안 #137953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137953 2019-07-28T15:28:29 Z Bohoty Minerals (JOI19_minerals) C++14
컴파일 오류
0 ms 0 KB
#include "minerals.h"
//#include "grader.cpp"
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
const int mxN = 2e5 + 5;
int inside[mxN], tot;
int get(int x){
  if(inside[x])
  tot--;
  else
  tot++;
  inside[x] ^= 1;
  return tot - Query(x);
}
void goKill(set<int> a, set<int> b, bool aInside, bool bInside){
  // cout << a.size() << '\n';
  if(a.size() == 2){
      int cur = get(*a.begin());
      int cur2 = get(*b.begin());
      if(aInside){
        if(cur == cur2){
          Answer(*a.begin(),*b.begin());
          Answer(*a.rbegin(),*b.rbegin());
        } else {
          Answer(*a.begin(),*b.rbegin());
          Answer(*a.rbegin(),*b.begin());
        }
      }
    else {
      if(cur != cur2){
        Answer(*a.begin(),*b.begin());
        Answer(*a.rbegin(),*b.rbegin());
      } else {
        Answer(*a.begin(),*b.rbegin());
        Answer(*a.rbegin(),*b.begin());
      }
    }
    return;
  }
  std::vector<int> o;
  if(a.size() == 1){
    Answer(*a.begin(), *b.begin());
    return;
  }
  std::vector<int> o;
  for(auto x : b)o.push_back(x);
  random_shuffle(o.begin(),o.end());
  int sz = a.size();
  set<int> x, y;
  int b4;
  int take = ceil(0.35 * sz);
  if(!aInside)take = sz - take;
  for(int j = 1; j <= ceil(0.35 * sz); j++){
    int v = *a.begin();
    a.erase(v);
    x.insert(v);
    b4 = get(v);
  }
  b.clear();
  for(auto it : o){
    if(x.size() == y.size())b.insert(it);
    else {
    int v = get(it);
    if((!aInside && v != b4)||(aInside && v == b4)){
      y.insert(it);
    } else b.insert(it);
    b4 = v;
    }
  }
  goKill(x,y,aInside^1,bInside^1);
  goKill(a,b,aInside,bInside^1);
}
void Solve(int N) {
  srand(time());
  int n = N + N;
  set<int> a, b;
  int b4 = 0;
  for (int i = 1; i <= n; i++) {
    int x = get(i);
    if(x > b4){
      a.insert(i);
    } else {
      b.insert(i);
    }
    b4 = x;
  }
  // cout << a.size() << ' ' << b.size() << '\n';

  goKill(a, b, 1, 1);

}

Compilation message

minerals.cpp: In function 'void goKill(std::set<int>, std::set<int>, bool, bool)':
minerals.cpp:46:20: error: redeclaration of 'std::vector<int> o'
   std::vector<int> o;
                    ^
minerals.cpp:41:20: note: 'std::vector<int> o' previously declared here
   std::vector<int> o;
                    ^
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:75:14: error: too few arguments to function 'time_t time(time_t*)'
   srand(time());
              ^
In file included from /usr/include/c++/7/ctime:42:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:49,
                 from minerals.cpp:4:
/usr/include/time.h:192:15: note: declared here
 extern time_t time (time_t *__timer) __THROW;
               ^~~~