답안 #207072

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207072 2020-03-06T10:33:39 Z istlemin Password (RMI18_password) C++14
컴파일 오류
0 ms 0 KB
#include "grader.cpp"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;

#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define rrep(i, a, b) for(ll i = b-1; i >= ll(a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

int query(string str);

string combine(string a, string b){
    string ans = "";
    //cout<<a<<" "<<b<<endl;
    while(b.size()&&a.size()){
        if(query(ans+b[0]+a)==sz(ans)+sz(a)+1){
            ans += b[0];
            b.erase(b.begin());
        } else {
            ans += a[0];
            a.erase(a.begin());
        }
    }
    ans+=b;
    ans+=a;
    //cout<<ans<<endl;
    return ans;
}

string guess(int n, int s){
    vector<string> v;

    rep(i,0,s) {
        v.push_back(string(query(string(n,'a'+i)),'a'+i));
        //cout<<v.back()<<endl;
    }
    while(v.size()>=2){
        vector<string> newV;
        rep(i,0,v.size()/2) newV.push_back(combine(v[2*i],v[2*i+1]));
        if(v.size()%2==1) newV.push_back(v.back());
        v = newV;
    }
    return v[0];
}

Compilation message

password.cpp:16:21: warning: optimization attribute on 'int query(std::__cxx11::string)' follows definition but the attribute doesn't match [-Wattributes]
 int query(string str);
                     ^
In file included from password.cpp:1:0:
grader.cpp:14:5: note: previous definition of 'int query(std::__cxx11::string)' was here
 int query(string q) {
     ^~~~~
/tmp/cc3weK9H.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/ccvoVhVV.o:password.cpp:(.text+0xd0): first defined here
/tmp/cc3weK9H.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccvoVhVV.o:password.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status