답안 #753635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753635 2023-06-05T15:25:38 Z minhcool 최후의 만찬 (IOI12_supper) C++17
0 / 100
217 ms 15396 KB
#include "advisor.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
//#define int long long
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
 
const int N = 3e5 + 5;
 
const int oo = 1e9 + 7, mod = 1e9 + 7;
 
 /*
mt19937 rng(1);
 
int rnd(int l, int r){
	int temp = rng() % (r - l + 1);
	return abs(temp) + l;
}*/
 
//set<ii> se;
 
map<int, int> mp;
 
int nxt[N];
 
int c[N];
 
bool cook[N];
int in[N];

int n, k;
 
void ComputeAdvice(int *C, int N, int K, int M){
  n = N, k = K;
	for(int i = 0; i < k; i++) c[i] = i;
	for(int i = k; i < n + k; i++) c[i] = C[i - k];
	for(int i = n + k - 1; i >= 0; i--){
		if(mp.find(c[i]) == mp.end()) nxt[i] = oo;
		else nxt[i] = mp[c[i]];
		mp[c[i]] = i;
	}
	set<ii> se;
	for(int i = 0; i < n; i++) in[i] = -1;
	for(int i = 0; i < n + k; i++){
		if(in[c[i]] >= 0){
			se.erase({in[c[i]], c[i]});
			in[c[i]] = nxt[i];
			se.insert({in[c[i]], c[i]});
		}
		else{
			if(se.size() == k){
				int temp = (*se.rbegin()).se;
				cook[temp] = 1;
				in[temp] = -1;
				se.erase((*se.rbegin()));
			}
			in[c[i]] = nxt[i];
			se.insert({in[c[i]], c[i]});
		}
	}
	for(int i = 0; i < n + k; i++) WriteAdvice(cook[i]); 
}
#include "assistant.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 3e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

mt19937 rng(1);

int rnd(int l, int r){
	int temp = rng() % (r - l + 1);
	return abs(temp) + l;
}


void Assist(unsigned char *A, int N, int K, int R){
	int n = N, k = K;
	set<int> cooking;
	set<int> ins;
	//cout << n + k << "\n";
	//for(int i = 0; i < n; i++) in[i] = -1;
	for(int i = 0; i < n + k; i++){
		int x;
		if(i < k) x = i; 
		else x = GetRequest();
		//cout << "HE " << x << "\n";
		if(ins.find(x) != ins.end()){
			cooking.erase(x);
			if(A[i]) cooking.insert(x);
		}
		else{
		//	cout << x << "\n";
		//	cout << "HOHOHO\n";
			if(ins.size() == k){
				assert(cooking.size());
				int temp = (*cooking.begin());
				cooking.erase(temp);
				ins.erase(temp);
				PutBack(temp);
			}
		//	cout << "HOHOHO2\n";
			if(A[i]) cooking.insert(x);
			ins.insert(x);
		//	cout << "HO\n";
		}
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:60:17: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |    if(se.size() == k){
      |                 ^

assistant.cpp:19:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:47:18: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |    if(ins.size() == k){
      |       ~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 524 KB Output is correct
2 Runtime error 2 ms 784 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 1980 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 122 ms 10912 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1292 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 145 ms 12848 KB Execution killed with signal 6
2 Runtime error 151 ms 13136 KB Execution killed with signal 6
3 Runtime error 217 ms 13560 KB Execution killed with signal 6
4 Runtime error 143 ms 13628 KB Execution killed with signal 6
5 Runtime error 138 ms 13608 KB Execution killed with signal 6
6 Runtime error 137 ms 13712 KB Execution killed with signal 6
7 Runtime error 139 ms 13504 KB Execution killed with signal 6
8 Runtime error 138 ms 13548 KB Execution killed with signal 6
9 Runtime error 137 ms 13564 KB Execution killed with signal 6
10 Runtime error 162 ms 15396 KB Execution killed with signal 6