답안 #505153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
505153 2022-01-10T19:17:08 Z rainliofficial Xoractive (IZhO19_xoractive) Java 11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
//#include "interactive.h"
//#include "grader.cpp"
using namespace std;
#define ll long long
#define pii pair<int, int>
#define f first
#define s second

multiset<int> filter(vector<int>& all, vector<int>& exclude){
    multiset<int> allValues;
    for (int i : all){
        allValues.insert(i);
    }
    for (int i : exclude){
        if (allValues.find(i) != allValues.end()){
            allValues.erase(allValues.find(i));
        }
    }
    return allValues;
}
vector<int> guess(int n) {
	vector<int> ans(n);
	vector<int> allPositions(n);
    for (int i=0; i<n; i++){
        allPositions[i] = i+1;
    }
    vector<int> exludeFirst(n-1);
    for (int i=1; i<n; i++){
        exludeFirst[i-1] = i+1;
    }
    int first = ask(1);
    vector<int> allPairwiseXor = get_pairwise_xor(allPositions);
    vector<int> excludeFirstXor = get_pairwise_xor(exludeFirst);
    multiset<int> allValues = filter(allPairwiseXor, excludeFirstXor);
    vector<int> valToInd(n+1); // Maps an element to its answer index
    valToInd[first] = 1;
    // Look at answer indexes by bit
    int maxBits = log2(n)+1;
    for (int i=0; i<=maxBits; i++){  
        vector<int> currSet; // The set of numbers with this bit ON
        for (int j=2; j<=n; j++){
            if (j & (1<<i)){ // This bit is ON
                currSet.push_back(j);
            }
        }
        if (currSet.empty()){
            continue; 
        }
        vector<int> currSetXor = get_pairwise_xor(currSet);
        currSet.push_back(1);
        vector<int> xorWithFirst = get_pairwise_xor(currSet);
        multiset<int> currSetResult = filter(xorWithFirst, currSetXor);
        set<int> processed;
        for (int curr : currSetResult){
            if (curr == 0 || processed.find(curr) != processed.end()){
                continue;
            }
            processed.insert(curr);
            int val = curr ^ first; // Convert XOR value to orig value
            valToInd[val] += 1<<i; 
        }
    }
    for (int i=1; i<=n; i++){
        ans[valToInd[i]-1] = i;
    }
	return ans;
}

Compilation message

Xoractive.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Xoractive.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
Xoractive.java:5: error: illegal character: '#'
#define ll long long
^
Xoractive.java:5: error: class, interface, or enum expected
#define ll long long
        ^
Xoractive.java:6: error: illegal character: '#'
#define pii pair<int, int>
^
Xoractive.java:7: error: illegal character: '#'
#define f first
^
Xoractive.java:8: error: illegal character: '#'
#define s second
^
Xoractive.java:12: error: class, interface, or enum expected
    for (int i : all){
    ^
Xoractive.java:14: error: class, interface, or enum expected
    }
    ^
Xoractive.java:18: error: class, interface, or enum expected
        }
        ^
Xoractive.java:21: error: class, interface, or enum expected
}
^
Xoractive.java:24: error: class, interface, or enum expected
	vector<int> allPositions(n);
	^
Xoractive.java:25: error: class, interface, or enum expected
    for (int i=0; i<n; i++){
    ^
Xoractive.java:25: error: class, interface, or enum expected
    for (int i=0; i<n; i++){
                  ^
Xoractive.java:25: error: class, interface, or enum expected
    for (int i=0; i<n; i++){
                       ^
Xoractive.java:27: error: class, interface, or enum expected
    }
    ^
Xoractive.java:29: error: class, interface, or enum expected
    for (int i=1; i<n; i++){
    ^
Xoractive.java:29: error: class, interface, or enum expected
    for (int i=1; i<n; i++){
                  ^
Xoractive.java:29: error: class, interface, or enum expected
    for (int i=1; i<n; i++){
                       ^
Xoractive.java:31: error: class, interface, or enum expected
    }
    ^
Xoractive.java:33: error: class, interface, or enum expected
    vector<int> allPairwiseXor = get_pairwise_xor(allPositions);
    ^
Xoractive.java:34: error: class, interface, or enum expected
    vector<int> excludeFirstXor = get_pairwise_xor(exludeFirst);
    ^
Xoractive.java:35: error: class, interface, or enum expected
    multiset<int> allValues = filter(allPairwiseXor, excludeFirstXor);
    ^
Xoractive.java:36: error: class, interface, or enum expected
    vector<int> valToInd(n+1); // Maps an element to its answer index
    ^
Xoractive.java:37: error: class, interface, or enum expected
    valToInd[first] = 1;
    ^
Xoractive.java:39: error: class, interface, or enum expected
    int maxBits = log2(n)+1;
    ^
Xoractive.java:40: error: class, interface, or enum expected
    for (int i=0; i<=maxBits; i++){  
    ^
Xoractive.java:40: error: class, interface, or enum expected
    for (int i=0; i<=maxBits; i++){  
                  ^
Xoractive.java:40: error: class, interface, or enum expected
    for (int i=0; i<=maxBits; i++){  
                              ^
Xoractive.java:42: error: class, interface, or enum expected
        for (int j=2; j<=n; j++){
        ^
Xoractive.java:42: error: class, interface, or enum expected
        for (int j=2; j<=n; j++){
                      ^
Xoractive.java:42: error: class, interface, or enum expected
        for (int j=2; j<=n; j++){
                            ^
Xoractive.java:45: error: class, interface, or enum expected
            }
            ^
Xoractive.java:49: error: class, interface, or enum expected
        }
        ^
Xoractive.java:51: error: class, interface, or enum expected
        currSet.push_back(1);
        ^
Xoractive.java:52: error: class, interface, or enum expected
        vector<int> xorWithFirst = get_pairwise_xor(currSet);
        ^
Xoractive.java:53: error: class, interface, or enum expected
        multiset<int> currSetResult = filter(xorWithFirst, currSetXor);
        ^
Xoractive.java:54: error: class, interface, or enum expected
        set<int> processed;
        ^
Xoractive.java:55: error: class, interface, or enum expected
        for (int curr : currSetResult){
        ^
Xoractive.java:58: error: class, interface, or enum expected
            }
            ^
Xoractive.java:60: error: class, interface, or enum expected
            int val = curr ^ first; // Convert XOR value to orig value
            ^
Xoractive.java:61: error: class, interface, or enum expected
            valToInd[val] += 1<<i; 
            ^
Xoractive.java:62: error: class, interface, or enum expected
        }
        ^
Xoractive.java:64: error: class, interface, or enum expected
    for (int i=1; i<=n; i++){
                  ^
Xoractive.java:64: error: class, interface, or enum expected
    for (int i=1; i<=n; i++){
                        ^
Xoractive.java:66: error: class, interface, or enum expected
    }
    ^
Xoractive.java:68: error: class, interface, or enum expected
}
^
47 errors