답안 #67054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67054 2018-08-13T09:25:26 Z osmanorhan Hidden Sequence (info1cup18_hidden) C++17
100 / 100
14 ms 568 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#include "grader.h"

using namespace std;

bool asknum( int n, int a ) {
	vector<int> v;
	if( n <= a/2+1 ) {
		for(int i=1;i<=n;i++) v.pb( 1 );
		return isSubsequence( v );
	} else {
		for(int i=n;i<=a;i++) v.pb( 0 );
		return !isSubsequence( v );
	}
	return 0;
}

vector < int > findSequence (int a)
{
	int bl = 0, pb = 0;
	int wh = a, pw = 0;
	while( bl < a && asknum(bl+1,a) ) bl++, wh--;
	//printf(" --- black = %d, white = %d\n",bl,wh);
    vector < int > ans (a, 0);
    
    for(int i=0;i<a;i++) {
    	if( !bl || !wh ) {
    		if( bl ) ans[i] = 1, bl--;
    		continue;
    	}
    	vector<int> v;
    	if( bl+pw < wh+pb ) {
    		v.pb( 0 );
    		for(int j=0;j<pw;j++) v.pb( 0 );
    		for(int j=0;j<bl;j++) v.pb( 1 );
    		if( isSubsequence( v ) ) ans[i] = 0;
    		else ans[i] = 1;
    	} else {
    		//printf("asd %d\n",i);
    		v.pb( 1 );
    		for(int j=0;j<pb;j++) v.pb( 1 );
    		for(int j=0;j<wh;j++) v.pb( 0 );
    		if( isSubsequence( v ) ) ans[i] = 1;
    		else ans[i] = 0;
    	}
    	if( ans[i] ) pb++, bl--;
    	else pw++, wh--;
    }

    return ans;
}

Compilation message

grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fifo_out, "%d\n", ans.size ());
                                ~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<ans.size () && i < N; i++)
                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct: Maximum length of a query = 5
2 Correct 3 ms 440 KB Output is correct: Maximum length of a query = 6
3 Correct 3 ms 440 KB Output is correct: Maximum length of a query = 5
4 Correct 2 ms 548 KB Output is correct: Maximum length of a query = 5
5 Correct 2 ms 548 KB Output is correct: Maximum length of a query = 4
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 548 KB Output is correct: Maximum length of a query = 83
2 Correct 9 ms 548 KB Output is correct: Maximum length of a query = 90
3 Correct 10 ms 548 KB Output is correct: Maximum length of a query = 96
4 Correct 8 ms 548 KB Output is correct: Maximum length of a query = 77
5 Correct 12 ms 548 KB Output is correct: Maximum length of a query = 95
6 Correct 8 ms 548 KB Output is correct: Maximum length of a query = 87
7 Correct 14 ms 556 KB Output is correct: Maximum length of a query = 97
8 Correct 8 ms 556 KB Output is correct: Maximum length of a query = 83
9 Correct 8 ms 568 KB Output is correct: Maximum length of a query = 101
10 Correct 9 ms 568 KB Output is correct: Maximum length of a query = 100
11 Correct 9 ms 568 KB Output is correct: Maximum length of a query = 96
12 Correct 9 ms 568 KB Output is correct: Maximum length of a query = 100
13 Correct 11 ms 568 KB Output is correct: Maximum length of a query = 101