답안 #493758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493758 2021-12-12T20:03:13 Z Habitus Hidden Sequence (info1cup18_hidden) C++14
컴파일 오류
0 ms 0 KB
#include "grader.h"
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dec(x, y) fixed << setprecision((y)) << (x)
#define xx first
#define yy second
#define srt(v) sort((v).begin(), (v).end())
#define srtr(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define popb pop_back
#define sz(a) (int)(a).size()
#define len(a) (int)(a).length()
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

bool nasao, nasao1;
int d, je, gde[200];
bool isSubsequence(vector<int> S) {

}
vector<int> findSequence(int N) {
    d=N/2+1;
    vector<int> v;
    for(int i=1; i<=d; i++) {
        v.pb(1);
        bool da=isSubsequence(v);
        if(!da) {
            je=i-1;
            nasao=1;
            break;
        }
    }
    if(!nasao) {
        v.clear();
        for(int i=1; i<=d; i++) {
            v.pb(0);
            bool da=isSubsequence(v);
            if(!da) {
                je=n-i+1;
                break;
            }
        }
    }
    for(int a=0; a<je; a++) {
        nasao=nasao1=0;
        for(int i=0; i+je-a<=d; i++) {
            v.clear();
            for(int j=0; j<i; j++) v.pb(0);
            for(int j=0; j<je-a; j++) v.pb(1);
            bool da=isSubsequence(v);
            if(!da) {
                gde[a]=i+a-1;
                nasao=1;
                break;
            }
        }
        if(!nasao) {
            v.clear();
            for(int j=0; j<a; j++) v.pb(1);
            for(int i=0; i+a+1<=d; i++) {
                if(i==0) v.pb(1);
                else v.pb(0);
                bool da=isSubsequence(v);
                if(!da) {
                    gde[a]=n-2-je-i+a;
                    nasao1=1;
                    break;
                }
            }
        }
        if(!nasao1) {
            gde[a]=d-je+2*a;
        }
    }
    v.resize(N);
    for(int i=0; i<je; i++) {
        v[gde[i]]=1;
    }
    return v;
}

Compilation message

hidden.cpp: In function 'bool isSubsequence(std::vector<int>)':
hidden.cpp:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
   25 | }
      | ^
hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:44:20: error: 'n' was not declared in this scope
   44 |                 je=n-i+1;
      |                    ^
hidden.cpp:70:28: error: 'n' was not declared in this scope
   70 |                     gde[a]=n-2-je-i+a;
      |                            ^
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |     fprintf (fifo_out, "%d\n", ans.size ());
      |                         ~^     ~~~~~~~~~~~
      |                          |              |
      |                          int            std::vector<int>::size_type {aka long unsigned int}
      |                         %ld
grader.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i=0; i<ans.size () && i < N; i++)
      |                   ~^~~~~~~~~~~~