답안 #1086070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086070 2024-09-09T13:02:57 Z vjudge1 사육제 (CEOI14_carnival) C++17
20 / 100
32 ms 600 KB
#include <bits/stdc++.h>

using namespace std;
int tip[200];
int gazda[200];
int n;

int prasaj(int l,int r)
{
    cout<<r-l+1<<" ";
    for (int i=l;i<=r;i++) cout<<i<<" ";
    cout<<endl;
    int x;
    cin>>x;
    return x;
}

void najdi(int l,int r,int raz)
{
    vector<int> grupa1,grupa2;
    int mid = (l+r)/2;
    bool vnatre[200];
    memset(vnatre,0,sizeof(vnatre));
    for (int i=l;i<=mid;i++)
    {
        int x = tip[i];
        if (vnatre[x]==false)
        {
            vnatre[x]=true;
            grupa1.push_back(i);
        }
    }
    for (int i=mid+1;i<=r;i++)
    {
        int x = tip[i];
        if (vnatre[x]==false)
        {
            vnatre[x]=true;
            grupa2.push_back(i);
        }
    }

    bool visited[200];
    memset(visited,0,sizeof(visited));
    int spojki = 0;
    for (int i=0;i<grupa1.size();i++)
    {
        for (int j=0;j<grupa2.size();j++)
        {
            int a=grupa1[i],b=grupa2[j];
            if (visited[a] || visited[b]) continue;
            cout<<"2 "<<a<<" "<<b<<endl;
            int x;
            cin>>x;
            if (x==1)
            {
                spojki++;
                visited[a]=true;
                visited[b]=true;
                int z = tip[b];
                for (int q=1;q<=n;q++)
                {
                    if (tip[q]==z) tip[q]=tip[a];
                }
                if (spojki==raz) return;
            }
        }
    }
}

int bs(int l,int r)
{
    if (l==r) return 1;
    int mid = (l+r)/2;
    int y = prasaj(l,r);
    if (y==1)
    {
        for (int i=l;i<=r;i++) tip[i]=tip[l];
    }
    else if (y==r-l+1) return y;

    int x = bs(l,mid) + bs(mid+1,r);
    if (x!=y) najdi(l,r,x-y);

    return y;
}

int stepen()
{
    int x=1;
    while(x<n) x*=2;
    return x;
}

int main()
{
    cin>>n;
    for (int i=1;i<=n;i++) tip[i]=i;
    bs(1,n);

    map<int,int> pr;
    int p = 1;
    for (int i=1;i<=n;i++)
    {
        int x = tip[i];
        if (pr[x]==0)
        {
            pr[x]=p;
            p++;
        }
    }

    cout<<0<<" ";
    for (int i=1;i<=n;i++) cout<<pr[tip[i]]<<" ";
    cout<<endl;

    return 0;
}

Compilation message

carnival.cpp: In function 'void najdi(int, int, int)':
carnival.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i=0;i<grupa1.size();i++)
      |                  ~^~~~~~~~~~~~~~
carnival.cpp:48:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int j=0;j<grupa2.size();j++)
      |                      ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 7 ms 344 KB Output is correct
3 Partially correct 24 ms 428 KB Partially correct
4 Partially correct 19 ms 444 KB Partially correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 7 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 11 ms 344 KB Output is correct
3 Correct 13 ms 592 KB Output is correct
4 Partially correct 25 ms 344 KB Partially correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 13 ms 344 KB Output is correct
4 Partially correct 14 ms 344 KB Partially correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 8 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Partially correct 24 ms 444 KB Partially correct
4 Partially correct 28 ms 432 KB Partially correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 3 ms 436 KB Output is correct
7 Correct 8 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Partially correct 20 ms 420 KB Partially correct
4 Partially correct 27 ms 428 KB Partially correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 3 ms 436 KB Output is correct
7 Partially correct 32 ms 592 KB Partially correct