답안 #500417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500417 2021-12-31T00:57:52 Z hidden1 Hidden Sequence (info1cup18_hidden) C++14
100 / 100
9 ms 300 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;

    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 Correct 0 ms 200 KB Output is correct: Maximum length of a query = 5
2 Correct 1 ms 276 KB Output is correct: Maximum length of a query = 6
3 Correct 0 ms 200 KB Output is correct: Maximum length of a query = 5
4 Correct 1 ms 200 KB Output is correct: Maximum length of a query = 5
5 Correct 1 ms 200 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 200 KB Output is correct: Maximum length of a query = 83
2 Correct 5 ms 300 KB Output is correct: Maximum length of a query = 90
3 Correct 5 ms 200 KB Output is correct: Maximum length of a query = 96
4 Correct 5 ms 292 KB Output is correct: Maximum length of a query = 77
5 Correct 6 ms 284 KB Output is correct: Maximum length of a query = 95
6 Correct 5 ms 200 KB Output is correct: Maximum length of a query = 87
7 Correct 9 ms 292 KB Output is correct: Maximum length of a query = 97
8 Correct 7 ms 200 KB Output is correct: Maximum length of a query = 83
9 Correct 7 ms 200 KB Output is correct: Maximum length of a query = 101
10 Correct 6 ms 288 KB Output is correct: Maximum length of a query = 100
11 Correct 5 ms 200 KB Output is correct: Maximum length of a query = 96
12 Correct 6 ms 200 KB Output is correct: Maximum length of a query = 100
13 Correct 5 ms 200 KB Output is correct: Maximum length of a query = 101