답안 #130968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130968 2019-07-16T10:25:48 Z semiauto CEOI16_icc (CEOI16_icc) C++14
61 / 100
220 ms 632 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
int i,j,k,sa,sb,l,r,m,x,q,alo,balo;
int parent[101],mas[101],a[101],b[101];
bool fix[101],go[101][101];
int n;/*
bool query(int a,int b,int *A,int *B) {
    int i,j;
    for (i=0;i<a;i++)
        for (j=0;j<b;j++)
            if (go[A[i]][B[j]])
                return true;
    return false;
}
void setRoad(int a,int b) {
    cout<<a<<" "<<b<<endl;
    cin>>alo>>balo;
    go[alo][balo]=go[balo][alo]=1;
}*/
void run(int n) {
    srand(time(NULL));
    for (i=1;i<=n;i++)
        parent[i]=i;
    for (j=1;j<n;j++) {
        for (i=1;i<=n;i++)
            fix[i]=0;
        for (i=1;i<=n;i++)
            fix[parent[i]]=1;
        k=0;
        for (i=1;i<=n;i++)
            if (fix[i])
                mas[k++]=i;q=0;
        while (true) {
            for (i=0;i<k;i++)
                fix[mas[i]]=rand()%2;
            sa=sb=0;
            for (i=0;i<=n;i++)
                a[i]=b[i]=0;
            for (i=1;i<=n;i++) {
                if (fix[parent[i]])
                    a[sa++]=i;
                else
                    b[sb++]=i;
            }q++;
            if (query(sa,sb,a,b))
                break;
        }
       // cout<<q<<endl;
        l=1;r=sa;
        while (l!=r) {
            m=(l+r)/2;
            for (i=0;i<=n;i++)
                mas[i]=0;
            for (i=l;i<=m;i++)
                mas[i-l]=a[i-1];
            if (query(m-l+1,sb,mas,b))
                r=m;
            else
                l=m+1;
        }
        x=l;
        l=1;r=sb;
        while (l!=r) {
            m=(l+r)/2;
            for (i=0;i<=n;i++)
                mas[i]=0;
            for (i=l;i<=m;i++)
                mas[i-l]=b[i-1];
            if (query(sa,m-l+1,a,mas))
                r=m;
            else
                l=m+1;
        }
        int solo=parent[a[x-1]];
        for (i=1;i<=n;i++)
            if (parent[i]==solo)
                parent[i]=parent[b[l-1]];
        setRoad(b[l-1],a[x-1]);
    }
    return;
}/*
int main() {
    cin>>n;
    cin>>alo>>balo;
    go[alo][balo]=go[balo][alo]=1;
    run(n);
    return 0;
}*/

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:32:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
             if (fix[i])
             ^~
icc.cpp:33:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
                 mas[k++]=i;q=0;
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 504 KB Ok! 102 queries used.
2 Correct 10 ms 504 KB Ok! 119 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 632 KB Ok! 543 queries used.
2 Correct 66 ms 504 KB Ok! 843 queries used.
3 Correct 64 ms 504 KB Ok! 829 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 560 KB Ok! 1563 queries used.
2 Correct 220 ms 608 KB Ok! 2087 queries used.
3 Correct 166 ms 508 KB Ok! 1671 queries used.
4 Correct 177 ms 504 KB Ok! 1724 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 167 ms 504 KB Ok! 1664 queries used.
2 Correct 170 ms 560 KB Ok! 1682 queries used.
3 Correct 190 ms 556 KB Ok! 1837 queries used.
4 Correct 160 ms 560 KB Ok! 1594 queries used.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 190 ms 504 KB Too many queries! 1868 out of 1775
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 201 ms 564 KB Too many queries! 1917 out of 1625
2 Halted 0 ms 0 KB -