Submission #797478

# Submission time Handle Problem Language Result Execution time Memory
797478 2023-07-29T12:42:51 Z beaconmc Minerals (JOI19_minerals) C++14
90 / 100
319 ms 15604 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) {
  ll fuck = 0;
  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;
      }
      long double ratio = 2;
      if (i.size() >= 10) ratio = 2.51;


   
      vector<ll> temp2;
      ll cutoff = (long double) i.size() / ratio;



      FOR(j,0,cutoff){
        temp2.push_back(i[j]);
      }
      temp.push_back(temp2);
      temp2.clear();
   
      FOR(j, cutoff, i.size()){
        temp2.push_back(i[j]);
      }
      temp.push_back(temp2);
    }
    bot = temp;
    temp.clear();
   
   
   
   
   
    ll ind = 0;
   
   
   
    FOR(i,0,top.size()){

      ll tempflag = -1;


      if (sus%2 == 0){
        if (machine.count(bot[ind][0])) tempflag = (sus + 1)%2;
        else tempflag = sus%2;
      }else{
        if (machine.count(bot[ind][0])) tempflag = sus%2;
        else tempflag = (sus+1)%2;
      }
   
      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);
   
      }
      ll idkman = top[i][top[i].size()-1];
      top[i].pop_back();

   
   
   
      for (auto&j : top[i]){
        ll result = query(j);
   
        if (result != curval){
          curval = result;
          first.push_back(j);
        }else{
          second.push_back(j);
        }
      }


      if (tempflag%2==1){
        
        if (first.size() != bot[ind].size()) first.push_back(idkman);
        else second.push_back(idkman);
        temp.push_back(first);
        temp.push_back(second);
      }
      else{

        if (second.size() != bot[ind].size()) second.push_back(idkman);
        else first.push_back(idkman);
        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:51: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]
   51 |   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++)
......
   77 |       FOR(j, cutoff, i.size()){
      |           ~~~~~~~~~~~~~~~~~~~      
minerals.cpp:77:7: note: in expansion of macro 'FOR'
   77 |       FOR(j, cutoff, 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++)
......
   93 |     FOR(i,0,top.size()){
      |         ~~~~~~~~~~~~~~             
minerals.cpp:93:5: note: in expansion of macro 'FOR'
   93 |     FOR(i,0,top.size()){
      |     ^~~
minerals.cpp:25:6: warning: unused variable 'fuck' [-Wunused-variable]
   25 |   ll fuck = 0;
      |      ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 648 KB Output is correct
2 Correct 10 ms 976 KB Output is correct
3 Correct 17 ms 1548 KB Output is correct
4 Correct 38 ms 2776 KB Output is correct
5 Correct 91 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 648 KB Output is correct
6 Correct 10 ms 976 KB Output is correct
7 Correct 17 ms 1548 KB Output is correct
8 Correct 38 ms 2776 KB Output is correct
9 Correct 91 ms 5112 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 61 ms 3552 KB Output is correct
12 Correct 96 ms 5140 KB Output is correct
13 Correct 66 ms 5096 KB Output is correct
14 Correct 68 ms 5020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 648 KB Output is correct
6 Correct 10 ms 976 KB Output is correct
7 Correct 17 ms 1548 KB Output is correct
8 Correct 38 ms 2776 KB Output is correct
9 Correct 91 ms 5112 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 61 ms 3552 KB Output is correct
12 Correct 96 ms 5140 KB Output is correct
13 Correct 66 ms 5096 KB Output is correct
14 Correct 68 ms 5020 KB Output is correct
15 Correct 247 ms 13536 KB Output is correct
16 Correct 258 ms 13588 KB Output is correct
17 Correct 180 ms 14748 KB Output is correct
18 Correct 182 ms 13340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 648 KB Output is correct
6 Correct 10 ms 976 KB Output is correct
7 Correct 17 ms 1548 KB Output is correct
8 Correct 38 ms 2776 KB Output is correct
9 Correct 91 ms 5112 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 61 ms 3552 KB Output is correct
12 Correct 96 ms 5140 KB Output is correct
13 Correct 66 ms 5096 KB Output is correct
14 Correct 68 ms 5020 KB Output is correct
15 Correct 247 ms 13536 KB Output is correct
16 Correct 258 ms 13588 KB Output is correct
17 Correct 180 ms 14748 KB Output is correct
18 Correct 182 ms 13340 KB Output is correct
19 Correct 265 ms 13388 KB Output is correct
20 Correct 252 ms 13204 KB Output is correct
21 Correct 185 ms 13304 KB Output is correct
22 Correct 186 ms 13172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 648 KB Output is correct
6 Correct 10 ms 976 KB Output is correct
7 Correct 17 ms 1548 KB Output is correct
8 Correct 38 ms 2776 KB Output is correct
9 Correct 91 ms 5112 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 61 ms 3552 KB Output is correct
12 Correct 96 ms 5140 KB Output is correct
13 Correct 66 ms 5096 KB Output is correct
14 Correct 68 ms 5020 KB Output is correct
15 Correct 247 ms 13536 KB Output is correct
16 Correct 258 ms 13588 KB Output is correct
17 Correct 180 ms 14748 KB Output is correct
18 Correct 182 ms 13340 KB Output is correct
19 Correct 265 ms 13388 KB Output is correct
20 Correct 252 ms 13204 KB Output is correct
21 Correct 185 ms 13304 KB Output is correct
22 Correct 186 ms 13172 KB Output is correct
23 Correct 263 ms 15432 KB Output is correct
24 Correct 257 ms 13280 KB Output is correct
25 Correct 206 ms 13684 KB Output is correct
26 Correct 192 ms 15252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 648 KB Output is correct
6 Correct 10 ms 976 KB Output is correct
7 Correct 17 ms 1548 KB Output is correct
8 Correct 38 ms 2776 KB Output is correct
9 Correct 91 ms 5112 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 61 ms 3552 KB Output is correct
12 Correct 96 ms 5140 KB Output is correct
13 Correct 66 ms 5096 KB Output is correct
14 Correct 68 ms 5020 KB Output is correct
15 Correct 247 ms 13536 KB Output is correct
16 Correct 258 ms 13588 KB Output is correct
17 Correct 180 ms 14748 KB Output is correct
18 Correct 182 ms 13340 KB Output is correct
19 Correct 265 ms 13388 KB Output is correct
20 Correct 252 ms 13204 KB Output is correct
21 Correct 185 ms 13304 KB Output is correct
22 Correct 186 ms 13172 KB Output is correct
23 Correct 263 ms 15432 KB Output is correct
24 Correct 257 ms 13280 KB Output is correct
25 Correct 206 ms 13684 KB Output is correct
26 Correct 192 ms 15252 KB Output is correct
27 Correct 274 ms 14896 KB Output is correct
28 Correct 319 ms 14928 KB Output is correct
29 Correct 206 ms 14960 KB Output is correct
30 Correct 228 ms 14088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 648 KB Output is correct
6 Correct 10 ms 976 KB Output is correct
7 Correct 17 ms 1548 KB Output is correct
8 Correct 38 ms 2776 KB Output is correct
9 Correct 91 ms 5112 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 61 ms 3552 KB Output is correct
12 Correct 96 ms 5140 KB Output is correct
13 Correct 66 ms 5096 KB Output is correct
14 Correct 68 ms 5020 KB Output is correct
15 Correct 247 ms 13536 KB Output is correct
16 Correct 258 ms 13588 KB Output is correct
17 Correct 180 ms 14748 KB Output is correct
18 Correct 182 ms 13340 KB Output is correct
19 Correct 265 ms 13388 KB Output is correct
20 Correct 252 ms 13204 KB Output is correct
21 Correct 185 ms 13304 KB Output is correct
22 Correct 186 ms 13172 KB Output is correct
23 Correct 263 ms 15432 KB Output is correct
24 Correct 257 ms 13280 KB Output is correct
25 Correct 206 ms 13684 KB Output is correct
26 Correct 192 ms 15252 KB Output is correct
27 Correct 274 ms 14896 KB Output is correct
28 Correct 319 ms 14928 KB Output is correct
29 Correct 206 ms 14960 KB Output is correct
30 Correct 228 ms 14088 KB Output is correct
31 Correct 301 ms 15404 KB Output is correct
32 Correct 285 ms 15500 KB Output is correct
33 Correct 224 ms 15604 KB Output is correct
34 Correct 209 ms 15224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 648 KB Output is correct
6 Correct 10 ms 976 KB Output is correct
7 Correct 17 ms 1548 KB Output is correct
8 Correct 38 ms 2776 KB Output is correct
9 Correct 91 ms 5112 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 61 ms 3552 KB Output is correct
12 Correct 96 ms 5140 KB Output is correct
13 Correct 66 ms 5096 KB Output is correct
14 Correct 68 ms 5020 KB Output is correct
15 Correct 247 ms 13536 KB Output is correct
16 Correct 258 ms 13588 KB Output is correct
17 Correct 180 ms 14748 KB Output is correct
18 Correct 182 ms 13340 KB Output is correct
19 Correct 265 ms 13388 KB Output is correct
20 Correct 252 ms 13204 KB Output is correct
21 Correct 185 ms 13304 KB Output is correct
22 Correct 186 ms 13172 KB Output is correct
23 Correct 263 ms 15432 KB Output is correct
24 Correct 257 ms 13280 KB Output is correct
25 Correct 206 ms 13684 KB Output is correct
26 Correct 192 ms 15252 KB Output is correct
27 Correct 274 ms 14896 KB Output is correct
28 Correct 319 ms 14928 KB Output is correct
29 Correct 206 ms 14960 KB Output is correct
30 Correct 228 ms 14088 KB Output is correct
31 Correct 301 ms 15404 KB Output is correct
32 Correct 285 ms 15500 KB Output is correct
33 Correct 224 ms 15604 KB Output is correct
34 Correct 209 ms 15224 KB Output is correct
35 Incorrect 256 ms 13656 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -