Submission #1022405

# Submission time Handle Problem Language Result Execution time Memory
1022405 2024-07-13T13:08:46 Z NintsiChkhaidze Hidden Sequence (info1cup18_hidden) C++17
100 / 100
5 ms 444 KB
#include<bits/stdc++.h>
#define pb push_back
#include "grader.h"
using namespace std;

vector <int> get(int x,int y,int c1,int c2){
	vector <int> v;
	for (int i = 1; i <= c1; i++)
		v.pb(x);
		
	for (int i = 1; i <= c2; i++)
		v.pb(y);
		
	return v;
}
vector <int> findSequence (int N){
	int n = N;
    int zero = 0, one = 1,cnt0 = 0,cnt1 = 0;
    int lim = N / 2 + 1;
    
    vector <int> vec(lim,0);
    if (!isSubsequence(vec)){
    	for (int i = 1; i <= (N / 2); i++){
    		vector <int> v(i,0);
    		if (isSubsequence(v)) cnt0 = i;
		}
		cnt1 = N - cnt0;
	}else{
		for (int i = 1; i <= (N / 2); i++){
    		vector <int> v(i,1);
    		if (isSubsequence(v)) cnt0 = i;
		}
		cnt1 = N - cnt0;
		zero = 1; one = 0;
	}
	//zero aris minimaluri raodenobit romelic gvxvdeba
	
	vector <int> ans;
	int i = 1,c1 = 0;
	while (i <= cnt0){
		int len1 = i + cnt1 - c1;
		if (len1 <= lim){
			if (isSubsequence(get(zero,one,i,cnt1 - c1))) {
				ans.pb(zero);
				i += 1;
			}else{
				ans.pb(one);
				c1 += 1;
			}
			continue;	
		}
		
		if (isSubsequence(get(one,zero,c1+1,cnt0 - i + 1))){
			ans.pb(one);
			c1+=1;
		}else{
			ans.pb(zero);
			i += 1;
		}
	}
	
	while (c1 < cnt1) ans.pb(one),++c1;
    return ans;
}

Compilation message

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:17:6: warning: unused variable 'n' [-Wunused-variable]
   17 |  int n = N;
      |      ^
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++)
      |                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct: Maximum length of a query = 5
2 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 6
3 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 5
4 Correct 1 ms 344 KB Output is correct: Maximum length of a query = 5
5 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 4
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct: Maximum length of a query = 83
2 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 90
3 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 96
4 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 77
5 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 95
6 Correct 2 ms 344 KB Output is correct: Maximum length of a query = 87
7 Correct 5 ms 344 KB Output is correct: Maximum length of a query = 97
8 Correct 2 ms 344 KB Output is correct: Maximum length of a query = 83
9 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 101
10 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 100
11 Correct 3 ms 444 KB Output is correct: Maximum length of a query = 96
12 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 100
13 Correct 3 ms 344 KB Output is correct: Maximum length of a query = 101