답안 #154984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154984 2019-09-25T19:24:28 Z Pankin Xoractive (IZhO19_xoractive) C++14
컴파일 오류
0 ms 0 KB
#include "interactive.h"
using namespace std;

vector<int> a;

set<int> getMn(set<int> ind) {
    vector<int> pos;
    for (auto i = ind.begin(); i != ind.end(); i++)
        pos.pb(*i);
    pos.pb(1);
    vector<int> px1 = get_pairwise_xor(pos);
    pos.pop_back();
    vector<int> px2 = get_pairwise_xor(pos);
    set<int> ans;
    multiset<int> temp;
    for (int i = 0; i < px1.size(); i++)
        temp.insert(px1[i]);
    for (int i = 0; i < px2.size(); i++)
        temp.erase(temp.find(px2[i]));
    for (auto i = temp.begin(); i != temp.end(); i++)
        ans.insert(*i ^ a[1]);
    ans.erase(a[1]);
    return ans;
}

vector<int> guess(int n) {
    a.resize(n + 1);
	set<int> all;
    a[1] = ask(1);
    vector< vector< set<int> > > mn(7, vector< set<int> >(2)), ind(7, vector< set<int> >(2));
    for (int i = 2; i <= n; i++) {
        for (int j = 6; j >= 0; j--) {
            ind[j][(i>>j)%2].pb(i);
        }
    }
    for (int j = 6; j >= 0; j--) {
        mn[j][1] = getMn(ind[j][1]);
        for (auto i = mn[j][1].begin(); i != mn[j][1].end(); i++)
            all.insert(*i);
    }

    for (int j = 6; j >= 0; j--) {
        mn[j][0] = all;
        for (auto i = mn[j][1].begin(); i != mn[j][1].end(); i++)
            mn[j][0].erase(*i);
    }

    for (int i = 2; i <= n; i++) {
        set<int> cur = all;
        for (int j = 6; j >= 0; j--) {
            for (auto it = all.begin(); it != all.end(); it++) {
                if (mn[j][(i>>j)%2].find(*it) == mn[j][(i>>j)%2].end())
                    cur.erase(*it);
            }
        }
        a[i] = *cur.begin();
    }
    a.erase(a.begin());
    return a;
}

Compilation message

Xoractive.cpp:6:1: error: 'set' does not name a type
 set<int> getMn(set<int> ind) {
 ^~~
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:28:2: error: 'set' was not declared in this scope
  set<int> all;
  ^~~
Xoractive.cpp:28:6: error: expected primary-expression before 'int'
  set<int> all;
      ^~~
Xoractive.cpp:30:28: error: template argument 1 is invalid
     vector< vector< set<int> > > mn(7, vector< set<int> >(2)), ind(7, vector< set<int> >(2));
                            ^
Xoractive.cpp:30:28: error: template argument 2 is invalid
Xoractive.cpp:30:30: error: template argument 1 is invalid
     vector< vector< set<int> > > mn(7, vector< set<int> >(2)), ind(7, vector< set<int> >(2));
                              ^
Xoractive.cpp:30:30: error: template argument 2 is invalid
Xoractive.cpp:30:32: error: expected unqualified-id before '>' token
     vector< vector< set<int> > > mn(7, vector< set<int> >(2)), ind(7, vector< set<int> >(2));
                                ^
Xoractive.cpp:33:13: error: 'ind' was not declared in this scope
             ind[j][(i>>j)%2].pb(i);
             ^~~
Xoractive.cpp:33:13: note: suggested alternative: 'int'
             ind[j][(i>>j)%2].pb(i);
             ^~~
             int
Xoractive.cpp:37:9: error: 'mn' was not declared in this scope
         mn[j][1] = getMn(ind[j][1]);
         ^~
Xoractive.cpp:37:9: note: suggested alternative: 'n'
         mn[j][1] = getMn(ind[j][1]);
         ^~
         n
Xoractive.cpp:37:26: error: 'ind' was not declared in this scope
         mn[j][1] = getMn(ind[j][1]);
                          ^~~
Xoractive.cpp:37:26: note: suggested alternative: 'int'
         mn[j][1] = getMn(ind[j][1]);
                          ^~~
                          int
Xoractive.cpp:37:20: error: 'getMn' was not declared in this scope
         mn[j][1] = getMn(ind[j][1]);
                    ^~~~~
Xoractive.cpp:39:13: error: 'all' was not declared in this scope
             all.insert(*i);
             ^~~
Xoractive.cpp:43:9: error: 'mn' was not declared in this scope
         mn[j][0] = all;
         ^~
Xoractive.cpp:43:9: note: suggested alternative: 'n'
         mn[j][0] = all;
         ^~
         n
Xoractive.cpp:43:20: error: 'all' was not declared in this scope
         mn[j][0] = all;
                    ^~~
Xoractive.cpp:49:13: error: expected primary-expression before 'int'
         set<int> cur = all;
             ^~~
Xoractive.cpp:51:28: error: 'all' was not declared in this scope
             for (auto it = all.begin(); it != all.end(); it++) {
                            ^~~
Xoractive.cpp:52:21: error: 'mn' was not declared in this scope
                 if (mn[j][(i>>j)%2].find(*it) == mn[j][(i>>j)%2].end())
                     ^~
Xoractive.cpp:52:21: note: suggested alternative: 'n'
                 if (mn[j][(i>>j)%2].find(*it) == mn[j][(i>>j)%2].end())
                     ^~
                     n
Xoractive.cpp:53:21: error: 'cur' was not declared in this scope
                     cur.erase(*it);
                     ^~~
Xoractive.cpp:53:21: note: suggested alternative: 'char'
                     cur.erase(*it);
                     ^~~
                     char
Xoractive.cpp:56:17: error: 'cur' was not declared in this scope
         a[i] = *cur.begin();
                 ^~~
Xoractive.cpp:56:17: note: suggested alternative: 'char'
         a[i] = *cur.begin();
                 ^~~
                 char