Submission #231067

# Submission time Handle Problem Language Result Execution time Memory
231067 2020-05-12T14:41:12 Z nicolaalexandra ICC (CEOI16_icc) C++14
0 / 100
5 ms 416 KB
#include <bits/stdc++.h>
#include "icc.h"
#define DIM 200
using namespace std;
vector <int> L[DIM],comp[DIM],w;
int n,i,x,y,k,k2,el;
int v[DIM],t[DIM],aux[DIM],a[DIM],b[DIM];

/*int query (int n, int m, int a[], int b[]){
    int ans;
    cout<<n<<" ";
    for (int i=0;i<n;i++)
        cout<<a[i]<<" ";
    cout<<endl;
    cout<<m<<" ";
    for (int i=0;i<m;i++)
        cout<<b[i]<<" ";
    cout<<endl;
    cin>>ans;
    return ans;
}
void setRoad (int x, int y){
    cout<<x<<" "<<y<<endl;
}
*/


void _union (int x, int y){
    if (t[x] > t[y])
        swap (x,y);
    for (int i=1;i<=n;i++){
        if (i != y && t[i] == t[y])
            t[i] = t[x];
        else {
            if (t[i] > t[y])
                t[i]--;
        }
    }
    t[y] = t[x];
}

void solve (){
    /// impart componentele conexe in doua multimi

    for (int bit=0;bit<8;bit++){
        k = 0, k2 = 0;

        for (int i=1;i<=n;i++){
            int val = t[i];
            if (val&(1<<bit))
                a[k++] = i;
            else b[k2++] = i;
        }

        if (!k || !k2)
            continue;

        if (query(k,k2,a,b)){ /// am gasit cele doua multimi

            int val = k;
            while (val > 1){
                int mid = val/2;

                if (query(mid,k2,a,b))
                    val = mid;
                else {
                    for (int i=mid;i<val;i++)
                        a[i-mid] = a[i];
                    val -= mid;
                }
            }
            x = a[0], k = 1;

            val = k2;
            while (val > 1){
                int mid = val/2;

                if (query(k,mid,a,b))
                    val = mid;
                else {
                    for (int i=mid;i<val;i++)
                        b[i-mid] = b[i];
                    val -= mid;
                }
            }
            y = b[0], k2 = 1;

            _union (x,y);
            setRoad(x,y);
            break;
        }
    }
}
void run (int n){
    for (int i=1;i<=n;i++)
        t[i] = i;
    for (int i=1;i<n;i++)
        solve();
}


# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Not all edges were guessed!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Not all edges were guessed!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Not all edges were guessed!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Not all edges were guessed!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Not all edges were guessed!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 416 KB Not all edges were guessed!
2 Halted 0 ms 0 KB -