Submission #67149

# Submission time Handle Problem Language Result Execution time Memory
67149 2018-08-13T11:58:14 Z MrTEK Hidden Sequence (info1cup18_hidden) C++14
44 / 100
11 ms 556 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];
bool fl;
vector <int > v;
vector <int> vec;
 
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> v2) {
 
    int i = 0;
    for (auto it : v)
    {
        while (i < len(v2) && it != v2[i]) i ++;
        if (i == len(v2)) return 0;
        i ++;
    }
    return 1;
}
 
void last_dfs(int x,int y,vector <int> v) {
    if (y == sz[0]) {
        fl = fl & isSubsequence(vec);
        return;
    }
    if (x == sz[1] - 1) {
        return;
    }
    vec.pb(v[x + 1]);
    last_dfs(x + 1, y + 1,v);
    vec.pop_back();
    last_dfs(x + 1,y,v);
}
 
 
bool check(vector <int> v) {
    fl = true;
    last_dfs(-1,0,v);
    return fl;
} 
 
vector < int > findSequence (int N)
{
	if (N <= 10) {
	    vector < int > ans (N, 0);
	    if (N > 10) exit(0);
	    sz[0] = N / 2 + 1;
	    sz[1] = N;
	    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 && check(allvec[1][i])) {
	            for (int j = 0 ; j < N ; j++) ans[j] = allvec[1][i][j];
	            break;
	        }
	    }
	    return ans;
	}
    vector < int > ans (N, 0),sif,v;
    for (int i = 0 ; i < N ; i++) {
        sif.pb(0);
        if (isSubsequence(sif) == false) {sif.pop_back();break;}
    }
    if (len(sif) == N) {
        for (int i = 0 ; i < N ; i++) ans[i] = sif[i];
        return ans;
    }
    else if(len(sif) == 0) {
        for (int i = 0 ; i < N ; i++) ans[i] = 1;
        return ans;
    }
    for (int i = 0 ; i < N ; i++) {
        v.clear();
        for (int j = 0; j < i ; j++) v.pb(ans[j]);
        v.pb(1);
        for (int j = 0 ; j < len(sif) ; j++) v.pb(sif[j]);
        if (len(v) > N) {
            for (int j = i ; j < N ; j++) ans[i] = 0;
                break;
        }
        // printf("%d ------>",i + 1);
        // for (auto j : v) printf("%d ",j);
        // puts("");
        if (isSubsequence(v)) {
            ans[i] = 1;
            continue;
        }
        else {
            ans[i] = 0;
            sif.pop_back();
        }
    }
    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++)
                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 320 KB Output is correct: Maximum length of a query = 5
2 Correct 4 ms 536 KB Output is correct: Maximum length of a query = 6
3 Correct 3 ms 536 KB Output is correct: Maximum length of a query = 5
4 Correct 3 ms 544 KB Output is correct: Maximum length of a query = 5
5 Correct 2 ms 544 KB Output is correct: Maximum length of a query = 4
# Verdict Execution time Memory Grader output
1 Partially correct 6 ms 544 KB Output is partially correct: Maximum length of a query = 165
2 Partially correct 8 ms 544 KB Output is partially correct: Maximum length of a query = 178
3 Partially correct 6 ms 544 KB Output is partially correct: Maximum length of a query = 190
4 Partially correct 4 ms 544 KB Output is partially correct: Maximum length of a query = 153
5 Partially correct 5 ms 544 KB Output is partially correct: Maximum length of a query = 188
6 Partially correct 6 ms 544 KB Output is partially correct: Maximum length of a query = 172
7 Partially correct 6 ms 544 KB Output is partially correct: Maximum length of a query = 192
8 Partially correct 8 ms 548 KB Output is partially correct: Maximum length of a query = 164
9 Partially correct 8 ms 548 KB Output is partially correct: Maximum length of a query = 200
10 Partially correct 7 ms 548 KB Output is partially correct: Maximum length of a query = 199
11 Partially correct 11 ms 548 KB Output is partially correct: Maximum length of a query = 190
12 Partially correct 6 ms 548 KB Output is partially correct: Maximum length of a query = 199
13 Partially correct 8 ms 556 KB Output is partially correct: Maximum length of a query = 200