Submission #944274

# Submission time Handle Problem Language Result Execution time Memory
944274 2024-03-12T13:34:10 Z nguyentunglam Minerals (JOI19_minerals) C++17
40 / 100
16 ms 6928 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

const int NN = 1e5 + 10;

bool in[NN];

int g[NN], one[NN], ans[NN], l[NN], r[NN];

vector<int> ask[NN];

void Solve(int n) {
  int cur = 0;
  for(int i = 1, j = 0; i <= 2 * n; i++) {
    if (Query(i) > cur) {
      g[i] = 1;
      in[i] ^= 1;
      cur++;
      one[++j] = i;
    }
    else g[i] = 2;
  }

  for(int i = 1; i <= 2 * n; i++) Query(i);

  for(int i = 1; i <= 2 * n; i++) if (g[i] == 2) {
    l[i] = 1;
    r[i] = n;
  }

  for(int loop = 1; loop <= 20; loop++) {
    bool stop = 1;
    for(int i = 1; i <= 2 * n; i++) if (g[i] == 2) {
      if (l[i] > r[i]) continue;
      stop = 0;
      int mid = l[i] + r[i] >> 1;
      ask[mid].push_back(i);
    }
    if (stop) break;
    for(int i = 1; i <= n; i++) {
      int cur = Query(one[i]);
      for(int &j : ask[i]) {
        int nxt = Query(j);
        if (nxt == cur) {
          ans[j] = i;
          r[j] = i - 1;
        } else l[j] = i + 1;
        Query(j);
      } ask[i].clear();
    }
    for(int i = 1; i <= n; i++) Query(one[i]);
  }

  for(int i = 1; i <= 2 * n; i++) if (g[i] == 2) {
    Answer(i, one[ans[i]]);
  }
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:37:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   37 |       int mid = l[i] + r[i] >> 1;
      |                 ~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4720 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 2 ms 4696 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 6 ms 5464 KB Output is correct
5 Correct 11 ms 6348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4720 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 2 ms 4696 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 6 ms 5464 KB Output is correct
9 Correct 11 ms 6348 KB Output is correct
10 Correct 2 ms 4696 KB Output is correct
11 Correct 9 ms 5976 KB Output is correct
12 Correct 14 ms 6488 KB Output is correct
13 Correct 9 ms 6232 KB Output is correct
14 Correct 10 ms 6448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4720 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 2 ms 4696 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 6 ms 5464 KB Output is correct
9 Correct 11 ms 6348 KB Output is correct
10 Correct 2 ms 4696 KB Output is correct
11 Correct 9 ms 5976 KB Output is correct
12 Correct 14 ms 6488 KB Output is correct
13 Correct 9 ms 6232 KB Output is correct
14 Correct 10 ms 6448 KB Output is correct
15 Incorrect 16 ms 6928 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4720 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 2 ms 4696 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 6 ms 5464 KB Output is correct
9 Correct 11 ms 6348 KB Output is correct
10 Correct 2 ms 4696 KB Output is correct
11 Correct 9 ms 5976 KB Output is correct
12 Correct 14 ms 6488 KB Output is correct
13 Correct 9 ms 6232 KB Output is correct
14 Correct 10 ms 6448 KB Output is correct
15 Incorrect 16 ms 6928 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4720 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 2 ms 4696 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 6 ms 5464 KB Output is correct
9 Correct 11 ms 6348 KB Output is correct
10 Correct 2 ms 4696 KB Output is correct
11 Correct 9 ms 5976 KB Output is correct
12 Correct 14 ms 6488 KB Output is correct
13 Correct 9 ms 6232 KB Output is correct
14 Correct 10 ms 6448 KB Output is correct
15 Incorrect 16 ms 6928 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4720 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 2 ms 4696 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 6 ms 5464 KB Output is correct
9 Correct 11 ms 6348 KB Output is correct
10 Correct 2 ms 4696 KB Output is correct
11 Correct 9 ms 5976 KB Output is correct
12 Correct 14 ms 6488 KB Output is correct
13 Correct 9 ms 6232 KB Output is correct
14 Correct 10 ms 6448 KB Output is correct
15 Incorrect 16 ms 6928 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4720 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 2 ms 4696 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 6 ms 5464 KB Output is correct
9 Correct 11 ms 6348 KB Output is correct
10 Correct 2 ms 4696 KB Output is correct
11 Correct 9 ms 5976 KB Output is correct
12 Correct 14 ms 6488 KB Output is correct
13 Correct 9 ms 6232 KB Output is correct
14 Correct 10 ms 6448 KB Output is correct
15 Incorrect 16 ms 6928 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4696 KB Output is correct
3 Correct 1 ms 4720 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 2 ms 4696 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 6 ms 5464 KB Output is correct
9 Correct 11 ms 6348 KB Output is correct
10 Correct 2 ms 4696 KB Output is correct
11 Correct 9 ms 5976 KB Output is correct
12 Correct 14 ms 6488 KB Output is correct
13 Correct 9 ms 6232 KB Output is correct
14 Correct 10 ms 6448 KB Output is correct
15 Incorrect 16 ms 6928 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -