답안 #907164

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
907164 2024-01-15T07:52:58 Z ibm2006 Minerals (JOI19_minerals) C++17
80 / 100
33 ms 5772 KB
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,perm[1100000],b[1100000];
vector<ll> v,u;
void dnc(vector<ll> v,vector<ll> u,ll z)
{
    //printf("(%lld %lld)\n",v.size(),u.size());
    ll i,m=v.size();
    ll mid=m/2,x,y;
    vector<ll> v1,v2,u1,u2;
    if(m==1)
    {
        perm[v[0]]=u[0];
        return;
    }
    /*if(m==2)
    {
        if(z==0)
    {for(i=0;i<mid;i++)
    {
        //printf("! %lld\n",v[i]);
        x=Query(v[i]);
        s++;
    }}
    else
    {
        for(i=mid;i<m;i++)
        {
            //printf("! %lld\n",v[i]);
            x=Query(v[i]);
            s--;
        }
    }
for(i=0;i<mid;i++)
    {
        v1.push_back(v[i]);
    }
    for(i=mid;i<m;i++)
    {
        v2.push_back(v[i]);
    }
    x=s-x;
    y=Query(u[0]);
        if(b[u[0]]==0)
        s++;
        else
            s--;
        b[u[0]]^=1;
        y=s-y;
        //printf("(%lld)\n",y);
        if(y!=x)
            {u1.push_back(u[0]);
            u2.push_back(u[1]);
            }
        else
            {u2.push_back(u[0]);
            u1.push_back(u[1]);
            }
        //    printf("! %lld\n",u[i]);
        x=y;
dnc(v2,u2,0);
    dnc(v1,u1,1);
    return;
    }*/
    if(z==0)
    {for(i=0;i<mid;i++)
    {
        //printf("! %lld\n",v[i]);
        x=Query(v[i]);
        s++;
    }}
    else
    {
        for(i=mid;i<m;i++)
        {
            //printf("! %lld\n",v[i]);
            x=Query(v[i]);
            s--;
        }
    }

    for(i=0;i<mid;i++)
    {
        v1.push_back(v[i]);
    }
    for(i=mid;i<m;i++)
    {
        v2.push_back(v[i]);
    }
    x=s-x;
    for(i=0;i<m;i++)
    {
        if(i==m-1)
        {
            if(u1.size()<mid)
            {
                u1.push_back(u[i]);
            }
            else
                u2.push_back(u[i]);
            continue;
        }
        //printf("! %lld\n",u[i]);
        y=Query(u[i]);
        if(b[u[i]]==0)
        s++;
        else
            s--;
        b[u[i]]^=1;
        y=s-y;
        //printf("(%lld)\n",y);
        if(y!=x)
            u1.push_back(u[i]);
        else
            u2.push_back(u[i]);
        //    printf("! %lld\n",u[i]);
        x=y;
    }
    dnc(v2,u2,0);
    dnc(v1,u1,1);
}
void f()
{
    ll i,x=0,y;
    for(i=1;i<=n*2;i++)
    {
        y=Query(i);
        s++;
        if(y>x)
        {
            v.push_back(i);
            x++;
            continue;
        }
        else
        {
            Query(i);
            s--;
            u.push_back(i);
            continue;
        }
    }
}
void Solve(ll N) {
   n=N;
   f();
   /*for(i=0;i<v.size();i++)
   {
       Query(v[i]);
   }*/
   dnc(v,u,1);
   for(i=1;i<=n*2;i++)
   {
       if(perm[i]==0)
        continue;
       Answer(i,perm[i]);
   }
}

Compilation message

minerals.cpp: In function 'void dnc(std::vector<int>, std::vector<int>, ll)':
minerals.cpp:97:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   97 |             if(u1.size()<mid)
      |                ~~~~~~~~~^~~~
minerals.cpp:92:6: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   92 |     x=s-x;
      |     ~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2648 KB Output is correct
3 Correct 3 ms 2648 KB Output is correct
4 Correct 7 ms 3016 KB Output is correct
5 Correct 11 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 3 ms 2648 KB Output is correct
8 Correct 7 ms 3016 KB Output is correct
9 Correct 11 ms 3416 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 8 ms 3340 KB Output is correct
12 Correct 11 ms 3672 KB Output is correct
13 Correct 14 ms 3868 KB Output is correct
14 Correct 10 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 3 ms 2648 KB Output is correct
8 Correct 7 ms 3016 KB Output is correct
9 Correct 11 ms 3416 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 8 ms 3340 KB Output is correct
12 Correct 11 ms 3672 KB Output is correct
13 Correct 14 ms 3868 KB Output is correct
14 Correct 10 ms 3412 KB Output is correct
15 Correct 32 ms 5464 KB Output is correct
16 Correct 30 ms 5352 KB Output is correct
17 Correct 24 ms 5604 KB Output is correct
18 Correct 24 ms 5344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 3 ms 2648 KB Output is correct
8 Correct 7 ms 3016 KB Output is correct
9 Correct 11 ms 3416 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 8 ms 3340 KB Output is correct
12 Correct 11 ms 3672 KB Output is correct
13 Correct 14 ms 3868 KB Output is correct
14 Correct 10 ms 3412 KB Output is correct
15 Correct 32 ms 5464 KB Output is correct
16 Correct 30 ms 5352 KB Output is correct
17 Correct 24 ms 5604 KB Output is correct
18 Correct 24 ms 5344 KB Output is correct
19 Correct 31 ms 5356 KB Output is correct
20 Correct 32 ms 5524 KB Output is correct
21 Correct 25 ms 5588 KB Output is correct
22 Correct 26 ms 5752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 3 ms 2648 KB Output is correct
8 Correct 7 ms 3016 KB Output is correct
9 Correct 11 ms 3416 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 8 ms 3340 KB Output is correct
12 Correct 11 ms 3672 KB Output is correct
13 Correct 14 ms 3868 KB Output is correct
14 Correct 10 ms 3412 KB Output is correct
15 Correct 32 ms 5464 KB Output is correct
16 Correct 30 ms 5352 KB Output is correct
17 Correct 24 ms 5604 KB Output is correct
18 Correct 24 ms 5344 KB Output is correct
19 Correct 31 ms 5356 KB Output is correct
20 Correct 32 ms 5524 KB Output is correct
21 Correct 25 ms 5588 KB Output is correct
22 Correct 26 ms 5752 KB Output is correct
23 Correct 31 ms 5516 KB Output is correct
24 Correct 31 ms 5464 KB Output is correct
25 Correct 26 ms 5772 KB Output is correct
26 Correct 26 ms 5388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 3 ms 2648 KB Output is correct
8 Correct 7 ms 3016 KB Output is correct
9 Correct 11 ms 3416 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 8 ms 3340 KB Output is correct
12 Correct 11 ms 3672 KB Output is correct
13 Correct 14 ms 3868 KB Output is correct
14 Correct 10 ms 3412 KB Output is correct
15 Correct 32 ms 5464 KB Output is correct
16 Correct 30 ms 5352 KB Output is correct
17 Correct 24 ms 5604 KB Output is correct
18 Correct 24 ms 5344 KB Output is correct
19 Correct 31 ms 5356 KB Output is correct
20 Correct 32 ms 5524 KB Output is correct
21 Correct 25 ms 5588 KB Output is correct
22 Correct 26 ms 5752 KB Output is correct
23 Correct 31 ms 5516 KB Output is correct
24 Correct 31 ms 5464 KB Output is correct
25 Correct 26 ms 5772 KB Output is correct
26 Correct 26 ms 5388 KB Output is correct
27 Incorrect 33 ms 5624 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 3 ms 2648 KB Output is correct
8 Correct 7 ms 3016 KB Output is correct
9 Correct 11 ms 3416 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 8 ms 3340 KB Output is correct
12 Correct 11 ms 3672 KB Output is correct
13 Correct 14 ms 3868 KB Output is correct
14 Correct 10 ms 3412 KB Output is correct
15 Correct 32 ms 5464 KB Output is correct
16 Correct 30 ms 5352 KB Output is correct
17 Correct 24 ms 5604 KB Output is correct
18 Correct 24 ms 5344 KB Output is correct
19 Correct 31 ms 5356 KB Output is correct
20 Correct 32 ms 5524 KB Output is correct
21 Correct 25 ms 5588 KB Output is correct
22 Correct 26 ms 5752 KB Output is correct
23 Correct 31 ms 5516 KB Output is correct
24 Correct 31 ms 5464 KB Output is correct
25 Correct 26 ms 5772 KB Output is correct
26 Correct 26 ms 5388 KB Output is correct
27 Incorrect 33 ms 5624 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 3 ms 2648 KB Output is correct
8 Correct 7 ms 3016 KB Output is correct
9 Correct 11 ms 3416 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 8 ms 3340 KB Output is correct
12 Correct 11 ms 3672 KB Output is correct
13 Correct 14 ms 3868 KB Output is correct
14 Correct 10 ms 3412 KB Output is correct
15 Correct 32 ms 5464 KB Output is correct
16 Correct 30 ms 5352 KB Output is correct
17 Correct 24 ms 5604 KB Output is correct
18 Correct 24 ms 5344 KB Output is correct
19 Correct 31 ms 5356 KB Output is correct
20 Correct 32 ms 5524 KB Output is correct
21 Correct 25 ms 5588 KB Output is correct
22 Correct 26 ms 5752 KB Output is correct
23 Correct 31 ms 5516 KB Output is correct
24 Correct 31 ms 5464 KB Output is correct
25 Correct 26 ms 5772 KB Output is correct
26 Correct 26 ms 5388 KB Output is correct
27 Incorrect 33 ms 5624 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -