Submission #317058

# Submission time Handle Problem Language Result Execution time Memory
317058 2020-10-29T01:49:29 Z Kevin_Zhang_TW Hidden Sequence (info1cup18_hidden) C++17
Compilation error
0 ms 0 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) {
			if (query( F + zero + B )) {
				res = F + zero + B;
				break;
			}
			if (query( F + one + B)) {
				res = F + one + B;
				break;
			}
			if (i == res.size()) 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) {
      |                  ~~^~~~~~~~~~~~~
hidden.cpp:53:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |    if (i == res.size()) break;
      |        ~~^~~~~~~~~~~~~
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++)
      |                   ~^~~~~~~~~~~~
/tmp/ccBGmynx.o: In function `main':
grader.cpp:(.text.startup+0x3f): undefined reference to `findSequence(int)'
collect2: error: ld returned 1 exit status