제출 #792247

#제출 시각아이디문제언어결과실행 시간메모리
792247beaconmcMinerals (JOI19_minerals)C++14
40 / 100
19 ms3708 KiB
#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::vector<ll> machine;

void empty(){
  using namespace std;
  for (auto&i : machine){
    Query(i);
  }
  machine.clear();
}

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){
    machine.push_back(i);
    ll result = Query(i);
    if (result == cur + 1){
      cur++;
      top[0].push_back(i);
    }else{
      Query(i);
      machine.pop_back();
      bot[0].push_back(i);
    }
  }
  empty();

  while (!(top.size() == bot.size() && bot.size() == N)){
    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();

    ll ind = 0;

    FOR(i,0,top.size()){
      if (top[i].size() == 1){
        ind += 1;
        temp.push_back(top[i]);
        continue;
      }
      empty();
      vector<ll> first;
      vector<ll> second;
      ll curval = 0;
      for (auto&j : bot[ind]){
        curval = Query(j);
        machine.push_back(j);
      }

      for (auto&j : top[i]){
        ll result = Query(j);
        machine.push_back(j);
        if (result > curval){
          machine.pop_back();
          Query(j);
          second.push_back(j);
        }else{
          first.push_back(j);
        }
      }
      temp.push_back(first);
      temp.push_back(second);
      ind += 2;
    }
    top = temp;
    empty();
  }

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





}

컴파일 시 표준 에러 (stderr) 메시지

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:47: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]
   47 |   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++)
......
   55 |       FOR(j,0,i.size()/2){
      |           ~~~~~~~~~~~~~~           
minerals.cpp:55:7: note: in expansion of macro 'FOR'
   55 |       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++)
......
   61 |       FOR(j, i.size()/2, i.size()){
      |           ~~~~~~~~~~~~~~~~~~~~~~~  
minerals.cpp:61:7: note: in expansion of macro 'FOR'
   61 |       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++)
......
   71 |     FOR(i,0,top.size()){
      |         ~~~~~~~~~~~~~~             
minerals.cpp:71:5: note: in expansion of macro 'FOR'
   71 |     FOR(i,0,top.size()){
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...