답안 #363027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363027 2021-02-05T03:08:29 Z Kevin_Zhang_TW 최후의 만찬 (IOI12_supper) C++17
0 / 100
156 ms 16500 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#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...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
const int MAX_N = 300010;

#include "advisor.h"

int nxt[MAX_N];
struct cmp {
	bool operator()(int a, int b) const{ 
		return nxt[a] < nxt[b];
	}
};
vector<int> pos[MAX_N];

set<int, cmp> st;

bool suc[MAX_N], need[MAX_N];

void pushin(int id) {
	st.insert(id);
}
void kill(int id) {
	st.erase(id);
}
void popoff() {
	st.erase(prev(end(st)));
}
bool kp[MAX_N + MAX_N];
void ComputeAdvice(int *C, int N, int K, int M) {
	for (int i = 0;i < N;++i) pos[i].pb(N+i);
	for (int i = N-1;i >= 0;--i)
		pos[ C[i] ].pb(i);
	for (int i = 0;i < K;++i) {
		nxt[i] = pos[i].back();
		pushin(i);
	}
	DE(N, K, M);
	int cnt = 0;
	for (int i = 0;i < N;++i) {
		if (suc[i] = st.count(C[i])) {
			kill(C[i]);
			pos[ C[i] ].pop_back();
			nxt[ C[i] ] = pos[ C[i] ].back();
			++cnt;
		}
		else 
			popoff();
		pushin(C[i]);
	}
	DE(cnt);
	for (int i = N-1;i >= 0;--i) {
		kp[i + K] = need[C[i]];
		need[C[i]] = suc[i];
	}
	for (int i = K-1;i >= 0;--i) 
	   kp[i] = need[C[i]];	
	for (int i = 0;i < N + K;++i) {
		 WriteAdvice(kp[i]);
	}
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
namespace {
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#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...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
const int MAX_N = 300010;
}

#include "assistant.h"

int have[MAX_N];

void popoff(int id) {
	have[id] = false;
	PutBack(id);
}
void Assist(unsigned char *A, int N, int K, int R) {
	vector<int> gar;
	for (int i = 0;i < K;++i) {
		have[i] = true;
		if (A[i] == 0) gar.pb(i);
	}
	for (int i = 0;i < N;++i) {
		int req = GetRequest();
		if (!have[req]) {
			popoff(gar.back()); gar.pop_back();
		}
		have[req] = true;
		if (A[i + K] == 0) gar.pb(req);
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:14:17: warning: statement has no effect [-Wunused-value]
   14 | #define DE(...) 0
      |                 ^
advisor.cpp:51:2: note: in expansion of macro 'DE'
   51 |  DE(N, K, M);
      |  ^~
advisor.cpp:54:14: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   54 |   if (suc[i] = st.count(C[i])) {
      |       ~~~~~~~^~~~~~~~~~~~~~~~
advisor.cpp:14:17: warning: statement has no effect [-Wunused-value]
   14 | #define DE(...) 0
      |                 ^
advisor.cpp:64:2: note: in expansion of macro 'DE'
   64 |  DE(cnt);
      |  ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 7992 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 8684 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 109 ms 14612 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 8492 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 135 ms 15948 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 156 ms 16112 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 137 ms 16188 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 143 ms 16188 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 144 ms 16188 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 138 ms 16316 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 138 ms 16212 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 138 ms 16188 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 140 ms 16204 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 126 ms 16500 KB Output isn't correct - not an optimal way