답안 #1091358

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091358 2024-09-20T16:59:30 Z kotnid Martian DNA (IOI16_dna) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

set<string>st;

int T = 0;
// bool f(string s){
//     string ans = "0";
//     if(st.find(s) != st.end())return 0;
//     cout << "? " << s << endl;
//     T++;
//     return (ans.find(s) != string::npos);
// }

bool f(string s){
    if(st.find(s) != st.end())return 0;
    // cout << "? " << s << endl;
    return make_test(s);
    // bool v;
    // cin >> v;
    // return v;
}

string analyse(int n, int t){
    st.clear();
    int len0 = 0;
    string s = "0";
    while(s.size() <= n && f(s)){
        len0++;
        s += "0";
    }
    st.insert(s);
    s.pop_back();

    if(len0 == 0){
        string s2 = "";
        for(int i=0; i<n; i++)s2 += "1";
        return s2;
        // cout << "! ";
        // for(int i=0; i<n; i++)cout << 1;
        // cout << endl;
        // return ;
    }
    // right side
    int flag = 1;
    int cnt = 0;
    while(1){
        s += (char)(flag+'0');
        cnt++;
        if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
        st.insert(s);
        s.pop_back();
        flag = 1-flag;
        s += (char)(flag+'0');
        cnt = 1;
        if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
        st.insert(s);
        s.pop_back();
        break;
    }

    flag = 1;
    cnt = 0;
    while(1){
        s.insert(0, string(1,(char)(flag+'0')));
        cnt++;
        if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
        st.insert(s);
        s.erase(s.begin());
        flag = 1-flag;
        s.insert(0, string(1,(char)(flag+'0')));
        cnt = 1;
        if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
        st.insert(s);
        s.erase(s.begin());
        break;
    }

    return s;
    // cout << T << endl;
}

// int main(){
//     int t;
//     cin >> t;
//     while(t--)solve();
// }

Compilation message

dna.cpp: In function 'bool f(std::string)':
dna.cpp:18:12: error: 'make_test' was not declared in this scope
   18 |     return make_test(s);
      |            ^~~~~~~~~
dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:28:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     while(s.size() <= n && f(s)){
      |           ~~~~~~~~~^~~~
dna.cpp:50:47: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |         if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
      |                                      ~~~~~~~~~^~~~
dna.cpp:56:47: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |         if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
      |                                      ~~~~~~~~~^~~~
dna.cpp:67:47: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 |         if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
      |                                      ~~~~~~~~~^~~~
dna.cpp:73:47: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |         if(!(!flag && cnt > len0) && s.size() <= n && f(s))continue;
      |                                      ~~~~~~~~~^~~~
grader.cpp: In function 'bool make_test(std::string)':
grader.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i < p.size(); i++) {
      |                  ~~^~~~~~~~~~
grader.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int i = 1; i <= ss.size(); i++) {
      |                  ~~^~~~~~~~~~~~
grader.cpp:28:13: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if (pr[i] == p.size()) {