답안 #227256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227256 2020-04-26T16:06:17 Z MKopchev Minerals (JOI19_minerals) C++14
90 / 100
68 ms 3716 KB
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;

const int nmax=1e5+42;

int used=0;

int colour[nmax]={0,1,2,3,3,1,2,4,4};
int cnt[nmax];
bool in[nmax];

int CURRENT;
/*
int Query(int pos)
{
    used++;

    CURRENT=CURRENT-(cnt[colour[pos]]>0);

    if(in[pos])
    {
        in[pos]=0;
        cnt[colour[pos]]--;
    }
    else
    {
        in[pos]=1;
        cnt[colour[pos]]++;
    }

    CURRENT=CURRENT+(cnt[colour[pos]]>0);

    return CURRENT;
}
void Answer(int a,int b)
{
    return;
    cout<<a<<" "<<b<<endl;
}
*/
vector< pair<int,int> > outp;

int current=0;

int which_is_active(int le,int ri)
{
    if(le)return 0;
    return 1;
}
void solve(vector<int> lhs,vector<int> rhs,bool active_lhs)
{
    /*
    cout<<active_lhs<<" LHS: ";for(auto k:lhs)cout<<k<<" ";cout<<endl;
    cout<<active_rhs<<" RHS: ";for(auto k:rhs)cout<<k<<" ";cout<<endl;
    cout<<"---"<<endl;
    */

    if(lhs.size()==1)
    {
        outp.push_back({lhs[0],rhs[0]});
        return;
    }

    int mid=lhs.size()/2;

    vector<int> lhs_new[2],rhs_new[2];

    lhs_new[0]={};lhs_new[1]={};

    rhs_new[0]={};rhs_new[1]={};

    for(int i=0;i<mid;i++)
    {
        int mem=Query(lhs[i]);

        current=mem;

        lhs_new[0].push_back(lhs[i]);
    }

    for(int i=mid;i<lhs.size();i++)
        lhs_new[1].push_back(lhs[i]);

    bool type_lhs[2]={!active_lhs,active_lhs};

    for(auto k:rhs)
    {
        if(rhs_new[0].size()==lhs_new[0].size())rhs_new[1].push_back(k);
        else if(rhs_new[1].size()==lhs_new[1].size())rhs_new[0].push_back(k);
        else
        {
            int mem=Query(k);

            if(current==mem)rhs_new[which_is_active(type_lhs[0],type_lhs[1])].push_back(k);
            else rhs_new[!which_is_active(type_lhs[0],type_lhs[1])].push_back(k);

            current=mem;
        }
    }

    solve(lhs_new[0],rhs_new[0],type_lhs[0]);

    solve(lhs_new[1],rhs_new[1],type_lhs[1]);
}
void Solve(int n)
{
    vector<int> lhs={},rhs={};

    for(int i=1;i<=2*n;i++)
    {
        int mem=Query(i);
        if(current<mem)lhs.push_back(i);
        else rhs.push_back(i);

        current=mem;
    }

    solve(lhs,rhs,1);

    for(int i=0;i<n;i++)
        Answer(outp[i].first,outp[i].second);
}
/*
int n;
void create()
{

    for(int i=1;i<=n;i++)
        colour[i]=i;
    for(int i=n+1;i<=2*n;i++)
        colour[i]=i-n;

}

int main()
{
    n=4.3e4;

    create();

    Solve(n);

    cout<<"used= "<<used<<endl;

    return 0;
}
*/

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:82:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=mid;i<lhs.size();i++)
                   ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
3 Correct 10 ms 640 KB Output is correct
4 Correct 15 ms 1024 KB Output is correct
5 Correct 24 ms 1440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 15 ms 1024 KB Output is correct
9 Correct 24 ms 1440 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 19 ms 1280 KB Output is correct
12 Correct 28 ms 1588 KB Output is correct
13 Correct 24 ms 1536 KB Output is correct
14 Correct 21 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 15 ms 1024 KB Output is correct
9 Correct 24 ms 1440 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 19 ms 1280 KB Output is correct
12 Correct 28 ms 1588 KB Output is correct
13 Correct 24 ms 1536 KB Output is correct
14 Correct 21 ms 1536 KB Output is correct
15 Correct 60 ms 3420 KB Output is correct
16 Correct 61 ms 3420 KB Output is correct
17 Correct 49 ms 3380 KB Output is correct
18 Correct 57 ms 3224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 15 ms 1024 KB Output is correct
9 Correct 24 ms 1440 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 19 ms 1280 KB Output is correct
12 Correct 28 ms 1588 KB Output is correct
13 Correct 24 ms 1536 KB Output is correct
14 Correct 21 ms 1536 KB Output is correct
15 Correct 60 ms 3420 KB Output is correct
16 Correct 61 ms 3420 KB Output is correct
17 Correct 49 ms 3380 KB Output is correct
18 Correct 57 ms 3224 KB Output is correct
19 Correct 65 ms 3504 KB Output is correct
20 Correct 62 ms 3508 KB Output is correct
21 Correct 50 ms 3348 KB Output is correct
22 Correct 50 ms 3260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 15 ms 1024 KB Output is correct
9 Correct 24 ms 1440 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 19 ms 1280 KB Output is correct
12 Correct 28 ms 1588 KB Output is correct
13 Correct 24 ms 1536 KB Output is correct
14 Correct 21 ms 1536 KB Output is correct
15 Correct 60 ms 3420 KB Output is correct
16 Correct 61 ms 3420 KB Output is correct
17 Correct 49 ms 3380 KB Output is correct
18 Correct 57 ms 3224 KB Output is correct
19 Correct 65 ms 3504 KB Output is correct
20 Correct 62 ms 3508 KB Output is correct
21 Correct 50 ms 3348 KB Output is correct
22 Correct 50 ms 3260 KB Output is correct
23 Correct 67 ms 3588 KB Output is correct
24 Correct 67 ms 3612 KB Output is correct
25 Correct 52 ms 3516 KB Output is correct
26 Correct 53 ms 3296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 15 ms 1024 KB Output is correct
9 Correct 24 ms 1440 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 19 ms 1280 KB Output is correct
12 Correct 28 ms 1588 KB Output is correct
13 Correct 24 ms 1536 KB Output is correct
14 Correct 21 ms 1536 KB Output is correct
15 Correct 60 ms 3420 KB Output is correct
16 Correct 61 ms 3420 KB Output is correct
17 Correct 49 ms 3380 KB Output is correct
18 Correct 57 ms 3224 KB Output is correct
19 Correct 65 ms 3504 KB Output is correct
20 Correct 62 ms 3508 KB Output is correct
21 Correct 50 ms 3348 KB Output is correct
22 Correct 50 ms 3260 KB Output is correct
23 Correct 67 ms 3588 KB Output is correct
24 Correct 67 ms 3612 KB Output is correct
25 Correct 52 ms 3516 KB Output is correct
26 Correct 53 ms 3296 KB Output is correct
27 Correct 64 ms 3584 KB Output is correct
28 Correct 64 ms 3608 KB Output is correct
29 Correct 53 ms 3560 KB Output is correct
30 Correct 60 ms 3440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 15 ms 1024 KB Output is correct
9 Correct 24 ms 1440 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 19 ms 1280 KB Output is correct
12 Correct 28 ms 1588 KB Output is correct
13 Correct 24 ms 1536 KB Output is correct
14 Correct 21 ms 1536 KB Output is correct
15 Correct 60 ms 3420 KB Output is correct
16 Correct 61 ms 3420 KB Output is correct
17 Correct 49 ms 3380 KB Output is correct
18 Correct 57 ms 3224 KB Output is correct
19 Correct 65 ms 3504 KB Output is correct
20 Correct 62 ms 3508 KB Output is correct
21 Correct 50 ms 3348 KB Output is correct
22 Correct 50 ms 3260 KB Output is correct
23 Correct 67 ms 3588 KB Output is correct
24 Correct 67 ms 3612 KB Output is correct
25 Correct 52 ms 3516 KB Output is correct
26 Correct 53 ms 3296 KB Output is correct
27 Correct 64 ms 3584 KB Output is correct
28 Correct 64 ms 3608 KB Output is correct
29 Correct 53 ms 3560 KB Output is correct
30 Correct 60 ms 3440 KB Output is correct
31 Correct 65 ms 3712 KB Output is correct
32 Correct 67 ms 3716 KB Output is correct
33 Correct 56 ms 3548 KB Output is correct
34 Correct 60 ms 3432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 10 ms 640 KB Output is correct
8 Correct 15 ms 1024 KB Output is correct
9 Correct 24 ms 1440 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 19 ms 1280 KB Output is correct
12 Correct 28 ms 1588 KB Output is correct
13 Correct 24 ms 1536 KB Output is correct
14 Correct 21 ms 1536 KB Output is correct
15 Correct 60 ms 3420 KB Output is correct
16 Correct 61 ms 3420 KB Output is correct
17 Correct 49 ms 3380 KB Output is correct
18 Correct 57 ms 3224 KB Output is correct
19 Correct 65 ms 3504 KB Output is correct
20 Correct 62 ms 3508 KB Output is correct
21 Correct 50 ms 3348 KB Output is correct
22 Correct 50 ms 3260 KB Output is correct
23 Correct 67 ms 3588 KB Output is correct
24 Correct 67 ms 3612 KB Output is correct
25 Correct 52 ms 3516 KB Output is correct
26 Correct 53 ms 3296 KB Output is correct
27 Correct 64 ms 3584 KB Output is correct
28 Correct 64 ms 3608 KB Output is correct
29 Correct 53 ms 3560 KB Output is correct
30 Correct 60 ms 3440 KB Output is correct
31 Correct 65 ms 3712 KB Output is correct
32 Correct 67 ms 3716 KB Output is correct
33 Correct 56 ms 3548 KB Output is correct
34 Correct 60 ms 3432 KB Output is correct
35 Incorrect 68 ms 3696 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -