Submission #137952

# Submission time Handle Problem Language Result Execution time Memory
137952 2019-07-28T15:25:08 Z Bohoty Minerals (JOI19_minerals) C++14
85 / 100
302 ms 17268 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;
  }
  if(a.size() == 1){
    Answer(*a.begin(), *b.begin());
    return;
  }
  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);
  }
  for(auto it : b){
    if(x.size() == y.size())continue;
    int v = get(it);
    if((!aInside && v != b4)||(aInside && v == b4)){
      y.insert(it);
    }
    b4 = v;
  }
  for(auto v : y)b.erase(v);
  goKill(x,y,aInside^1,bInside^1);
  goKill(a,b,aInside,bInside^1);
}
void Solve(int N) {
  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:59:29: warning: 'b4' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if((!aInside && v != b4)||(aInside && v == b4)){
        ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 632 KB Output is correct
2 Correct 10 ms 1016 KB Output is correct
3 Correct 19 ms 1912 KB Output is correct
4 Correct 40 ms 3496 KB Output is correct
5 Correct 80 ms 6204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 10 ms 1016 KB Output is correct
7 Correct 19 ms 1912 KB Output is correct
8 Correct 40 ms 3496 KB Output is correct
9 Correct 80 ms 6204 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 50 ms 4216 KB Output is correct
12 Correct 80 ms 6320 KB Output is correct
13 Correct 63 ms 6392 KB Output is correct
14 Correct 73 ms 6216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 10 ms 1016 KB Output is correct
7 Correct 19 ms 1912 KB Output is correct
8 Correct 40 ms 3496 KB Output is correct
9 Correct 80 ms 6204 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 50 ms 4216 KB Output is correct
12 Correct 80 ms 6320 KB Output is correct
13 Correct 63 ms 6392 KB Output is correct
14 Correct 73 ms 6216 KB Output is correct
15 Correct 250 ms 15460 KB Output is correct
16 Correct 238 ms 15620 KB Output is correct
17 Correct 182 ms 15608 KB Output is correct
18 Correct 192 ms 15372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 10 ms 1016 KB Output is correct
7 Correct 19 ms 1912 KB Output is correct
8 Correct 40 ms 3496 KB Output is correct
9 Correct 80 ms 6204 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 50 ms 4216 KB Output is correct
12 Correct 80 ms 6320 KB Output is correct
13 Correct 63 ms 6392 KB Output is correct
14 Correct 73 ms 6216 KB Output is correct
15 Correct 250 ms 15460 KB Output is correct
16 Correct 238 ms 15620 KB Output is correct
17 Correct 182 ms 15608 KB Output is correct
18 Correct 192 ms 15372 KB Output is correct
19 Correct 244 ms 15900 KB Output is correct
20 Correct 240 ms 15912 KB Output is correct
21 Correct 188 ms 15956 KB Output is correct
22 Correct 196 ms 15832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 10 ms 1016 KB Output is correct
7 Correct 19 ms 1912 KB Output is correct
8 Correct 40 ms 3496 KB Output is correct
9 Correct 80 ms 6204 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 50 ms 4216 KB Output is correct
12 Correct 80 ms 6320 KB Output is correct
13 Correct 63 ms 6392 KB Output is correct
14 Correct 73 ms 6216 KB Output is correct
15 Correct 250 ms 15460 KB Output is correct
16 Correct 238 ms 15620 KB Output is correct
17 Correct 182 ms 15608 KB Output is correct
18 Correct 192 ms 15372 KB Output is correct
19 Correct 244 ms 15900 KB Output is correct
20 Correct 240 ms 15912 KB Output is correct
21 Correct 188 ms 15956 KB Output is correct
22 Correct 196 ms 15832 KB Output is correct
23 Correct 249 ms 16472 KB Output is correct
24 Correct 302 ms 16380 KB Output is correct
25 Correct 200 ms 16376 KB Output is correct
26 Correct 199 ms 16304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 10 ms 1016 KB Output is correct
7 Correct 19 ms 1912 KB Output is correct
8 Correct 40 ms 3496 KB Output is correct
9 Correct 80 ms 6204 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 50 ms 4216 KB Output is correct
12 Correct 80 ms 6320 KB Output is correct
13 Correct 63 ms 6392 KB Output is correct
14 Correct 73 ms 6216 KB Output is correct
15 Correct 250 ms 15460 KB Output is correct
16 Correct 238 ms 15620 KB Output is correct
17 Correct 182 ms 15608 KB Output is correct
18 Correct 192 ms 15372 KB Output is correct
19 Correct 244 ms 15900 KB Output is correct
20 Correct 240 ms 15912 KB Output is correct
21 Correct 188 ms 15956 KB Output is correct
22 Correct 196 ms 15832 KB Output is correct
23 Correct 249 ms 16472 KB Output is correct
24 Correct 302 ms 16380 KB Output is correct
25 Correct 200 ms 16376 KB Output is correct
26 Correct 199 ms 16304 KB Output is correct
27 Correct 255 ms 16888 KB Output is correct
28 Correct 263 ms 16828 KB Output is correct
29 Correct 211 ms 16832 KB Output is correct
30 Correct 228 ms 16504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 10 ms 1016 KB Output is correct
7 Correct 19 ms 1912 KB Output is correct
8 Correct 40 ms 3496 KB Output is correct
9 Correct 80 ms 6204 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 50 ms 4216 KB Output is correct
12 Correct 80 ms 6320 KB Output is correct
13 Correct 63 ms 6392 KB Output is correct
14 Correct 73 ms 6216 KB Output is correct
15 Correct 250 ms 15460 KB Output is correct
16 Correct 238 ms 15620 KB Output is correct
17 Correct 182 ms 15608 KB Output is correct
18 Correct 192 ms 15372 KB Output is correct
19 Correct 244 ms 15900 KB Output is correct
20 Correct 240 ms 15912 KB Output is correct
21 Correct 188 ms 15956 KB Output is correct
22 Correct 196 ms 15832 KB Output is correct
23 Correct 249 ms 16472 KB Output is correct
24 Correct 302 ms 16380 KB Output is correct
25 Correct 200 ms 16376 KB Output is correct
26 Correct 199 ms 16304 KB Output is correct
27 Correct 255 ms 16888 KB Output is correct
28 Correct 263 ms 16828 KB Output is correct
29 Correct 211 ms 16832 KB Output is correct
30 Correct 228 ms 16504 KB Output is correct
31 Correct 266 ms 17268 KB Output is correct
32 Correct 265 ms 17212 KB Output is correct
33 Correct 199 ms 17144 KB Output is correct
34 Incorrect 194 ms 16936 KB Wrong Answer [2]
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 10 ms 1016 KB Output is correct
7 Correct 19 ms 1912 KB Output is correct
8 Correct 40 ms 3496 KB Output is correct
9 Correct 80 ms 6204 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 50 ms 4216 KB Output is correct
12 Correct 80 ms 6320 KB Output is correct
13 Correct 63 ms 6392 KB Output is correct
14 Correct 73 ms 6216 KB Output is correct
15 Correct 250 ms 15460 KB Output is correct
16 Correct 238 ms 15620 KB Output is correct
17 Correct 182 ms 15608 KB Output is correct
18 Correct 192 ms 15372 KB Output is correct
19 Correct 244 ms 15900 KB Output is correct
20 Correct 240 ms 15912 KB Output is correct
21 Correct 188 ms 15956 KB Output is correct
22 Correct 196 ms 15832 KB Output is correct
23 Correct 249 ms 16472 KB Output is correct
24 Correct 302 ms 16380 KB Output is correct
25 Correct 200 ms 16376 KB Output is correct
26 Correct 199 ms 16304 KB Output is correct
27 Correct 255 ms 16888 KB Output is correct
28 Correct 263 ms 16828 KB Output is correct
29 Correct 211 ms 16832 KB Output is correct
30 Correct 228 ms 16504 KB Output is correct
31 Correct 266 ms 17268 KB Output is correct
32 Correct 265 ms 17212 KB Output is correct
33 Correct 199 ms 17144 KB Output is correct
34 Incorrect 194 ms 16936 KB Wrong Answer [2]