Submission #112360

# Submission time Handle Problem Language Result Execution time Memory
112360 2019-05-19T05:26:56 Z shoemakerjo Minerals (JOI19_minerals) C++14
90 / 100
86 ms 3284 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int maxn = 100010;
// map<ll, int> v;

mt19937 mt_rand(time(NULL));

int cval;
const int magic = 0;


void go(vector<int>& a, vector<int>& b, bool aactive) {

  // cout << "as: ";
  // for (int vv : a) cout << vv << " ";
  // cout << endl;
  // cout << "bs: ";
  // for (int vv : b) cout << vv << " ";
  // cout << endl;

  if (a.size() == 2) {

    if (a[0] > b[0] || a[1] > b[1]) {
      Answer(a[0], b[1]);
      Answer(a[1], b[0]);
      return;
    }
    if (a[0] > b[1] || a[1] > b[0]) {
      Answer(a[0], b[0]);
      Answer(a[1], b[1]);
      return;
    }


    cval = Query(a[0]);
    int cur = Query(b[0]);
    if (aactive) {
      if (cval == cur) {
        Answer(a[0], b[1]);
        Answer(a[1], b[0]);
      }
      else {
        Answer(a[0], b[0]);
        Answer(a[1], b[1]);
      }
    }
    else {
      if (cval == cur) {
        Answer(a[0], b[0]);
        Answer(a[1], b[1]);
      }
      else {
        Answer(a[0], b[1]);
        Answer(a[1], b[0]);
      }
    }
    cval = cur;
    return;
  }

  vector<int> al, bl, ar, br;
  shuffle(a.begin(), a.end(), mt_rand);
  shuffle(b.begin(), b.end(), mt_rand);

  if (a.size() == 1 && b.size() == 1) {
    Answer(a[0], b[0]);
    return;
  }
  if (a.size() == 0) return;

  int mid = a.size()/2;
  for (int i = 0; i < magic; i++) {
    if (mid == 1) break;
    --mid;
  }
  //modify what is true for all less than this
  for (int i = 0; i < mid; i++) {
    cval = Query(a[i]);
    al.push_back(a[i]);
  }
  for (int i = mid; i < a.size(); i++) {
    ar.push_back(a[i]);
  }

  for (int i = 0; i < b.size(); i++) {
    // cout << "here: " << b[i] << endl;
    if (bl.size() == al.size()) {
      br.push_back(b[i]);
      continue;
    }
    if (br.size() == ar.size()) {
      bl.push_back(b[i]);
      continue;
    }

    int cur = Query(b[i]);
    if (cur != cval) {
      if (aactive) {
        bl.push_back(b[i]);
      }
      else {
        br.push_back(b[i]);
      }
    }
    else {
      if (aactive) {
        br.push_back(b[i]);
      }
      else {
        bl.push_back(b[i]);
      }
    }
    cval = cur;
  }

  go(al, bl, !aactive);
  go(ar, br, aactive);

}

void Solve(int N) {
  // int nrounds = 1000000/N;
  vector<int> cl, cr;
  cval = 0;
  vector<int> stuff;
  for (int i = 1; i <= 2*N; i++) {
    stuff.push_back(i);
  }
  shuffle(stuff.begin(), stuff.end(), mt_rand);
  //the above process saves about 2 queries (not worth)

  //beginning has more limitations we are not considering
  for (int i = 1; i <= 2*N; i++) {
    if (cl.size() == N) {
      cr.push_back(i);
      // mbig[i] = i-1;
      continue;
    }
    int cur = Query(i);
    if (cur != cval) {
      cl.push_back(i);
    }
    else cr.push_back(i);
    cval = cur;
  }
  go(cl, cr, true);
}

Compilation message

minerals.cpp: In function 'void go(std::vector<int>&, std::vector<int>&, bool)':
minerals.cpp:85:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = mid; i < a.size(); i++) {
                     ~~^~~~~~~~~~
minerals.cpp:89:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < b.size(); i++) {
                   ~~^~~~~~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:138:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (cl.size() == N) {
         ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 324 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
4 Correct 13 ms 768 KB Output is correct
5 Correct 29 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 13 ms 768 KB Output is correct
9 Correct 29 ms 1280 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 17 ms 1024 KB Output is correct
12 Correct 25 ms 1280 KB Output is correct
13 Correct 24 ms 1280 KB Output is correct
14 Correct 24 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 13 ms 768 KB Output is correct
9 Correct 29 ms 1280 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 17 ms 1024 KB Output is correct
12 Correct 25 ms 1280 KB Output is correct
13 Correct 24 ms 1280 KB Output is correct
14 Correct 24 ms 1280 KB Output is correct
15 Correct 79 ms 2848 KB Output is correct
16 Correct 77 ms 2960 KB Output is correct
17 Correct 74 ms 3036 KB Output is correct
18 Correct 70 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 13 ms 768 KB Output is correct
9 Correct 29 ms 1280 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 17 ms 1024 KB Output is correct
12 Correct 25 ms 1280 KB Output is correct
13 Correct 24 ms 1280 KB Output is correct
14 Correct 24 ms 1280 KB Output is correct
15 Correct 79 ms 2848 KB Output is correct
16 Correct 77 ms 2960 KB Output is correct
17 Correct 74 ms 3036 KB Output is correct
18 Correct 70 ms 2852 KB Output is correct
19 Correct 73 ms 3100 KB Output is correct
20 Correct 74 ms 3020 KB Output is correct
21 Correct 72 ms 3184 KB Output is correct
22 Correct 73 ms 2976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 13 ms 768 KB Output is correct
9 Correct 29 ms 1280 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 17 ms 1024 KB Output is correct
12 Correct 25 ms 1280 KB Output is correct
13 Correct 24 ms 1280 KB Output is correct
14 Correct 24 ms 1280 KB Output is correct
15 Correct 79 ms 2848 KB Output is correct
16 Correct 77 ms 2960 KB Output is correct
17 Correct 74 ms 3036 KB Output is correct
18 Correct 70 ms 2852 KB Output is correct
19 Correct 73 ms 3100 KB Output is correct
20 Correct 74 ms 3020 KB Output is correct
21 Correct 72 ms 3184 KB Output is correct
22 Correct 73 ms 2976 KB Output is correct
23 Correct 77 ms 3056 KB Output is correct
24 Correct 76 ms 3152 KB Output is correct
25 Correct 74 ms 3240 KB Output is correct
26 Correct 72 ms 2928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 13 ms 768 KB Output is correct
9 Correct 29 ms 1280 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 17 ms 1024 KB Output is correct
12 Correct 25 ms 1280 KB Output is correct
13 Correct 24 ms 1280 KB Output is correct
14 Correct 24 ms 1280 KB Output is correct
15 Correct 79 ms 2848 KB Output is correct
16 Correct 77 ms 2960 KB Output is correct
17 Correct 74 ms 3036 KB Output is correct
18 Correct 70 ms 2852 KB Output is correct
19 Correct 73 ms 3100 KB Output is correct
20 Correct 74 ms 3020 KB Output is correct
21 Correct 72 ms 3184 KB Output is correct
22 Correct 73 ms 2976 KB Output is correct
23 Correct 77 ms 3056 KB Output is correct
24 Correct 76 ms 3152 KB Output is correct
25 Correct 74 ms 3240 KB Output is correct
26 Correct 72 ms 2928 KB Output is correct
27 Correct 80 ms 3232 KB Output is correct
28 Correct 86 ms 3204 KB Output is correct
29 Correct 79 ms 3284 KB Output is correct
30 Correct 84 ms 3060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 13 ms 768 KB Output is correct
9 Correct 29 ms 1280 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 17 ms 1024 KB Output is correct
12 Correct 25 ms 1280 KB Output is correct
13 Correct 24 ms 1280 KB Output is correct
14 Correct 24 ms 1280 KB Output is correct
15 Correct 79 ms 2848 KB Output is correct
16 Correct 77 ms 2960 KB Output is correct
17 Correct 74 ms 3036 KB Output is correct
18 Correct 70 ms 2852 KB Output is correct
19 Correct 73 ms 3100 KB Output is correct
20 Correct 74 ms 3020 KB Output is correct
21 Correct 72 ms 3184 KB Output is correct
22 Correct 73 ms 2976 KB Output is correct
23 Correct 77 ms 3056 KB Output is correct
24 Correct 76 ms 3152 KB Output is correct
25 Correct 74 ms 3240 KB Output is correct
26 Correct 72 ms 2928 KB Output is correct
27 Correct 80 ms 3232 KB Output is correct
28 Correct 86 ms 3204 KB Output is correct
29 Correct 79 ms 3284 KB Output is correct
30 Correct 84 ms 3060 KB Output is correct
31 Correct 84 ms 3272 KB Output is correct
32 Correct 81 ms 3236 KB Output is correct
33 Correct 77 ms 3184 KB Output is correct
34 Correct 78 ms 3056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 13 ms 768 KB Output is correct
9 Correct 29 ms 1280 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 17 ms 1024 KB Output is correct
12 Correct 25 ms 1280 KB Output is correct
13 Correct 24 ms 1280 KB Output is correct
14 Correct 24 ms 1280 KB Output is correct
15 Correct 79 ms 2848 KB Output is correct
16 Correct 77 ms 2960 KB Output is correct
17 Correct 74 ms 3036 KB Output is correct
18 Correct 70 ms 2852 KB Output is correct
19 Correct 73 ms 3100 KB Output is correct
20 Correct 74 ms 3020 KB Output is correct
21 Correct 72 ms 3184 KB Output is correct
22 Correct 73 ms 2976 KB Output is correct
23 Correct 77 ms 3056 KB Output is correct
24 Correct 76 ms 3152 KB Output is correct
25 Correct 74 ms 3240 KB Output is correct
26 Correct 72 ms 2928 KB Output is correct
27 Correct 80 ms 3232 KB Output is correct
28 Correct 86 ms 3204 KB Output is correct
29 Correct 79 ms 3284 KB Output is correct
30 Correct 84 ms 3060 KB Output is correct
31 Correct 84 ms 3272 KB Output is correct
32 Correct 81 ms 3236 KB Output is correct
33 Correct 77 ms 3184 KB Output is correct
34 Correct 78 ms 3056 KB Output is correct
35 Incorrect 85 ms 3224 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -