Submission #792272

# Submission time Handle Problem Language Result Execution time Memory
792272 2023-07-24T23:14:25 Z beaconmc Minerals (JOI19_minerals) C++14
40 / 100
204 ms 6044 KB
#include "minerals.h"
#include <bits/stdc++.h>

typedef long long ll;



#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)



std::set<ll> machine;
int query(int a){
  if (machine.count(a)){
    machine.erase(a);
  }else{
    machine.insert(a);
  }
  return Query(a);
}

void Solve(int N) {
  using namespace std;
  vector<vector<ll>> top;
  vector<vector<ll>> bot;

  top.push_back({});
  bot.push_back({});


  ll cur = 0;

  FOR(i,1, 2*N+1){

    ll result = query(i);
    if (result == cur + 1){
      cur++;
      top[0].push_back(i);
    }else{
      bot[0].push_back(i);
    }
  }

  ll sus = 0;

  while (!(top.size() == bot.size() && bot.size() == N)){
    sus++;

    vector<vector<ll>> temp;
    for (auto&i : bot){
      if (i.size() == 1){
        temp.push_back(i);
        continue;
      }
      vector<ll> temp2;
      FOR(j,0,i.size()/2){
        temp2.push_back(i[j]);
      }
      temp.push_back(temp2);
      temp2.clear();

      FOR(j, i.size()/2, i.size()){
        temp2.push_back(i[j]);
      }
      temp.push_back(temp2);
    }
    bot = temp;
    temp.clear();




    if (sus%2==1){
      FOR(i,1,2*N+1){
        if (!machine.count(i)){
          query(i);
        }
      }
    }else{
      vector<ll> idkman;

      for (auto&i : machine){
        idkman.push_back(i);
      }
      for (auto&i : idkman){
        query(i);
      }
    }


    ll ind = 0;



    FOR(i,0,top.size()){

      if (top[i].size() == 1){
        ind += 1;
        temp.push_back(top[i]);
        continue;
      }


      vector<ll> first;
      vector<ll> second;
      ll curval = 0;
      for (auto&j : bot[ind]){

        curval = query(j);
  
      }



      for (auto&j : top[i]){
        ll result = query(j);

        if (result != curval){
          curval = result;
          first.push_back(j);
        }else{
          second.push_back(j);
        }
      }
      if (sus%2==1){
        temp.push_back(first);
        temp.push_back(second);
      }
      else{
        temp.push_back(second);
        temp.push_back(first);

      }

      ind += 2;
    }

    top = temp;

  }
  FOR(i,0,N){
    Answer((int) top[i][0],(int) bot[i][0]);
  }






}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:48:51: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |   while (!(top.size() == bot.size() && bot.size() == N)){
      |                                        ~~~~~~~~~~~^~~~
minerals.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   58 |       FOR(j,0,i.size()/2){
      |           ~~~~~~~~~~~~~~           
minerals.cpp:58:7: note: in expansion of macro 'FOR'
   58 |       FOR(j,0,i.size()/2){
      |       ^~~
minerals.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   64 |       FOR(j, i.size()/2, i.size()){
      |           ~~~~~~~~~~~~~~~~~~~~~~~  
minerals.cpp:64:7: note: in expansion of macro 'FOR'
   64 |       FOR(j, i.size()/2, i.size()){
      |       ^~~
minerals.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   97 |     FOR(i,0,top.size()){
      |         ~~~~~~~~~~~~~~             
minerals.cpp:97:5: note: in expansion of macro 'FOR'
   97 |     FOR(i,0,top.size()){
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 592 KB Output is correct
2 Correct 8 ms 848 KB Output is correct
3 Correct 19 ms 1488 KB Output is correct
4 Correct 41 ms 2576 KB Output is correct
5 Correct 89 ms 4528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 8 ms 848 KB Output is correct
7 Correct 19 ms 1488 KB Output is correct
8 Correct 41 ms 2576 KB Output is correct
9 Correct 89 ms 4528 KB Output is correct
10 Correct 4 ms 540 KB Output is correct
11 Correct 58 ms 3056 KB Output is correct
12 Correct 92 ms 4484 KB Output is correct
13 Correct 71 ms 4584 KB Output is correct
14 Correct 70 ms 4512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 8 ms 848 KB Output is correct
7 Correct 19 ms 1488 KB Output is correct
8 Correct 41 ms 2576 KB Output is correct
9 Correct 89 ms 4528 KB Output is correct
10 Correct 4 ms 540 KB Output is correct
11 Correct 58 ms 3056 KB Output is correct
12 Correct 92 ms 4484 KB Output is correct
13 Correct 71 ms 4584 KB Output is correct
14 Correct 70 ms 4512 KB Output is correct
15 Incorrect 204 ms 6044 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 8 ms 848 KB Output is correct
7 Correct 19 ms 1488 KB Output is correct
8 Correct 41 ms 2576 KB Output is correct
9 Correct 89 ms 4528 KB Output is correct
10 Correct 4 ms 540 KB Output is correct
11 Correct 58 ms 3056 KB Output is correct
12 Correct 92 ms 4484 KB Output is correct
13 Correct 71 ms 4584 KB Output is correct
14 Correct 70 ms 4512 KB Output is correct
15 Incorrect 204 ms 6044 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 8 ms 848 KB Output is correct
7 Correct 19 ms 1488 KB Output is correct
8 Correct 41 ms 2576 KB Output is correct
9 Correct 89 ms 4528 KB Output is correct
10 Correct 4 ms 540 KB Output is correct
11 Correct 58 ms 3056 KB Output is correct
12 Correct 92 ms 4484 KB Output is correct
13 Correct 71 ms 4584 KB Output is correct
14 Correct 70 ms 4512 KB Output is correct
15 Incorrect 204 ms 6044 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 8 ms 848 KB Output is correct
7 Correct 19 ms 1488 KB Output is correct
8 Correct 41 ms 2576 KB Output is correct
9 Correct 89 ms 4528 KB Output is correct
10 Correct 4 ms 540 KB Output is correct
11 Correct 58 ms 3056 KB Output is correct
12 Correct 92 ms 4484 KB Output is correct
13 Correct 71 ms 4584 KB Output is correct
14 Correct 70 ms 4512 KB Output is correct
15 Incorrect 204 ms 6044 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 8 ms 848 KB Output is correct
7 Correct 19 ms 1488 KB Output is correct
8 Correct 41 ms 2576 KB Output is correct
9 Correct 89 ms 4528 KB Output is correct
10 Correct 4 ms 540 KB Output is correct
11 Correct 58 ms 3056 KB Output is correct
12 Correct 92 ms 4484 KB Output is correct
13 Correct 71 ms 4584 KB Output is correct
14 Correct 70 ms 4512 KB Output is correct
15 Incorrect 204 ms 6044 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 8 ms 848 KB Output is correct
7 Correct 19 ms 1488 KB Output is correct
8 Correct 41 ms 2576 KB Output is correct
9 Correct 89 ms 4528 KB Output is correct
10 Correct 4 ms 540 KB Output is correct
11 Correct 58 ms 3056 KB Output is correct
12 Correct 92 ms 4484 KB Output is correct
13 Correct 71 ms 4584 KB Output is correct
14 Correct 70 ms 4512 KB Output is correct
15 Incorrect 204 ms 6044 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -