답안 #199692

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199692 2020-02-02T20:37:39 Z Osama_Alkhodairy Password (RMI18_password) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.cpp"
using namespace std;

int query(string s);
string guess(int n, int c){
    vector <int> f(c);
    for(char i = 'a' ; i < 'a' + c ; i++){
        f[i - 'a'] = query(string(n, i));
    }
    string ans;
    for(char i = 'a' ; i < 'a' + c ; i++){
        string cur = ans;
        int e = ans.size();
        for(int j = 0 ; j < f[i - 'a'] ; j++){
            while(e >= 15 && query(ans.substr(0, e - 15) + string(j + 1, i)) != e - 15 + j + 1){
                e -= 16;
            }
            int l = max(0, e - 15), r = e;
            while(l <= r){
                int mid = (l + r) / 2;
                if(query(ans.substr(0, mid) + string(j + 1, i)) == mid + j + 1) l = mid + 1;
                else r = mid - 1;
            }
            cur.insert(cur.begin() + r, i);
        }
        ans = cur;
    }
    return ans;
}

Compilation message

/tmp/ccIhpb0z.o: In function `query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccrJ8ZPi.o:password.cpp:(.text+0x140): first defined here
/tmp/ccIhpb0z.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccrJ8ZPi.o:password.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status