Submission #527842

# Submission time Handle Problem Language Result Execution time Memory
527842 2022-02-18T13:35:54 Z definitelynotmee Xoractive (IZhO19_xoractive) C++17
88 / 100
5 ms 428 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++){
      |                         ~~^~~~~~~~~~~~~~
Xoractive.cpp:109:13: warning: unused variable 'timer' [-Wunused-variable]
  109 |         int timer = 3;
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 4 ms 328 KB Output is partially correct
2 Partially correct 3 ms 328 KB Output is partially correct
3 Partially correct 3 ms 328 KB Output is partially correct
4 Partially correct 4 ms 392 KB Output is partially correct
5 Partially correct 4 ms 328 KB Output is partially correct
6 Partially correct 4 ms 328 KB Output is partially correct
7 Partially correct 3 ms 328 KB Output is partially correct
8 Partially correct 4 ms 328 KB Output is partially correct
9 Partially correct 4 ms 328 KB Output is partially correct
10 Partially correct 3 ms 328 KB Output is partially correct
11 Partially correct 3 ms 328 KB Output is partially correct
12 Partially correct 4 ms 328 KB Output is partially correct
13 Partially correct 4 ms 328 KB Output is partially correct
14 Partially correct 4 ms 328 KB Output is partially correct
15 Partially correct 3 ms 328 KB Output is partially correct
16 Partially correct 4 ms 328 KB Output is partially correct
17 Partially correct 4 ms 328 KB Output is partially correct
18 Partially correct 4 ms 328 KB Output is partially correct
19 Partially correct 3 ms 328 KB Output is partially correct
20 Partially correct 4 ms 416 KB Output is partially correct
21 Partially correct 4 ms 328 KB Output is partially correct
22 Partially correct 4 ms 328 KB Output is partially correct
23 Partially correct 3 ms 328 KB Output is partially correct
24 Partially correct 4 ms 328 KB Output is partially correct
25 Partially correct 4 ms 328 KB Output is partially correct
26 Partially correct 4 ms 328 KB Output is partially correct
27 Partially correct 3 ms 328 KB Output is partially correct
28 Partially correct 4 ms 328 KB Output is partially correct
29 Partially correct 4 ms 328 KB Output is partially correct
30 Partially correct 3 ms 328 KB Output is partially correct
31 Partially correct 3 ms 328 KB Output is partially correct
32 Partially correct 4 ms 328 KB Output is partially correct
33 Partially correct 4 ms 328 KB Output is partially correct
34 Partially correct 5 ms 392 KB Output is partially correct
35 Partially correct 4 ms 328 KB Output is partially correct
36 Partially correct 4 ms 328 KB Output is partially correct
37 Partially correct 4 ms 328 KB Output is partially correct
38 Partially correct 4 ms 428 KB Output is partially correct
39 Partially correct 3 ms 328 KB Output is partially correct
40 Partially correct 4 ms 328 KB Output is partially correct
41 Partially correct 4 ms 328 KB Output is partially correct
42 Partially correct 4 ms 328 KB Output is partially correct
43 Partially correct 3 ms 328 KB Output is partially correct
44 Partially correct 4 ms 392 KB Output is partially correct
45 Partially correct 4 ms 328 KB Output is partially correct
46 Partially correct 4 ms 328 KB Output is partially correct
47 Partially correct 3 ms 328 KB Output is partially correct
48 Partially correct 4 ms 328 KB Output is partially correct
49 Partially correct 4 ms 328 KB Output is partially correct
50 Partially correct 4 ms 328 KB Output is partially correct
51 Partially correct 3 ms 328 KB Output is partially correct
52 Partially correct 4 ms 328 KB Output is partially correct
53 Partially correct 4 ms 328 KB Output is partially correct
54 Partially correct 5 ms 328 KB Output is partially correct
55 Partially correct 3 ms 396 KB Output is partially correct
56 Partially correct 4 ms 332 KB Output is partially correct
57 Partially correct 4 ms 404 KB Output is partially correct
58 Partially correct 4 ms 332 KB Output is partially correct
59 Partially correct 3 ms 328 KB Output is partially correct
60 Partially correct 4 ms 328 KB Output is partially correct
61 Partially correct 4 ms 328 KB Output is partially correct
62 Partially correct 4 ms 328 KB Output is partially correct
63 Partially correct 3 ms 332 KB Output is partially correct
64 Partially correct 5 ms 404 KB Output is partially correct
65 Partially correct 4 ms 416 KB Output is partially correct
66 Partially correct 3 ms 344 KB Output is partially correct
67 Partially correct 3 ms 392 KB Output is partially correct
68 Partially correct 4 ms 328 KB Output is partially correct
69 Partially correct 4 ms 344 KB Output is partially correct
70 Partially correct 4 ms 344 KB Output is partially correct
71 Partially correct 3 ms 344 KB Output is partially correct
72 Partially correct 3 ms 344 KB Output is partially correct
73 Partially correct 4 ms 408 KB Output is partially correct
74 Partially correct 4 ms 328 KB Output is partially correct
75 Partially correct 3 ms 328 KB Output is partially correct
76 Partially correct 4 ms 328 KB Output is partially correct
77 Partially correct 4 ms 328 KB Output is partially correct
78 Partially correct 4 ms 340 KB Output is partially correct
79 Partially correct 3 ms 408 KB Output is partially correct
80 Partially correct 4 ms 344 KB Output is partially correct
81 Partially correct 4 ms 344 KB Output is partially correct
82 Partially correct 4 ms 344 KB Output is partially correct
83 Partially correct 3 ms 344 KB Output is partially correct
84 Partially correct 4 ms 344 KB Output is partially correct
85 Partially correct 4 ms 344 KB Output is partially correct
86 Partially correct 4 ms 400 KB Output is partially correct
87 Partially correct 3 ms 336 KB Output is partially correct
88 Partially correct 4 ms 328 KB Output is partially correct
89 Partially correct 4 ms 328 KB Output is partially correct
90 Partially correct 4 ms 328 KB Output is partially correct
91 Partially correct 4 ms 328 KB Output is partially correct
92 Partially correct 4 ms 328 KB Output is partially correct
93 Partially correct 5 ms 392 KB Output is partially correct
94 Partially correct 5 ms 404 KB Output is partially correct
95 Partially correct 3 ms 328 KB Output is partially correct
96 Partially correct 4 ms 328 KB Output is partially correct
97 Partially correct 4 ms 328 KB Output is partially correct
98 Partially correct 4 ms 328 KB Output is partially correct
99 Partially correct 3 ms 328 KB Output is partially correct
100 Partially correct 4 ms 328 KB Output is partially correct