Submission #233684

# Submission time Handle Problem Language Result Execution time Memory
233684 2020-05-21T11:10:49 Z AlexLuchianov Minerals (JOI19_minerals) C++14
75 / 100
50 ms 4120 KB
#include "minerals.h"
#include <vector>
#include <random>
#include <algorithm>
#include <iostream>

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;
  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(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:67:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < spec.size(); i++)
                  ~~^~~~~~~~~~~~~
minerals.cpp:54: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 8 ms 1536 KB Output is correct
3 Correct 9 ms 1640 KB Output is correct
4 Correct 12 ms 1920 KB Output is correct
5 Correct 20 ms 2552 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 8 ms 1536 KB Output is correct
7 Correct 9 ms 1640 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 20 ms 2552 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 16 ms 2048 KB Output is correct
12 Correct 19 ms 2432 KB Output is correct
13 Correct 18 ms 2432 KB Output is correct
14 Correct 21 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 8 ms 1536 KB Output is correct
7 Correct 9 ms 1640 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 20 ms 2552 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 16 ms 2048 KB Output is correct
12 Correct 19 ms 2432 KB Output is correct
13 Correct 18 ms 2432 KB Output is correct
14 Correct 21 ms 2432 KB Output is correct
15 Correct 47 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 46 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 8 ms 1536 KB Output is correct
7 Correct 9 ms 1640 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 20 ms 2552 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 16 ms 2048 KB Output is correct
12 Correct 19 ms 2432 KB Output is correct
13 Correct 18 ms 2432 KB Output is correct
14 Correct 21 ms 2432 KB Output is correct
15 Correct 47 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 46 ms 3828 KB Output is correct
19 Correct 48 ms 4120 KB Output is correct
20 Correct 50 ms 4084 KB Output is correct
21 Correct 47 ms 4084 KB Output is correct
22 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 8 ms 1536 KB Output is correct
7 Correct 9 ms 1640 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 20 ms 2552 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 16 ms 2048 KB Output is correct
12 Correct 19 ms 2432 KB Output is correct
13 Correct 18 ms 2432 KB Output is correct
14 Correct 21 ms 2432 KB Output is correct
15 Correct 47 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 46 ms 3828 KB Output is correct
19 Correct 48 ms 4120 KB Output is correct
20 Correct 50 ms 4084 KB Output is correct
21 Correct 47 ms 4084 KB Output is correct
22 Correct 49 ms 3988 KB Output is correct
23 Incorrect 49 ms 3836 KB Wrong Answer [2]
24 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 8 ms 1536 KB Output is correct
7 Correct 9 ms 1640 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 20 ms 2552 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 16 ms 2048 KB Output is correct
12 Correct 19 ms 2432 KB Output is correct
13 Correct 18 ms 2432 KB Output is correct
14 Correct 21 ms 2432 KB Output is correct
15 Correct 47 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 46 ms 3828 KB Output is correct
19 Correct 48 ms 4120 KB Output is correct
20 Correct 50 ms 4084 KB Output is correct
21 Correct 47 ms 4084 KB Output is correct
22 Correct 49 ms 3988 KB Output is correct
23 Incorrect 49 ms 3836 KB Wrong Answer [2]
24 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 8 ms 1536 KB Output is correct
7 Correct 9 ms 1640 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 20 ms 2552 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 16 ms 2048 KB Output is correct
12 Correct 19 ms 2432 KB Output is correct
13 Correct 18 ms 2432 KB Output is correct
14 Correct 21 ms 2432 KB Output is correct
15 Correct 47 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 46 ms 3828 KB Output is correct
19 Correct 48 ms 4120 KB Output is correct
20 Correct 50 ms 4084 KB Output is correct
21 Correct 47 ms 4084 KB Output is correct
22 Correct 49 ms 3988 KB Output is correct
23 Incorrect 49 ms 3836 KB Wrong Answer [2]
24 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 8 ms 1536 KB Output is correct
7 Correct 9 ms 1640 KB Output is correct
8 Correct 12 ms 1920 KB Output is correct
9 Correct 20 ms 2552 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 16 ms 2048 KB Output is correct
12 Correct 19 ms 2432 KB Output is correct
13 Correct 18 ms 2432 KB Output is correct
14 Correct 21 ms 2432 KB Output is correct
15 Correct 47 ms 4084 KB Output is correct
16 Correct 49 ms 4084 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 46 ms 3828 KB Output is correct
19 Correct 48 ms 4120 KB Output is correct
20 Correct 50 ms 4084 KB Output is correct
21 Correct 47 ms 4084 KB Output is correct
22 Correct 49 ms 3988 KB Output is correct
23 Incorrect 49 ms 3836 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -