Submission #233692

# Submission time Handle Problem Language Result Execution time Memory
233692 2020-05-21T11:22:31 Z AlexLuchianov Minerals (JOI19_minerals) C++14
80 / 100
76 ms 4212 KB
#include "minerals.h"
#include <vector>
#include <random>
#include <algorithm>
#include <iostream>
#include <chrono>

using namespace std;

int const nmax = 43000;
int ord[1 + 2 * nmax];
vector<int> basic, spec;
int start[1 + nmax], bonus[1 + nmax];
int active[1 + 2 * nmax];
int sol[1 + nmax];

vector<int> g[1 + nmax];

int last = 0;

int query(int pos){
  int curr = Query(pos);
  active[pos] ^= 1;
  if(last == curr)
    return 0;
  else {
    last = curr;
    return 1;
  }
}


void Solve(int n) {
  for(int i = 1; i <= 2 * n; i++)
    ord[i] = i;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  shuffle(ord + 1, ord + 2 * n + 1, rng);

  int last = 0;

  for(int i = 1; i <= 2 * n; i++){
    if(query(ord[i]) == 1) {
      active[ord[i]] = 1;
      basic.push_back(ord[i]);
    } else{
      ++last;
      spec.push_back(ord[i]);
      start[spec.size() - 1] = 0 ;
      bonus[spec.size() - 1] = basic.size() - 1;
    }
  }
  for(int i = 0; i < n; i++)
    sol[i] = 0;

  int result = 2 * n;

  for(int bit = 15; 0 <= bit; bit--){
    for(int i = 0; i < n; i++)
      if(0 < ((1 << bit) & i))
        query(basic[i]);
    for(int j = 0; j < n; j++)
      if(start[j] + (1 << bit) <= bonus[j] && sol[j] != query(spec[j])){
        sol[j] ^= 1;
        start[j] += (1 << bit);
      }
  }

  for(int i = 0; i < spec.size(); i++)
    Answer(spec[i], basic[start[i]]);
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:68:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < spec.size(); i++)
                  ~~^~~~~~~~~~~~~
minerals.cpp:55:7: warning: unused variable 'result' [-Wunused-variable]
   int result = 2 * n;
       ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
4 Correct 5 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1408 KB Output is correct
2 Correct 6 ms 1536 KB Output is correct
3 Correct 9 ms 1664 KB Output is correct
4 Correct 12 ms 1920 KB Output is correct
5 Correct 31 ms 2432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
4 Correct 5 ms 1408 KB Output is correct
5 Correct 6 ms 1408 KB Output is correct
6 Correct 6 ms 1536 KB Output is correct
7 Correct 9 ms 1664 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 31 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 14 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 18 ms 2424 KB Output is correct
14 Correct 18 ms 2408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
4 Correct 5 ms 1408 KB Output is correct
5 Correct 6 ms 1408 KB Output is correct
6 Correct 6 ms 1536 KB Output is correct
7 Correct 9 ms 1664 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 31 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 14 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 18 ms 2424 KB Output is correct
14 Correct 18 ms 2408 KB Output is correct
15 Correct 51 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 46 ms 4084 KB Output is correct
18 Correct 47 ms 3828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
4 Correct 5 ms 1408 KB Output is correct
5 Correct 6 ms 1408 KB Output is correct
6 Correct 6 ms 1536 KB Output is correct
7 Correct 9 ms 1664 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 31 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 14 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 18 ms 2424 KB Output is correct
14 Correct 18 ms 2408 KB Output is correct
15 Correct 51 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 46 ms 4084 KB Output is correct
18 Correct 47 ms 3828 KB Output is correct
19 Correct 52 ms 4116 KB Output is correct
20 Correct 49 ms 4084 KB Output is correct
21 Correct 49 ms 4084 KB Output is correct
22 Correct 54 ms 3944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
4 Correct 5 ms 1408 KB Output is correct
5 Correct 6 ms 1408 KB Output is correct
6 Correct 6 ms 1536 KB Output is correct
7 Correct 9 ms 1664 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 31 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 14 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 18 ms 2424 KB Output is correct
14 Correct 18 ms 2408 KB Output is correct
15 Correct 51 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 46 ms 4084 KB Output is correct
18 Correct 47 ms 3828 KB Output is correct
19 Correct 52 ms 4116 KB Output is correct
20 Correct 49 ms 4084 KB Output is correct
21 Correct 49 ms 4084 KB Output is correct
22 Correct 54 ms 3944 KB Output is correct
23 Correct 57 ms 4084 KB Output is correct
24 Correct 50 ms 4212 KB Output is correct
25 Correct 76 ms 4212 KB Output is correct
26 Correct 49 ms 3988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
4 Correct 5 ms 1408 KB Output is correct
5 Correct 6 ms 1408 KB Output is correct
6 Correct 6 ms 1536 KB Output is correct
7 Correct 9 ms 1664 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 31 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 14 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 18 ms 2424 KB Output is correct
14 Correct 18 ms 2408 KB Output is correct
15 Correct 51 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 46 ms 4084 KB Output is correct
18 Correct 47 ms 3828 KB Output is correct
19 Correct 52 ms 4116 KB Output is correct
20 Correct 49 ms 4084 KB Output is correct
21 Correct 49 ms 4084 KB Output is correct
22 Correct 54 ms 3944 KB Output is correct
23 Correct 57 ms 4084 KB Output is correct
24 Correct 50 ms 4212 KB Output is correct
25 Correct 76 ms 4212 KB Output is correct
26 Correct 49 ms 3988 KB Output is correct
27 Incorrect 53 ms 3956 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
4 Correct 5 ms 1408 KB Output is correct
5 Correct 6 ms 1408 KB Output is correct
6 Correct 6 ms 1536 KB Output is correct
7 Correct 9 ms 1664 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 31 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 14 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 18 ms 2424 KB Output is correct
14 Correct 18 ms 2408 KB Output is correct
15 Correct 51 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 46 ms 4084 KB Output is correct
18 Correct 47 ms 3828 KB Output is correct
19 Correct 52 ms 4116 KB Output is correct
20 Correct 49 ms 4084 KB Output is correct
21 Correct 49 ms 4084 KB Output is correct
22 Correct 54 ms 3944 KB Output is correct
23 Correct 57 ms 4084 KB Output is correct
24 Correct 50 ms 4212 KB Output is correct
25 Correct 76 ms 4212 KB Output is correct
26 Correct 49 ms 3988 KB Output is correct
27 Incorrect 53 ms 3956 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
4 Correct 5 ms 1408 KB Output is correct
5 Correct 6 ms 1408 KB Output is correct
6 Correct 6 ms 1536 KB Output is correct
7 Correct 9 ms 1664 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 31 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 14 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 18 ms 2424 KB Output is correct
14 Correct 18 ms 2408 KB Output is correct
15 Correct 51 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 46 ms 4084 KB Output is correct
18 Correct 47 ms 3828 KB Output is correct
19 Correct 52 ms 4116 KB Output is correct
20 Correct 49 ms 4084 KB Output is correct
21 Correct 49 ms 4084 KB Output is correct
22 Correct 54 ms 3944 KB Output is correct
23 Correct 57 ms 4084 KB Output is correct
24 Correct 50 ms 4212 KB Output is correct
25 Correct 76 ms 4212 KB Output is correct
26 Correct 49 ms 3988 KB Output is correct
27 Incorrect 53 ms 3956 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -