답안 #980736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980736 2024-05-12T11:01:05 Z Jarif_Rahman Minerals (JOI19_minerals) C++17
40 / 100
26 ms 2524 KB
#include "minerals.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int cnt = 0;
vector<int> ex;

void pbs(int l, int r, bool right, bool reset, vector<int> X){
    if(l == r){
        for(int i: X) Answer(i, ex[l]);
        return;
    }

    int md = (l+r)/2;
    if(right) for(int i = l; i <= md; i++) cnt = Query(ex[i]);
    else for(int i = r; i > md; i--) cnt = Query(ex[i]);
    vector<int> A, B;
    for(int i: X){
        if(A.size() == md-l+1){
            B.push_back(i);
            continue;
        }
        if(B.size() == r-md){
            A.push_back(i);
            continue;
        }
        int cnt_ = Query(i);
        if(cnt_ == cnt) A.push_back(i);
        else B.push_back(i);
        cnt = cnt_;
    }

    pbs(l, md, 0, 1, A);
    pbs(md+1, r, 1, reset, B);
    if(reset){
        if(right) for(int i = l; i <= md; i++) cnt = Query(ex[i]);
        else for(int i = r; i > md; i--) cnt = Query(ex[i]);
    }
}

void Solve(int n){
    vector<int> X;
    for(int i = 1; i <= 2*n; i++){
        int cnt_ = Query(i);
        if(cnt_ == cnt) ex.push_back(i);
        else X.push_back(i);
        cnt = cnt_;
    }
    for(int i: X) Query(i);
    pbs(0, n-1, 0, 0, X);
}

Compilation message

minerals.cpp: In function 'void pbs(int, int, bool, bool, std::vector<int>)':
minerals.cpp:24:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |         if(A.size() == md-l+1){
      |            ~~~~~~~~~^~~~~~~~~
minerals.cpp:28:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |         if(B.size() == r-md){
      |            ~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 5 ms 856 KB Output is correct
5 Correct 8 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1112 KB Output is correct
12 Correct 9 ms 1112 KB Output is correct
13 Correct 6 ms 1624 KB Output is correct
14 Correct 6 ms 1288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1112 KB Output is correct
12 Correct 9 ms 1112 KB Output is correct
13 Correct 6 ms 1624 KB Output is correct
14 Correct 6 ms 1288 KB Output is correct
15 Incorrect 26 ms 2524 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1112 KB Output is correct
12 Correct 9 ms 1112 KB Output is correct
13 Correct 6 ms 1624 KB Output is correct
14 Correct 6 ms 1288 KB Output is correct
15 Incorrect 26 ms 2524 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1112 KB Output is correct
12 Correct 9 ms 1112 KB Output is correct
13 Correct 6 ms 1624 KB Output is correct
14 Correct 6 ms 1288 KB Output is correct
15 Incorrect 26 ms 2524 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1112 KB Output is correct
12 Correct 9 ms 1112 KB Output is correct
13 Correct 6 ms 1624 KB Output is correct
14 Correct 6 ms 1288 KB Output is correct
15 Incorrect 26 ms 2524 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1112 KB Output is correct
12 Correct 9 ms 1112 KB Output is correct
13 Correct 6 ms 1624 KB Output is correct
14 Correct 6 ms 1288 KB Output is correct
15 Incorrect 26 ms 2524 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 8 ms 1112 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1112 KB Output is correct
12 Correct 9 ms 1112 KB Output is correct
13 Correct 6 ms 1624 KB Output is correct
14 Correct 6 ms 1288 KB Output is correct
15 Incorrect 26 ms 2524 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -