답안 #958071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958071 2024-04-04T20:33:39 Z I_am_Polish_Girl Xoractive (IZhO19_xoractive) C++14
컴파일 오류
0 ms 0 KB
//#include "interactive.h"

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <cmath>
#include <random>
#include <chrono>

using namespace std;

//#define int long long

int log_ = 10;
int inf = 1000000000000000000;
int mod = 998244353;




vector <int> a;

int ask(int position)
{
    position--;

    return a[position];
}


vector<int> get_pairwise_xor(vector<int> positions)
{
    vector <int> ans;

    for (int i = 0; i < positions.size(); i++)
    {
        for (int j = 0; j < positions.size(); j++)
        {
            ans.push_back(a[positions[i] - 1] ^ a[positions[j] - 1]);
        }
    }

    sort(ans.begin(), ans.end());

    return ans;
}

vector<int> guess(int n)
{
    vector <int> ans(n);

    if (n < 15)
    {
        for (int i = 0 ; i < n ; i++)
        {
            ans[i] = ask(i);
        }


        return ans;
    }
    ans[0] = ask(1);

    map <int, int> nums_;

    for (int i = 0; i <= 6; i++)
    {
        vector <int> ind;


        for (int j = 1; j < n; j++)
        {
            if ((j & (1 << i)) != 0)
            {
                ind.push_back(j+1);
            }
        }

        vector <int> ans1 = get_pairwise_xor(ind);
        ind.push_back(1);

        vector <int> ans2 = get_pairwise_xor(ind);

        map <int, int> nums;

        for (int i = 0; i < ans2.size(); i++)
        {
            nums[ans2[i]]++;
        }

        for (int i = 0; i < ans1.size(); i++)
        {
            nums[ans1[i]]--;
        }


        for (auto i_ : nums)
        {
            if (i_.second != 0)
            {
                nums_[i_.first ^ ans[0]] += (1 << i);
            }
        }
    }



    for (int i = 1; i < n; i++)
    {
        for (auto j : nums_)
        {
            if (j.second == i)
                ans[i] = j.first;
        }
    }


    return ans;
};



signed main()
{
    ios_base::sync_with_stdio();
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    a.resize(n);


    for (int i = 0; i < n; i++)
        cin >> a[i];


    vector <int> ans = guess(n);


    for (int i = 0; i < n; i++)
        cout << ans[i] << " ";
}

Compilation message

Xoractive.cpp:21:11: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   21 | int inf = 1000000000000000000;
      |           ^~~~~~~~~~~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> get_pairwise_xor(std::vector<int>)':
Xoractive.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 0; i < positions.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~~~~
Xoractive.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int j = 0; j < positions.size(); j++)
      |                         ~~^~~~~~~~~~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:92:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |         for (int i = 0; i < ans2.size(); i++)
      |                         ~~^~~~~~~~~~~~~
Xoractive.cpp:97:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |         for (int i = 0; i < ans1.size(); i++)
      |                         ~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccqBKSHa.o: in function `ask(int)':
grader.cpp:(.text+0x470): multiple definition of `ask(int)'; /tmp/cc4iJEJd.o:Xoractive.cpp:(.text+0x550): first defined here
/usr/bin/ld: /tmp/ccqBKSHa.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc4iJEJd.o:Xoractive.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccqBKSHa.o: in function `get_pairwise_xor(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x4d0): multiple definition of `get_pairwise_xor(std::vector<int, std::allocator<int> >)'; /tmp/cc4iJEJd.o:Xoractive.cpp:(.text+0x570): first defined here
collect2: error: ld returned 1 exit status