답안 #201351

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201351 2020-02-10T09:56:04 Z theStaticMind Password (RMI18_password) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int, int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
int query(string s);
string merge(string a, string b){
      int j = 0;
      if(a.length() > b.length())swap(a, b);
      for(int i = 0; i <= a.length() && j < b.length(); i++){
            string w = a;
            string::iterator itr = a.insert(a.begin() + i, b[j]);
            if(query(a) == a.length()){
                  j++;
            }
            else {
                  a.erase(itr);
            }
      }
      return a;
}
string guess(int n, int k){
      vector<string> seg;
      for(int i = 0; i < k; i++){
            string s;
            for(int j = 0; j < n; j++) s.pb('a' + i);
            int l = query(s);
            s.clear();
            for(int j = 0; j < l; j++) s.pb('a' + i);
            seg.pb(s);
      }
      while(seg.size() != 1){
            vector<string> temp;
            for(int i = 1; i < seg.size(); i += 2){
                  temp.pb(merge(seg[i - 1], seg[i]));
            }
            if(seg.size() % 2)temp.pb(seg.back());
            swap(temp, seg);
      }
      return seg[0];
}

Compilation message

password.cpp: In function 'std::__cxx11::string merge(std::__cxx11::string, std::__cxx11::string)':
password.cpp:14:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 0; i <= a.length() && j < b.length(); i++){
                      ~~^~~~~~~~~~~~~
password.cpp:14:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 0; i <= a.length() && j < b.length(); i++){
                                         ~~^~~~~~~~~~~~
password.cpp:17:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(query(a) == a.length()){
                ~~~~~~~~~^~~~~~~~~~~~~
password.cpp: In function 'std::__cxx11::string guess(long long int, long long int)':
password.cpp:38:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i = 1; i < seg.size(); i += 2){
                            ~~^~~~~~~~~~~~
/tmp/cc3SkfE9.o: In function `main':
grader.cpp:(.text.startup+0x5f): undefined reference to `guess[abi:cxx11](int, int)'
collect2: error: ld returned 1 exit status