Submission #317061

# Submission time Handle Problem Language Result Execution time Memory
317061 2020-10-29T01:53:07 Z Kevin_Zhang_TW Hidden Sequence (info1cup18_hidden) C++17
34 / 100
12 ms 512 KB
#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] : ", args)
void kout() { cerr << endl; }
template<class T, class ...U>
void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
void debug(auto L, auto R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
vector<int> ans{0,1,1,1,0,1,1,0,1,1,0};
bool isSubsequence(vector<int> a) {
	for (int i = 0, j = 0;i < a.size();++i) {
		while (j < ans.size() && ans[j] != a[i])
			++j;
		if (j == ans.size()) return false;
		++j;
	}
	return true;
}
#else
#include "grader.h"
#define debug(...) 0
#define DE(...) 0
#endif
const int MAX_N = 300010;
const vector<int> zero{0}, one{1};
int n;
bool query(vector<int> a) {
	if (a.size() > n) return false;
	return isSubsequence(a);
}

vector<int> operator + (vector<int> a, vector<int> b) {
	a.insert(end(a), AI(b));
	return a;
}
vector<int> findSequence(int _n) {
	n = _n;
	vector<int> res;
	while (res.size() < n) {
		vector<int> F, B = res;
		for (int i = 0;i <= res.size();++i) {
			while (query( F + zero + B))
				F.pb(0);
			while (query( F + one + B))
				F.pb(1);

			res = F + B;
			if (B.empty()) break;

			F.pb(B[0]);
			B.erase(begin(B));
		}
	}
	return res;
}

#ifdef KEV
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	vector<int> res = findSequence(ans.size());
	if (res == ans)
		cerr << "AC!\n";
	else {
		cerr << "WA\n";
		debug(AI(res));
		cerr << "Should be\n";
		debug(AI(ans));
	}
}
#endif

Compilation message

hidden.cpp: In function 'bool query(std::vector<int>)':
hidden.cpp:31:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |  if (a.size() > n) return false;
      |      ~~~~~~~~~^~~
hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:42:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |  while (res.size() < n) {
      |         ~~~~~~~~~~~^~~
hidden.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for (int i = 0;i <= res.size();++i) {
      |                  ~~^~~~~~~~~~~~~
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 Partially correct 1 ms 256 KB Output is partially correct: Maximum length of a query = 8
2 Partially correct 1 ms 256 KB Output is partially correct: Maximum length of a query = 10
3 Partially correct 1 ms 256 KB Output is partially correct: Maximum length of a query = 8
4 Partially correct 1 ms 256 KB Output is partially correct: Maximum length of a query = 9
5 Partially correct 1 ms 256 KB Output is partially correct: Maximum length of a query = 7
# Verdict Execution time Memory Grader output
1 Partially correct 8 ms 384 KB Output is partially correct: Maximum length of a query = 165
2 Partially correct 9 ms 384 KB Output is partially correct: Maximum length of a query = 178
3 Partially correct 12 ms 376 KB Output is partially correct: Maximum length of a query = 190
4 Partially correct 7 ms 256 KB Output is partially correct: Maximum length of a query = 153
5 Partially correct 9 ms 376 KB Output is partially correct: Maximum length of a query = 188
6 Partially correct 8 ms 512 KB Output is partially correct: Maximum length of a query = 172
7 Partially correct 8 ms 256 KB Output is partially correct: Maximum length of a query = 192
8 Partially correct 7 ms 256 KB Output is partially correct: Maximum length of a query = 164
9 Partially correct 10 ms 256 KB Output is partially correct: Maximum length of a query = 200
10 Partially correct 10 ms 256 KB Output is partially correct: Maximum length of a query = 199
11 Partially correct 10 ms 256 KB Output is partially correct: Maximum length of a query = 190
12 Partially correct 7 ms 256 KB Output is partially correct: Maximum length of a query = 199
13 Partially correct 10 ms 256 KB Output is partially correct: Maximum length of a query = 200