답안 #485996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485996 2021-11-10T06:23:55 Z blue Minerals (JOI19_minerals) C++17
80 / 100
46 ms 3664 KB
#include "minerals.h"
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

using vi = vector<int>;

const int maxN = 43'000;

int N;

vi mushroom(1+2*maxN, 0);

void dnc(vi L, vi R, bool bL, bool bR)
{
    // cerr << "dnc " << b << " : ";
    // for(int l:L) cerr << l << ' ';
    // cerr << " | ";
    // for(int r:R) cerr << r << ' ';
    // cerr << "\n";
    if(int(L.size()) == 1)
        Answer(L[0], R[0]);
    else
    {
        int K = int(L.size());

        vi L1, L2;
        for(int i = 0; i < K/2; i++)
            L1.push_back(L[i]);

        for(int i = K/2; i < K; i++)
            L2.push_back(L[i]);

        int Q;

        // for(int l: L1)
        //     Q = Query(l); //enable

        if(bL)
        {
            for(int l: L2)
                Q = Query(l);
        }
        else
        {
            for(int l: L1)
                Q = Query(l);
        }

        vi R1, R2;

        for(int r:R)
        {
            int Q1 = Query(r);
            if(Q1 == Q)
            {
                R1.push_back(r);
            }
            else
            {
                R2.push_back(r);
            }
            Q = Q1;
        }

        dnc(L1, R1, 1, !bR);
        dnc(L2, R2, 0, !bR);
    }
}

void Solve(int N_)
{
    N = N_;

    int ct = 0;

    for(int i = 1; i <= 2*N; i++)
    {
        int Q = Query(i);
        if(Q > ct)
        {
            // cerr << "increasing ct = " << ct << " at " << i << '\n';
            ct++;
            mushroom[i] = ct;
            // cerr << i << " : " << mushroom[i] << '\n';
        }
    }

    // cerr << "check\n";

    // for(int i = 1; i <= 2*N; i++) cerr << i << " : " << mushroom[i] << '\n';


    vi leftval, rightval;
    for(int i = 1; i <= 2*N; i++)
    {
        if(mushroom[i])
            leftval.push_back(i);
        else
            rightval.push_back(i);
    }

    dnc(leftval, rightval, 1, 1);
}

Compilation message

minerals.cpp: In function 'void dnc(vi, vi, bool, bool)':
minerals.cpp:56:13: warning: 'Q' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |             if(Q1 == Q)
      |             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 584 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 712 KB Output is correct
2 Correct 2 ms 792 KB Output is correct
3 Correct 4 ms 840 KB Output is correct
4 Correct 7 ms 1180 KB Output is correct
5 Correct 15 ms 1676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 584 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
5 Correct 1 ms 712 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Correct 7 ms 1180 KB Output is correct
9 Correct 15 ms 1676 KB Output is correct
10 Correct 1 ms 712 KB Output is correct
11 Correct 9 ms 1352 KB Output is correct
12 Correct 13 ms 1664 KB Output is correct
13 Correct 12 ms 1736 KB Output is correct
14 Correct 12 ms 1640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 584 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
5 Correct 1 ms 712 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Correct 7 ms 1180 KB Output is correct
9 Correct 15 ms 1676 KB Output is correct
10 Correct 1 ms 712 KB Output is correct
11 Correct 9 ms 1352 KB Output is correct
12 Correct 13 ms 1664 KB Output is correct
13 Correct 12 ms 1736 KB Output is correct
14 Correct 12 ms 1640 KB Output is correct
15 Correct 36 ms 3440 KB Output is correct
16 Correct 36 ms 3540 KB Output is correct
17 Correct 31 ms 3348 KB Output is correct
18 Correct 30 ms 3200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 584 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
5 Correct 1 ms 712 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Correct 7 ms 1180 KB Output is correct
9 Correct 15 ms 1676 KB Output is correct
10 Correct 1 ms 712 KB Output is correct
11 Correct 9 ms 1352 KB Output is correct
12 Correct 13 ms 1664 KB Output is correct
13 Correct 12 ms 1736 KB Output is correct
14 Correct 12 ms 1640 KB Output is correct
15 Correct 36 ms 3440 KB Output is correct
16 Correct 36 ms 3540 KB Output is correct
17 Correct 31 ms 3348 KB Output is correct
18 Correct 30 ms 3200 KB Output is correct
19 Correct 45 ms 3648 KB Output is correct
20 Correct 37 ms 3612 KB Output is correct
21 Correct 32 ms 3460 KB Output is correct
22 Correct 31 ms 3348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 584 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
5 Correct 1 ms 712 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Correct 7 ms 1180 KB Output is correct
9 Correct 15 ms 1676 KB Output is correct
10 Correct 1 ms 712 KB Output is correct
11 Correct 9 ms 1352 KB Output is correct
12 Correct 13 ms 1664 KB Output is correct
13 Correct 12 ms 1736 KB Output is correct
14 Correct 12 ms 1640 KB Output is correct
15 Correct 36 ms 3440 KB Output is correct
16 Correct 36 ms 3540 KB Output is correct
17 Correct 31 ms 3348 KB Output is correct
18 Correct 30 ms 3200 KB Output is correct
19 Correct 45 ms 3648 KB Output is correct
20 Correct 37 ms 3612 KB Output is correct
21 Correct 32 ms 3460 KB Output is correct
22 Correct 31 ms 3348 KB Output is correct
23 Correct 38 ms 3648 KB Output is correct
24 Correct 46 ms 3644 KB Output is correct
25 Correct 33 ms 3516 KB Output is correct
26 Correct 40 ms 3392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 584 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
5 Correct 1 ms 712 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Correct 7 ms 1180 KB Output is correct
9 Correct 15 ms 1676 KB Output is correct
10 Correct 1 ms 712 KB Output is correct
11 Correct 9 ms 1352 KB Output is correct
12 Correct 13 ms 1664 KB Output is correct
13 Correct 12 ms 1736 KB Output is correct
14 Correct 12 ms 1640 KB Output is correct
15 Correct 36 ms 3440 KB Output is correct
16 Correct 36 ms 3540 KB Output is correct
17 Correct 31 ms 3348 KB Output is correct
18 Correct 30 ms 3200 KB Output is correct
19 Correct 45 ms 3648 KB Output is correct
20 Correct 37 ms 3612 KB Output is correct
21 Correct 32 ms 3460 KB Output is correct
22 Correct 31 ms 3348 KB Output is correct
23 Correct 38 ms 3648 KB Output is correct
24 Correct 46 ms 3644 KB Output is correct
25 Correct 33 ms 3516 KB Output is correct
26 Correct 40 ms 3392 KB Output is correct
27 Incorrect 38 ms 3664 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 584 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
5 Correct 1 ms 712 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Correct 7 ms 1180 KB Output is correct
9 Correct 15 ms 1676 KB Output is correct
10 Correct 1 ms 712 KB Output is correct
11 Correct 9 ms 1352 KB Output is correct
12 Correct 13 ms 1664 KB Output is correct
13 Correct 12 ms 1736 KB Output is correct
14 Correct 12 ms 1640 KB Output is correct
15 Correct 36 ms 3440 KB Output is correct
16 Correct 36 ms 3540 KB Output is correct
17 Correct 31 ms 3348 KB Output is correct
18 Correct 30 ms 3200 KB Output is correct
19 Correct 45 ms 3648 KB Output is correct
20 Correct 37 ms 3612 KB Output is correct
21 Correct 32 ms 3460 KB Output is correct
22 Correct 31 ms 3348 KB Output is correct
23 Correct 38 ms 3648 KB Output is correct
24 Correct 46 ms 3644 KB Output is correct
25 Correct 33 ms 3516 KB Output is correct
26 Correct 40 ms 3392 KB Output is correct
27 Incorrect 38 ms 3664 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 584 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 584 KB Output is correct
5 Correct 1 ms 712 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Correct 7 ms 1180 KB Output is correct
9 Correct 15 ms 1676 KB Output is correct
10 Correct 1 ms 712 KB Output is correct
11 Correct 9 ms 1352 KB Output is correct
12 Correct 13 ms 1664 KB Output is correct
13 Correct 12 ms 1736 KB Output is correct
14 Correct 12 ms 1640 KB Output is correct
15 Correct 36 ms 3440 KB Output is correct
16 Correct 36 ms 3540 KB Output is correct
17 Correct 31 ms 3348 KB Output is correct
18 Correct 30 ms 3200 KB Output is correct
19 Correct 45 ms 3648 KB Output is correct
20 Correct 37 ms 3612 KB Output is correct
21 Correct 32 ms 3460 KB Output is correct
22 Correct 31 ms 3348 KB Output is correct
23 Correct 38 ms 3648 KB Output is correct
24 Correct 46 ms 3644 KB Output is correct
25 Correct 33 ms 3516 KB Output is correct
26 Correct 40 ms 3392 KB Output is correct
27 Incorrect 38 ms 3664 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -