답안 #1091502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091502 2024-09-21T03:40:04 Z rjvkr2021 Martian DNA (IOI16_dna) C++17
컴파일 오류
0 ms 0 KB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
string analyse(int n, int t) {
    vector<string> yes, no;
    string query;
    auto valid_query = [&](){
        if(query.size() > n){
            return false;
        }
        for(string &t: yes){
            if(!is_substring(query, t)){
                return false;
            }
        }
        for(string &t: no){
            if(is_substring(query, t)){
                return false;
            }
        }
        return true;
    };
    bool response;
    bool suffix_found = false;
    while(true){
        if(suffix_found){
            query.insert(query.begin(), '0'); // try zero
            if(valid_query()){
                response = make_test(query);
                if(response){
                    yes.pb(query);
                    continue;
                }
                else{
                    no.pb(query);
                }
            }
            query[0] = '1'; // try one
            if(valid_query()){
                response = make_test(query);
                if(response){
                    yes.pb(query);
                    continue;
                }
                else{
                    no.pb(query);
                }
            }
            query.erase(query.begin());
            return query;
        }
        else{
            query.pb('0'); // try zero
            if(valid_query()){
                response = make_test(query);
                if(response){
                    yes.pb(query);
                    continue;
                }
                else{
                    no.pb(query);
                }
            }
            query.back() = '1'; // try one
            if(valid_query()){
                response = make_test(query);
                if(response){
                    yes.pb(query);
                    continue;
                }
                else{
                    no.pb(query);
                }
            }
            query.pop_back();
            suffix_found = true;
        }
    }
}

Compilation message

dna.cpp: In lambda function:
dna.cpp:8:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |         if(query.size() > n){
      |            ~~~~~~~~~~~~~^~~
dna.cpp:12:17: error: 'is_substring' was not declared in this scope
   12 |             if(!is_substring(query, t)){
      |                 ^~~~~~~~~~~~
dna.cpp:17:16: error: 'is_substring' was not declared in this scope
   17 |             if(is_substring(query, t)){
      |                ^~~~~~~~~~~~
dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:31:25: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb'
   31 |                     yes.pb(query);
      |                         ^~
dna.cpp:35:24: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb'
   35 |                     no.pb(query);
      |                        ^~
dna.cpp:42:25: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb'
   42 |                     yes.pb(query);
      |                         ^~
dna.cpp:46:24: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb'
   46 |                     no.pb(query);
      |                        ^~
dna.cpp:53:19: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'pb'
   53 |             query.pb('0'); // try zero
      |                   ^~
dna.cpp:57:25: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb'
   57 |                     yes.pb(query);
      |                         ^~
dna.cpp:61:24: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb'
   61 |                     no.pb(query);
      |                        ^~
dna.cpp:68:25: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb'
   68 |                     yes.pb(query);
      |                         ^~
dna.cpp:72:24: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'pb'
   72 |                     no.pb(query);
      |                        ^~
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()) {