답안 #500416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500416 2021-12-31T00:57:28 Z hidden1 Hidden Sequence (info1cup18_hidden) C++14
0 / 100
4 ms 548 KB
#include<bits/stdc++.h>
#include "grader.h"

#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#ifndef LOCAL
#define cerr if(false) cerr
#endif
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
typedef long long ll;
template<class T, template<class T2, class A=allocator<T2> > class cont> inline ostream &operator <<(ostream &out, const cont<T> &x) { for(const auto &it : x) { out << it << " ";} return out;}
template<class T, template<class T2, class A=allocator<T2> > class cont> inline istream &operator >>(istream &in, cont<T> &x) { for(auto &it : x) { in >> it;} return in;}
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;

vector<int> findSequence(int n) {
    int ZERO = 0, ONE = 1;
    int half = (n / 2) + 1;
    vector<int> s = {};
    int cntZero = 0, cntOne = 0;
    for(cntZero = 0; cntZero < half; cntZero ++) {
        s.push_back(0);
        if(!isSubsequence(s)) {
            break;
        }
    }
    s = {};
    for(cntOne = 0; cntOne < half; cntOne ++) {
        s.push_back(1);
        if(!isSubsequence(s)) {
            break;
        }
    }
    if(cntZero > cntOne) {
        swap(ZERO, ONE);
        swap(cntZero, cntOne);
    }
    cntOne = n - cntZero;

    cout << ZERO << " " << ONE << endl;

    vector<int> ans;

    int nowZero = 0, nowOne = 0;

    for(int i = 0; i < n; i ++) {
        if(i != 0 && ans.back() == ONE) {
            if(nowZero + cntOne - nowOne < nowOne + cntZero - nowZero) {
                vector<int> ask = {};
                for(int j = 0; j < nowZero + 1; j ++) {ask.push_back(ZERO);}
                for(int j = 0; j < cntOne - nowOne; j ++) {ask.push_back(ONE);}
                if(!isSubsequence(ask)) {
                    ans.push_back(ONE);
                } else {
                    ans.push_back(ZERO);
                }
            } else {
                vector<int> ask = {};
                for(int j = 0; j < nowOne + 1; j ++) {ask.push_back(ONE);}
                for(int j = 0; j < cntZero - nowZero; j ++) {ask.push_back(ZERO);}
                if(isSubsequence(ask)) {
                    ans.push_back(ONE);
                } else {
                    ans.push_back(ZERO);
                }
            }
        } else {
            vector<int> ask = {};
            for(int j = 0; j < nowZero; j ++) {ask.push_back(ZERO);}
            ask.push_back(ONE);
            for(int j = 0; j < cntZero - nowZero; j ++) {ask.push_back(ZERO);}
            if(isSubsequence(ask)) {
                ans.push_back(ONE);
            } else {
                ans.push_back(ZERO);
            }
        }
        if(ans.back() == ONE) {
            nowOne ++;
        } else {
            nowZero ++;
        }
    }
    return ans;
}


Compilation message

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 Runtime error 1 ms 412 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 548 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -