Submission #250172

# Submission time Handle Problem Language Result Execution time Memory
250172 2020-07-17T05:42:32 Z SomeoneUnknown Minerals (JOI19_minerals) C++14
6 / 100
14 ms 512 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

const int b = 208;

void Solve(int N) {
    queue<int> firsts, mbox;
    for(int i = 1; i <= 2*N; i++){
        int res = Query(i);
        if(firsts.size() < res){
            firsts.push(i);
        }else{
            mbox.push(i);
        }
        if(mbox.size() >= b){
            queue<int> ftrash;
            while(!mbox.empty()){
                int examining = firsts.front();
                firsts.pop();
                int res2 = Query(examining);
                if(firsts.size() < res2){
                    while(Query(mbox.front()) == res2){
                        Query(mbox.front());
                        mbox.push(mbox.front());
                        mbox.pop();
                    }
                    Answer(examining, mbox.front());
                    mbox.pop();
                }else{
                    firsts.push(examining);
                    Query(examining);
                }

            }
        }
    }
    if(mbox.size() != firsts.size()) int a = 1/0;
    while(!mbox.empty()){
        int res2 = Query(firsts.front());
        while(Query(mbox.front()) == res2){
            Query(mbox.front());
            mbox.push(mbox.front());
            mbox.pop();
        }
        Answer(firsts.front(), mbox.front());
        mbox.pop();
        firsts.pop();
    }
  /*int v = Query(1);
  for (int i = 1; i <= N; ++i) {
    Answer(i, 2 * N + 1 - i);
  }//*/
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:11:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(firsts.size() < res){
            ~~~~~~~~~~~~~~^~~~~
minerals.cpp:22:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(firsts.size() < res2){
                    ~~~~~~~~~~~~~~^~~~~~
minerals.cpp:38:47: warning: division by zero [-Wdiv-by-zero]
     if(mbox.size() != firsts.size()) int a = 1/0;
                                              ~^~
minerals.cpp:38:42: warning: unused variable 'a' [-Wunused-variable]
     if(mbox.size() != firsts.size()) int a = 1/0;
                                          ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 416 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
4 Incorrect 14 ms 512 KB Wrong Answer [2]
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 416 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Incorrect 14 ms 512 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 416 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Incorrect 14 ms 512 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 416 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Incorrect 14 ms 512 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 416 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Incorrect 14 ms 512 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 416 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Incorrect 14 ms 512 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 416 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Incorrect 14 ms 512 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 416 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Incorrect 14 ms 512 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -