Submission #527840

# Submission time Handle Problem Language Result Execution time Memory
527840 2022-02-18T13:31:39 Z definitelynotmee Xoractive (IZhO19_xoractive) C++17
0 / 100
2 ms 328 KB
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
using namespace std;
template <typename T>
using matrix = vector<vector<T>>;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const double EPS = 1e-7;
const int MOD = 1e9 + 7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
const int MAXN = 1e6+1;
#include "interactive.h"

/*vector<int> arr;

int ask(int i){
  cout << "ask " << i << endl;
  int in;
  cin >> in;
  return in;
}
vector<int> get_pairwise_xor(vector<int> q){
  /*cout << "get_pairwise_xor ";
  for(int i : q)
    cout << i << ' ';
  cout << endl;
  vector<int> ret;
  for(int i = 0; i < q.size(); i++){
    for(int j = i; j < q.size(); j++){
      ret.push_back(arr[q[i]-1]^arr[q[j]-1]);
    }
  }
  sort(all(ret));
  return ret;
}*/
int ask(int i);
vector<int> get_pairwise_xor(vector<int> q);
vector<int> guess(int n) {

        int last = ask(n);

        auto getset =[&](vector<int> q)->vector<int>{
          cout << "getset ";
          for(int i : q)
            cout << i << ' ';
          cout << '\n';
          q.push_back(n);
          vector<int> tot = get_pairwise_xor(q);
          q.pop_back();
          vector<int> totminus = get_pairwise_xor(q);

          vector<int> v(q.size());
          cout << "tot: ";
          for(int i : tot)
            cout << i << ' ';
          cout << '\n';
          cout << "totminus: ";
          for(int i : totminus)
            cout << i << ' ';
          cout << endl;
          int p1 = 0, p2 = 0;
          int ptr = 0;
          while(p1 < tot.size()){
            cout << "p1 = " << p1 << "(" << tot[p1] <<"), p2 = " << p2 << "(" << totminus[p2] << ");\n";
            if(p2 == totminus.size() || totminus[p2] != tot[p1]){
              if(tot[p1] != 0){
                v[ptr] = tot[p1]^last;
                ptr++;
                p1++;
              }

            } else  p2++;
            p1++;
          }

          cout << "-> ";
          for(int i : v)
            cout << i << ' ';
          cout << endl;
          assert(ptr == q.size());
          /*cout << "getset ";
          for(int i : q)
            cout << i << ' ';
          cout << "\n-> ";
          for(int i : v)
            cout << i << ' ';
          cout << endl;*/
          return v;
        };

        cout << 1 << endl;

        vector<int> q(n-1);
        iota(all(q),1);


        matrix<int> group = {getset(q)};

        cout << 2 << endl;
        int timer = 3;
        while(group.size() < n-1){
          cout << timer++ << endl;
          matrix<int> newgroup;
          vector<int> q;
          int ct = 1;
          for(vector<int>& i : group){
            for(int j = 0; j < (i.size()+1)/2; j++)
              q.push_back(ct), ct++;
            ct+=i.size()-(i.size()+1)/2;
          }
          vector<int> r = getset(q);
          set<int> s(all(r));

          for(vector<int>& i : group){
            vector<int> g1, g2;
            for(int j : i){
              if(s.count(j))
                g1.push_back(j);
              else g2.push_back(j);
            }
            if(g1.size())
              newgroup.push_back(g1);
            if(g2.size())
              newgroup.push_back(g2);
          }
          swap(group,newgroup);
        }
        vector<int> resp;
        for(int i = 0 ; i < group.size(); i++){
          /*cout << i << ":\n";
          for(int j : group[i])
            cout << j << ' ';
          cout << '\n';*/
          assert(group[i].size());
          resp.push_back(group[i].back());
        }
        resp.push_back(last);
        for(int i : resp)
          cout << i << ' ';
        cout << endl;
        return resp;

}
/*
int main(){
  int n;
  cin >> n;
  arr = vector<int>(n);
  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  vector<int> resp = guess(n);
  cout << "! ";
  for(int i : resp)
    cout << i << ' ';
  cout << '\n';
}
*/

Compilation message

Xoractive.cpp:32:3: warning: "/*" within comment [-Wcomment]
   32 |   /*cout << "get_pairwise_xor ";
      |    
Xoractive.cpp: In lambda function:
Xoractive.cpp:72:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |           while(p1 < tot.size()){
      |                 ~~~^~~~~~~~~~~~
Xoractive.cpp:74:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |             if(p2 == totminus.size() || totminus[p2] != tot[p1]){
      |                ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from Xoractive.cpp:1:
Xoractive.cpp:89:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |           assert(ptr == q.size());
      |                  ~~~~^~~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:110:28: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  110 |         while(group.size() < n-1){
      |               ~~~~~~~~~~~~~^~~~~
Xoractive.cpp:116:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  116 |             for(int j = 0; j < (i.size()+1)/2; j++)
      |                            ~~^~~~~~~~~~~~~~~~
Xoractive.cpp:138:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  138 |         for(int i = 0 ; i < group.size(); i++){
      |                         ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Failed 0 ms 200 KB do not print anything to standard output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 328 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -