답안 #681587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681587 2023-01-13T12:12:35 Z Karuk Xoractive (IZhO19_xoractive) C++14
컴파일 오류
0 ms 0 KB
#include "interactive.h"
using namespace std;
vector<int>sub(vector<int>a,vector<int>b) {
    map<int,int>m;
    for(int i:a)m[i]++;
    for(int j:b)m[j]--;
    vector<int>ans;
    for(pair<int,int>p:m) {
        for(int i=0;i<p.second;i++)ans.push_back(p.first);
    }
    return ans;
}
vector<int> guess(int n) {
    map<int,int>m;
    vector<int>nums;
    int x;
    x=ask(1);
    for(int i=6;i>=0;i--) {
        vector<int>askk;
        for(int j=2;j<=n;j++) {
            if(j&(1<<i))askk.push_back(j);
        }
        if(askk.size()==0)continue;
        vector<int>first=get_pairwise_xor(askk);
        askk.push_back(1);
        vector<int>second=get_pairwise_xor(askk);
        second=sub(second,first);
        for(int j=0;j<second.size();j++) {
            second[j]^=x;
            m[x]|=(1<<i);
        }
    }
    int anss[n+1];
    for(pair<int,int>p:m) {
        anss[p.second]=p.first;
    }
    anss[1]=x;
    vector<int>ans(n);
    for(int i=0;i<n;i++)ans[i]=anss[i+1];
    return ans;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> sub(std::vector<int>, std::vector<int>)':
Xoractive.cpp:4:5: error: 'map' was not declared in this scope
    4 |     map<int,int>m;
      |     ^~~
Xoractive.cpp:2:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
    1 | #include "interactive.h"
  +++ |+#include <map>
    2 | using namespace std;
Xoractive.cpp:4:9: error: expected primary-expression before 'int'
    4 |     map<int,int>m;
      |         ^~~
Xoractive.cpp:5:17: error: 'm' was not declared in this scope
    5 |     for(int i:a)m[i]++;
      |                 ^
Xoractive.cpp:6:17: error: 'm' was not declared in this scope
    6 |     for(int j:b)m[j]--;
      |                 ^
Xoractive.cpp:8:24: error: 'm' was not declared in this scope
    8 |     for(pair<int,int>p:m) {
      |                        ^
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:14:5: error: 'map' was not declared in this scope
   14 |     map<int,int>m;
      |     ^~~
Xoractive.cpp:14:5: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
Xoractive.cpp:14:9: error: expected primary-expression before 'int'
   14 |     map<int,int>m;
      |         ^~~
Xoractive.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int j=0;j<second.size();j++) {
      |                     ~^~~~~~~~~~~~~~
Xoractive.cpp:30:13: error: 'm' was not declared in this scope
   30 |             m[x]|=(1<<i);
      |             ^
Xoractive.cpp:34:24: error: 'm' was not declared in this scope
   34 |     for(pair<int,int>p:m) {
      |                        ^