답안 #512910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
512910 2022-01-16T19:47:45 Z Carmel_Ab1 Hidden Sequence (info1cup18_hidden) C++17
0 / 100
5 ms 316 KB
#include<bits/stdc++.h>
#include "grader.h"
#define pb push_back
using namespace std;
typedef vector<int>vi;

int mx_len=0;
bool ask(vi v){
    mx_len=max(mx_len,int(v.size()));
    return isSubsequence(v);
}
int c0=0,c1=0;


vi buildL(int n){
    int cur1=c1,cur0=c0;
    vi ans;

    while(ans.size()!=n){
        if(cur1>cur0){
            vi v;
            for(int x:ans)
                v.pb(x);
            v.pb(1);
            for(int i=0; i<cur0; i++)
                v.pb(0);
            if(ask(v))
                ans.pb(1),cur1--;
            else
                ans.pb(0),cur0--;
        }
        else{
            vi v;
            for(int x:ans)
                v.pb(x);
            v.pb(0);
            for(int i=0; i<cur1; i++)
                v.pb(1);
            if(ask(v))
                ans.pb(0),cur0--;
            else
                ans.pb(1),cur1--;
        }
    }
    return ans;
}
vi buildR(int n){
    int cur1=c1,cur0=c0,ans0=0,ans1=0;
    vi ans;

    while(ans.size()!=n){
        if(c1>c0){
            vi v=vi(cur0,0);
            v.pb(1);

            if(ans.size() && ans[0]==1)
                v.pb(1);
            for(int i=0; i<ans0;i ++)
                v.pb(0);
            if(ask(v))ans.insert(ans.begin(),1),ans1++,cur1--;
            else ans.insert(ans.begin(),0),ans0++,cur0--;
        }
        else{
            vi v=vi(cur1,1);
            v.pb(0);

            if(ans.size() && ans[0]==0)
                v.pb(0);
            for(int i=0; i<ans1;i ++)
                v.pb(1);
            if(ask(v))ans.insert(ans.begin(),0),ans0++,cur0--;
            else ans.insert(ans.begin(),1),ans1++,cur1--;
        }
    }
    return ans;
}
vi findSequence (int n){
    for(int i=1; ; i++){
        vi all1=vi(i,1);
        vi all0=vi(i,0);

        if(!ask(all1)){
            c1=i-1;
            c0=n-c1;
            break;
        }
        if(!ask(all0)){
            c0=i-1;
            c1=n-c0;
            break;
        }
    }
    vi L=buildL((n+1)/2),R=buildR(n/2);
    vi ans;
    for(int x:L)ans.pb(x);
    for(int x:R)ans.pb(x);
    return ans;
}

Compilation message

hidden.cpp: In function 'vi buildL(int)':
hidden.cpp:19:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     while(ans.size()!=n){
      |           ~~~~~~~~~~^~~
hidden.cpp: In function 'vi buildR(int)':
hidden.cpp:51:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |     while(ans.size()!=n){
      |           ~~~~~~~~~~^~~
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++)
      |                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 316 KB Output is not correct: The returned sequence does not match the hidden one
2 Halted 0 ms 0 KB -