Submission #67093

# Submission time Handle Problem Language Result Execution time Memory
67093 2018-08-13T10:35:32 Z MrTEK Hidden Sequence (info1cup18_hidden) C++14
0 / 100
8 ms 592 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 1e3 + 5;
const int M = 4;
const int SQ = 350;
const int MOD = 998244353;

vector < vector <int> > allvec[2];
vector <vector <int> > seq;

int sz[2];
vector <int > v;

void dfs(int step,int w) {
	if (step > sz[w]) {
		allvec[w].pb(v);
		return; 
	}
	for (int i = 0 ; i < 2 ; i++) {
		v.pb(i);
		dfs(step + 1,w);
		v.pop_back();
	}
}

bool my_isSubsequence (vector < int > v, vector <int> theRealAnswer)
{
    int i = 0;
    for (auto it : v)
    {
        while (i < theRealAnswer.size () && it != theRealAnswer[i]) i++;
        if (i == theRealAnswer.size ()) return 0;
        i++;
    }
    return 1;
}

vector < int > findSequence (int N)
{
	assert(N <= 10);
	sz[0] = N;
	sz[1] = N / 2 + 1;
	dfs(1,0);
	dfs(1,1);
	for (int i = 0 ; i < len(allvec[0]) ; i++) {
		if (isSubsequence(allvec[0][i])) {
			seq.pb(allvec[0][i]);
		}
	}
	for (int i = 0 ; i < len(allvec[1]) ; i++) {
		bool flag = true;
		for (int j = 0 ; j < len(seq); j++) {
	 		if (my_isSubsequence(seq[j],allvec[1][i]) == false) {
	 			flag = false; break;
	 		}
		}
		if (flag) {
			return allvec[1][i];
		}
	}
}

Compilation message

hidden.cpp: In function 'bool my_isSubsequence(std::vector<int>, std::vector<int>)':
hidden.cpp:51:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (i < theRealAnswer.size () && it != theRealAnswer[i]) i++;
                ~~^~~~~~~~~~~~~~~~~~~~~~~
hidden.cpp:52:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i == theRealAnswer.size ()) return 0;
             ~~^~~~~~~~~~~~~~~~~~~~~~~~
hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:81:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
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++)
                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 592 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -