Submission #233685

# Submission time Handle Problem Language Result Execution time Memory
233685 2020-05-21T11:11:42 Z AlexLuchianov Minerals (JOI19_minerals) C++14
80 / 100
56 ms 4212 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(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: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 6 ms 1536 KB Output is correct
3 Correct 8 ms 1664 KB Output is correct
4 Correct 11 ms 1920 KB Output is correct
5 Correct 19 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 8 ms 1664 KB Output is correct
8 Correct 11 ms 1920 KB Output is correct
9 Correct 19 ms 2408 KB Output is correct
10 Correct 6 ms 1456 KB Output is correct
11 Correct 13 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 20 ms 2432 KB Output is correct
14 Correct 19 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 8 ms 1664 KB Output is correct
8 Correct 11 ms 1920 KB Output is correct
9 Correct 19 ms 2408 KB Output is correct
10 Correct 6 ms 1456 KB Output is correct
11 Correct 13 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 20 ms 2432 KB Output is correct
14 Correct 19 ms 2432 KB Output is correct
15 Correct 52 ms 3988 KB Output is correct
16 Correct 49 ms 4100 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 48 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 8 ms 1664 KB Output is correct
8 Correct 11 ms 1920 KB Output is correct
9 Correct 19 ms 2408 KB Output is correct
10 Correct 6 ms 1456 KB Output is correct
11 Correct 13 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 20 ms 2432 KB Output is correct
14 Correct 19 ms 2432 KB Output is correct
15 Correct 52 ms 3988 KB Output is correct
16 Correct 49 ms 4100 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 48 ms 3828 KB Output is correct
19 Correct 50 ms 4084 KB Output is correct
20 Correct 51 ms 4068 KB Output is correct
21 Correct 48 ms 4080 KB Output is correct
22 Correct 56 ms 3956 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 8 ms 1664 KB Output is correct
8 Correct 11 ms 1920 KB Output is correct
9 Correct 19 ms 2408 KB Output is correct
10 Correct 6 ms 1456 KB Output is correct
11 Correct 13 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 20 ms 2432 KB Output is correct
14 Correct 19 ms 2432 KB Output is correct
15 Correct 52 ms 3988 KB Output is correct
16 Correct 49 ms 4100 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 48 ms 3828 KB Output is correct
19 Correct 50 ms 4084 KB Output is correct
20 Correct 51 ms 4068 KB Output is correct
21 Correct 48 ms 4080 KB Output is correct
22 Correct 56 ms 3956 KB Output is correct
23 Correct 50 ms 4212 KB Output is correct
24 Correct 52 ms 4212 KB Output is correct
25 Correct 49 ms 4084 KB Output is correct
26 Correct 50 ms 3956 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 8 ms 1664 KB Output is correct
8 Correct 11 ms 1920 KB Output is correct
9 Correct 19 ms 2408 KB Output is correct
10 Correct 6 ms 1456 KB Output is correct
11 Correct 13 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 20 ms 2432 KB Output is correct
14 Correct 19 ms 2432 KB Output is correct
15 Correct 52 ms 3988 KB Output is correct
16 Correct 49 ms 4100 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 48 ms 3828 KB Output is correct
19 Correct 50 ms 4084 KB Output is correct
20 Correct 51 ms 4068 KB Output is correct
21 Correct 48 ms 4080 KB Output is correct
22 Correct 56 ms 3956 KB Output is correct
23 Correct 50 ms 4212 KB Output is correct
24 Correct 52 ms 4212 KB Output is correct
25 Correct 49 ms 4084 KB Output is correct
26 Correct 50 ms 3956 KB Output is correct
27 Incorrect 53 ms 4104 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 8 ms 1664 KB Output is correct
8 Correct 11 ms 1920 KB Output is correct
9 Correct 19 ms 2408 KB Output is correct
10 Correct 6 ms 1456 KB Output is correct
11 Correct 13 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 20 ms 2432 KB Output is correct
14 Correct 19 ms 2432 KB Output is correct
15 Correct 52 ms 3988 KB Output is correct
16 Correct 49 ms 4100 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 48 ms 3828 KB Output is correct
19 Correct 50 ms 4084 KB Output is correct
20 Correct 51 ms 4068 KB Output is correct
21 Correct 48 ms 4080 KB Output is correct
22 Correct 56 ms 3956 KB Output is correct
23 Correct 50 ms 4212 KB Output is correct
24 Correct 52 ms 4212 KB Output is correct
25 Correct 49 ms 4084 KB Output is correct
26 Correct 50 ms 3956 KB Output is correct
27 Incorrect 53 ms 4104 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 8 ms 1664 KB Output is correct
8 Correct 11 ms 1920 KB Output is correct
9 Correct 19 ms 2408 KB Output is correct
10 Correct 6 ms 1456 KB Output is correct
11 Correct 13 ms 2048 KB Output is correct
12 Correct 21 ms 2432 KB Output is correct
13 Correct 20 ms 2432 KB Output is correct
14 Correct 19 ms 2432 KB Output is correct
15 Correct 52 ms 3988 KB Output is correct
16 Correct 49 ms 4100 KB Output is correct
17 Correct 49 ms 4084 KB Output is correct
18 Correct 48 ms 3828 KB Output is correct
19 Correct 50 ms 4084 KB Output is correct
20 Correct 51 ms 4068 KB Output is correct
21 Correct 48 ms 4080 KB Output is correct
22 Correct 56 ms 3956 KB Output is correct
23 Correct 50 ms 4212 KB Output is correct
24 Correct 52 ms 4212 KB Output is correct
25 Correct 49 ms 4084 KB Output is correct
26 Correct 50 ms 3956 KB Output is correct
27 Incorrect 53 ms 4104 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -