Submission #1096816

# Submission time Handle Problem Language Result Execution time Memory
1096816 2024-10-05T07:53:13 Z KasymK Xoractive (IZhO19_xoractive) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
// #include "interactive.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int> my;

int ask(int pos){
    return my[pos-1];
}

vector<int> get_pairwise_xor(vector<int> &ber){
    vector<int> qry;
    int n = (int)ber.size();
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            qry.pb(my[ber[i]-1]^my[ber[j]-1]);
    sort(all(qry));
    return qry;
}

vector<int> guess(int n){
    vector<int> answer;
    for(int ad = 1; ad <= n; ++ad){
        vector<int> A;
        int ad2;
        for(ad2 = ad; ad2 <= ad+3; ++ad2)
            A.pb(ad2);
        int a = ask(ad);
        ad = ad2;
        A = get_pairwise_xor(A);
        for(int i : A)
            printf("%d ", i);
        puts("");
        wr;
        assert((int)A.size() == 16);
        vector<int> check, same;
        for(int mk = 0; mk < (1<<16); ++mk){
            int cnt = __builtin_popcount(mk);
            if(cnt != 4)
                continue;
            for(int i = 0; i < 16; ++i)
                if(mk>>i&1)
                    check.pb(A[i]);
            assert((int)check.size() == 4);
            vector<int> green, check2 = check;
            green.pb(0), green.pb(2), green.pb(4), green.pb(7);
            for(int i = 0; i < 4; ++i){
                int x = a^check[i];
                check[i] = x;
            }
            if(check2 == green){
                puts("men barde."   );
                for(int i : check)
                    printf("%d ", i);
                puts("");
                wr;
            }
            for(int i = 0; i < 4; ++i)
                for(int j = 0; j < 4; ++j)
                    same.pb(check[i]^check[j]);
            assert((int)same.size() == 16);
            if(same == A){
                for(int i = 0; i < 4; ++i)
                    answer.pb(check[i]);
                break;
            }
            same.clear(), check.clear();
        }
    }
    return answer;
}

int main(){
    freopen("file.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        int x;
        scanf("%d", &x);
        my.pb(x);
    }
    vector<int> solve = guess(n);
    if(solve == my)
        puts("Dogry");
    else
        puts("Yalnysh");
    return 0;
}

Compilation message

Xoractive.cpp: In function 'int main()':
Xoractive.cpp:85:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |     freopen("file.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Xoractive.cpp:87:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Xoractive.cpp:90:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   90 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccau7XCb.o: in function `ask(int)':
grader.cpp:(.text+0x470): multiple definition of `ask(int)'; /tmp/cckOmHDe.o:Xoractive.cpp:(.text+0x380): first defined here
/usr/bin/ld: /tmp/ccau7XCb.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cckOmHDe.o:Xoractive.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status