답안 #233682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233682 2020-05-21T11:09:37 Z AlexLuchianov Minerals (JOI19_minerals) C++14
40 / 100
45 ms 3684 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] = query(spec[j]);
        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;
       ^~~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1408 KB Output is correct
2 Correct 7 ms 1408 KB Output is correct
3 Correct 8 ms 1664 KB Output is correct
4 Correct 12 ms 2048 KB Output is correct
5 Correct 20 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 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 7 ms 1408 KB Output is correct
7 Correct 8 ms 1664 KB Output is correct
8 Correct 12 ms 2048 KB Output is correct
9 Correct 20 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 15 ms 2048 KB Output is correct
12 Correct 21 ms 2516 KB Output is correct
13 Correct 20 ms 2384 KB Output is correct
14 Correct 20 ms 2460 KB Output is correct
# 결과 실행 시간 메모리 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 7 ms 1408 KB Output is correct
7 Correct 8 ms 1664 KB Output is correct
8 Correct 12 ms 2048 KB Output is correct
9 Correct 20 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 15 ms 2048 KB Output is correct
12 Correct 21 ms 2516 KB Output is correct
13 Correct 20 ms 2384 KB Output is correct
14 Correct 20 ms 2460 KB Output is correct
15 Incorrect 45 ms 3684 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 7 ms 1408 KB Output is correct
7 Correct 8 ms 1664 KB Output is correct
8 Correct 12 ms 2048 KB Output is correct
9 Correct 20 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 15 ms 2048 KB Output is correct
12 Correct 21 ms 2516 KB Output is correct
13 Correct 20 ms 2384 KB Output is correct
14 Correct 20 ms 2460 KB Output is correct
15 Incorrect 45 ms 3684 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 7 ms 1408 KB Output is correct
7 Correct 8 ms 1664 KB Output is correct
8 Correct 12 ms 2048 KB Output is correct
9 Correct 20 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 15 ms 2048 KB Output is correct
12 Correct 21 ms 2516 KB Output is correct
13 Correct 20 ms 2384 KB Output is correct
14 Correct 20 ms 2460 KB Output is correct
15 Incorrect 45 ms 3684 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 7 ms 1408 KB Output is correct
7 Correct 8 ms 1664 KB Output is correct
8 Correct 12 ms 2048 KB Output is correct
9 Correct 20 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 15 ms 2048 KB Output is correct
12 Correct 21 ms 2516 KB Output is correct
13 Correct 20 ms 2384 KB Output is correct
14 Correct 20 ms 2460 KB Output is correct
15 Incorrect 45 ms 3684 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 7 ms 1408 KB Output is correct
7 Correct 8 ms 1664 KB Output is correct
8 Correct 12 ms 2048 KB Output is correct
9 Correct 20 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 15 ms 2048 KB Output is correct
12 Correct 21 ms 2516 KB Output is correct
13 Correct 20 ms 2384 KB Output is correct
14 Correct 20 ms 2460 KB Output is correct
15 Incorrect 45 ms 3684 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 7 ms 1408 KB Output is correct
7 Correct 8 ms 1664 KB Output is correct
8 Correct 12 ms 2048 KB Output is correct
9 Correct 20 ms 2432 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 15 ms 2048 KB Output is correct
12 Correct 21 ms 2516 KB Output is correct
13 Correct 20 ms 2384 KB Output is correct
14 Correct 20 ms 2460 KB Output is correct
15 Incorrect 45 ms 3684 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -