Submission #121334

# Submission time Handle Problem Language Result Execution time Memory
121334 2019-06-26T10:47:13 Z MAMBA Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "advisor.h"

#define rep(i , j , k) for (int i = j; i < k; i++)

using namespace std;

constexpr int MAXN = 2e6 + 10;

int ptr[MAXN];
vector<int> come[MAXN];
bitset<MAXN> a , b, mark;
set<pair<int , int>> st;

void ComputeAdvice(int *C, int N, int K, int M) {
	rep(i , 0 , N) {
		come[i].clear();
		ptr[i] = -1;
	}
	rep(i , 0 , K)
		come[i].push_back(-1);
	rep(i , 0 , N) come[C[i]].push_back(i);
	a.reset();
	b.reset();
	mark.reset();
	rep(i , 0 , K) {
		ptr[i]++;
		mark[i] = true;
		if (ptr[i] + 1 < come[i].size())
			st.insert({-come[i][ptr[i] + 1] , i});
		else st.insert({-1e9 , i});
	}
	rep(i , 0 , N) {
		ptr[C[i]]++;
		if (mark[C[i]]) continue;
		int v = st.begin()->second;
		st.erase(st.begin());
		mark[v] = false;
      mark[C[i]] = true;
		if (come[v][ptr[v]] == -1)
			a[v] = true;
		else b[come[v][ptr[v]]] = true;
		if (ptr[C[i]] + 1 < come[C[i]].size())
			st.insert({-come[C[i]][ptr[C[i]] + 1] , C[i]});
		else st.insert({-1e9 , C[i]});
	}
	rep(i , 0 , K)
		WriteAdvice(a[i] ? 1 : 0);
	rep(i , 0 , N)
		WriteAdvice(b[i] ? 1 : 0);
	return;
}
#include <bits/stdc++.h>
#include "assistant.h"

#define rep(i , j , k) for (int i = j; i < k; i++)

using namespace std;

constexpr int MAXN = 2e6 + 10;

bitset<MAXN> a_ , b_, mark_;
int q[MAXN], l , r;

void Assist(unsigned char *A, int N, int K, int R) {
  assert(N _ K == R);
	l = r = 0;
	mark_.reset();
	a_.reset();
	b_.reset();
	rep(i , 0 , K) mark_[i] = true;
	rep(i , 0 , K)
		if (A[i])
			a_[i] = true;
	rep(i , 0 , N)
		if (A[i + K])
			b_[i] = true;
	rep(i , 0 , K)
		if (a_[i]) q[r++] = i;
	rep(i , 0 , N) {
		int v = GetRequest();
		if (b_[i]) q[r++] = v;
      	if (mark_[v]) continue;
      assert(l < r);
      assert(mark_[q[l]]);
		PutBack(q[l]);
		mark_[q[l]] = false;
		mark_[v] = true;
      l++;
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (ptr[i] + 1 < come[i].size())
       ~~~~~~~~~~~^~~~~~~~~~~~~~~~
advisor.cpp:43:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (ptr[C[i]] + 1 < come[C[i]].size())
       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~

In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from assistant.cpp:1:
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:14:12: error: expected ')' before '_'
   assert(N _ K == R);
            ^
assistant.cpp:14:21: error: expected ')' before ';' token
   assert(N _ K == R);
                     ^
In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from assistant.cpp:1:
assistant.cpp:14:10: warning: statement has no effect [-Wunused-value]
   assert(N _ K == R);
          ^