Submission #988441

# Submission time Handle Problem Language Result Execution time Memory
988441 2024-05-24T17:26:35 Z vjudge1 Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "advisor.h"
#include "assistant.h"

#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define vint vector<int>
#define vpii vector<pii>
#define se second
#define fi first
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
const int N = (int)2e5 + 69;
const int mod = 1000000007;
const int base = 313;
const int INF = INT_MAX;
int power(int a, int bb) { int ans = 1;while (bb) { if (bb % 2) { ans *= a; }a *= a;bb /= 2; }return ans; }
int gcd(int a, int b) { if (b == 0)return a;return gcd(b, a % b); }

void ComputeAdvice(int c[], int n, int k, int m) {
	vint mp(n,0);
	vint pos[N];
	set<pii> s;
	vint advice(n+k, 0);
	for (int i = 0; i < n; i++)
		pos[c[i]].pb(i);
	for (int i = 0; i < k; i++) {
		mp[i] = 1;
		if (!pos[i].size())
			s.insert({ -INF,i});
		else
			s.insert({ -pos[i][0],i });
	}
	for (int i = 0; i < n; i++) {
		if(!mp[c[i]]) {
			pii tmp = *s.begin();
			s.erase(s.begin());
			advice[tmp.se] = 1;
			mp[c[i]] = 1;
			if (tmp.se < k) 
				mp[tmp.se] = 0;
			else 
				mp[c[tmp.se - k]] = 0;
		}
		int idx = upper_bound(all(pos[c[i]]), i) - pos[c[i]].begin();
		if (idx == pos[c[i]].size())
			s.insert({ -INF,i + k });
		else
			s.insert({ -pos[c[i]][idx],i + k });
	}
	for (int i = 0; i < n + k; i++)
		WriteAdvice(advice[i]);
}
void Assist(unsigned char* a, int n, int k, int R) {
	vint st;
	vint mp(n,0);
	for (int i = 0; i < k; i++) {
		mp[i] = 1;
		if (a[i])
			st.pb(i);
	}
	for (int i = 0; i < n; i++) {
		int c = GetRequest();
		if (!mp[c]) {
			PutBack(st.back());
			mp[st.back()] = 0;
			mp[c] = 1;
			st.pop_back();
		}
		if (a[i + k])
			st.pb(c);
	}
	return;
}


//int32_t main() {
//
//    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//
//    
//}



    

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:48:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   if (idx == pos[c[i]].size())
      |       ~~~~^~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccZiU7WE.o: in function `Assist(unsigned char*, int, int, int)':
advisor.cpp:(.text+0x918): undefined reference to `GetRequest()'
/usr/bin/ld: advisor.cpp:(.text+0x937): undefined reference to `PutBack(int)'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/ccXoVjPr.o: in function `main':
assistant_grader.cpp:(.text.startup+0x21e): undefined reference to `Assist(unsigned char*, int, int, int)'
collect2: error: ld returned 1 exit status