답안 #1040763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1040763 2024-08-01T09:01:58 Z 비요뜨(#11041) How to Avoid Disqualification in 75 Easy Steps (CEOI23_avoid) C++17
10 / 100
1 ms 484 KB
/*#include "avoid.h"
#include <bits/stdc++.h>
using namespace std;

int ind[10][10];
int save[10];
int p[20];

int find(int a) {
    return p[a]<0?a:p[a]=find(p[a]);
}

void merge(int a,int b) {
    a=find(a);
    b=find(b);
    if (a==b) {
        return;
    }
    p[b]=a;
}

std::pair<int, int> scout(int R, int H) {
    vector<int> v[75];
    for(int i=0;i<10;i++) {
        for(int j=1;j<=1000;j++) {
            if (j&(1<<i)) {
                v[i].push_back(j);
            }
            else {
                v[10+i].push_back(j);
            }
        }
    }
    int cnt=20;
    for(int i=0;i<10;i++) {
        for(int j=i+1;j<10;j++) {
            for(int k=1;k<=1000;k++) {
                if ((k&(1<<i))&&(k&(1<<j))) {
                    v[cnt].push_back(k);
                }
            }
            ind[i][j]=cnt++;
        }
    }
    for(int i=0;i<cnt;i++) {
        send(v[i]);
    }
memset(p,-1,sizeof(p));
    vector<int> got=wait();
    for(int i=0;i<10;i++) {
        if (got[i]==0&&got[10+i]==1) {
            save[i]=0;
        }
        else if (got[i]==1&&got[10+i]==0) {
            save[i]=1;
        }
        else {
            save[i]=-1;
        }
    }
    for(int i=0;i<10;i++) {
        for(int j=i+1;j<10;j++) {
            if (save[i]==-1&&save[j]==-1) {
                if (got[ind[i][j]]==1) {
                    merge(i,j);
                    merge(10+i,10+j);
                }
                else {
                    merge(i,10+j);
                    merge(10+i,j);
                }
            }
        }
    }
    int one=0;
    int two=0;
    int st=-1;
    for(int i=9;i>=0;i--) {
        if (save[i]==-1) {
            st=i;
        }
        else {
            one+=(save[i]<<i);
            two+=(save[i]<<i);
        }
    }
if (st!=-1)
    two+=(1<<st);
    for(int i=0;i<10;i++) {
        if (save[i]==-1&&i!=st) {
            if (find(i)==find(st)) {
                two+=(1<<i);
            }
            else {
                one+=(1<<i);
            }
        }
    }
    return pair<int,int>(one,two);
}*/
#include "avoid.h"
#include <bits/stdc++.h>
using namespace std;

int ind[10][10];
int save[10];
int p[20];
typedef pair<int,int> P;

int find(int a) {
    return p[a]<0?a:p[a]=find(p[a]);
}

void merge(int a,int b) {
    a=find(a);
    b=find(b);
    if (a==b) {
        return;
    }
    p[b]=a;
}

std::pair<int, int> scout(int R, int H) {
    vector<int> v[75];
    for(int i=0;i<10;i++) {
        for(int j=1;j<=1000;j++) {
            if (j&(1<<i)) {
                v[i].push_back(j);
            }
            else {
                v[10+i].push_back(j);
            }
        }
    }
    int cnt=20;
    for(int i=0;i<cnt;i++) {
        send(v[i]);
    }
memset(p,-1,sizeof(p));
    vector<int> got=wait();
    int pl=0;
    for(int i=0;i<10;i++) {
        if (got[i]==0&&got[10+i]==1) {
            save[i]=0;
        }
        else if (got[i]==1&&got[10+i]==0) {
            save[i]=1;
        }
        else {
            save[i]=-1;
            pl+=(1<<i);
        }
    }
    int one=0;
    int two=0;
    int st=-1;
    for(int i=9;i>=0;i--) {
        if (save[i]==-1) {
            st=i;
        }
        else {
            one+=(save[i]<<i);
            two+=(save[i]<<i);
        }
    }
    if (st==-1) {
        return P(one,two);
    }
    one+=(1<<st);
    cnt=0;
    int ind[10];
    for(int i=0;i<10;i++) {
        if (i==st||save[i]!=-1) {
            continue;
        }
        v[cnt].clear();
        for(int j=1;j<=1000;j++) {
            if (j&(1<<st)) {
                if (j&(1<<i)) {
                    v[cnt].push_back(j);
                }
            }
        }
        send(v[cnt]);
        ind[cnt]=i;
        cnt++;
    }
    vector<int> gott=wait();
    for(int i=0;i<cnt;i++) {
        if (gott[i]==1) {
            one+=(1<<ind[i]);
        }
        else {
            two+=(1<<ind[i]);
        }
    }
    return pair<int,int>(one,two);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
2 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
3 Correct 0 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
4 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
5 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
6 Correct 1 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
7 Correct 0 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
8 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
9 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
10 Correct 0 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
11 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
12 Correct 1 ms 344 KB Correct: 26 robot(s) used, 2 hour(s) passed
13 Correct 1 ms 344 KB Correct: 26 robot(s) used, 2 hour(s) passed
14 Correct 1 ms 344 KB Correct: 26 robot(s) used, 2 hour(s) passed
15 Correct 1 ms 344 KB Correct: 20 robot(s) used, 2 hour(s) passed
16 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
17 Correct 1 ms 344 KB Correct: 25 robot(s) used, 2 hour(s) passed
18 Correct 0 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
19 Correct 1 ms 344 KB Correct: 20 robot(s) used, 2 hour(s) passed
20 Correct 0 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
21 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
22 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
23 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
24 Correct 0 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
25 Correct 0 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
26 Correct 0 ms 344 KB Correct: 20 robot(s) used, 2 hour(s) passed
27 Correct 1 ms 484 KB Correct: 23 robot(s) used, 2 hour(s) passed
28 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
29 Correct 1 ms 344 KB Correct: 20 robot(s) used, 2 hour(s) passed
30 Correct 0 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
31 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
32 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
33 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
34 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
35 Correct 0 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
36 Correct 1 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
37 Correct 1 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
38 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
39 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
40 Correct 0 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
41 Correct 1 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
42 Correct 0 ms 344 KB Correct: 20 robot(s) used, 2 hour(s) passed
43 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
44 Correct 0 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
45 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
46 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
47 Correct 0 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
48 Correct 0 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
49 Correct 0 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
50 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
51 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
52 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
53 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
54 Correct 1 ms 344 KB Correct: 25 robot(s) used, 2 hour(s) passed
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Not correct
2 Halted 0 ms 0 KB -