Submission #772809

# Submission time Handle Problem Language Result Execution time Memory
772809 2023-07-04T11:28:38 Z kingfran1907 Last supper (IOI12_supper) C++14
39 / 100
2500 ms 209852 KB
#include "advisor.h"
#include <vector>
#include <queue>
#include <set>
#include <cstdio>

using namespace std;
const int maxn = 2e5+10;

bool sol[maxn];
vector< int > v;
queue< int > q[maxn];
int las[maxn];

void ComputeAdvice(int *C, int N, int K, int M) {
	for (int i = 0; i < K; i++) v.push_back(i);
	for (int i = 0; i < N; i++) v.push_back(C[i]);
	
	for (int i = 0; i < v.size(); i++) {
		q[v[i]].push(i);
	}
	for (int i = 0; i < N; i++) q[i].push(v.size() + 1);
	
	set< pair<int, int> > s;
	for (int i = 0; i < K; i++) s.insert({-q[i].front(), i});
	for (int i = 0; i < v.size(); i++) {
		//printf("debug: %d\n", v[i]); fflush(stdout);
		int x = v[i];
		if (!s.count({-q[x].front(), x})) {
			int tr = s.begin()->second;
			s.erase(s.begin());
			q[x].pop();
			s.insert({-q[x].front(), x});
		} else {
			sol[las[x]] = 1;
			s.erase({-q[x].front(), x});
			q[x].pop();
			s.insert({-q[x].front(), x});
		}
		las[x] = i;
	}
	for (int i = 0; i < v.size(); i++) WriteAdvice(sol[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"
#define X first
#define Y second

using namespace std;
const int maxn = 1e5+10;
queue< int > qs[maxn];

void Assist(unsigned char *A, int N, int K, int R) {
	set< int > active, passive;
	for (int i = 0; i < K; i++) {
		if (A[i] == 1) active.insert(i);
		else passive.insert(i);
	}
	
	//printf("good\n"); fflush(stdout);
	for (int i = 0; i < N; i++) {
		int c = GetRequest();
		//printf("debug: %d\n", c); fflush(stdout);
		//printf("sizes: %d %d\n", active.size(), passive.size()); fflush(stdout);
		if (!active.count(c) && !passive.count(c)) {
			PutBack(*passive.begin());
			passive.erase(passive.begin());
		}
		active.erase(c);
		passive.erase(c);
		if (A[i + K] == 1) active.insert(c);
		else passive.insert(c);
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
advisor.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
advisor.cpp:30:8: warning: unused variable 'tr' [-Wunused-variable]
   30 |    int tr = s.begin()->second;
      |        ^~
advisor.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for (int i = 0; i < v.size(); i++) WriteAdvice(sol[i]);
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 100 ms 202476 KB Output is correct
2 Correct 103 ms 202420 KB Output is correct
3 Correct 102 ms 202596 KB Output is correct
4 Execution timed out 2599 ms 202640 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 118 ms 202984 KB Output is correct
2 Execution timed out 2552 ms 205208 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 208 ms 207300 KB Output is correct
2 Correct 232 ms 209596 KB Output is correct
3 Correct 249 ms 209768 KB Output is correct
4 Correct 238 ms 209784 KB Output is correct
5 Correct 229 ms 209264 KB Output is correct
6 Correct 234 ms 209768 KB Output is correct
7 Correct 246 ms 209852 KB Output is correct
8 Correct 211 ms 209716 KB Output is correct
9 Execution timed out 2602 ms 209724 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 112 ms 202716 KB Output is correct
2 Correct 109 ms 202856 KB Output is correct
3 Execution timed out 2606 ms 202740 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 235 ms 208104 KB Output is correct - 120000 bits used
2 Correct 246 ms 208356 KB Output is correct - 122000 bits used
3 Correct 244 ms 208596 KB Output is correct - 125000 bits used
4 Correct 273 ms 208740 KB Output is correct - 125000 bits used
5 Correct 240 ms 208616 KB Output is correct - 125000 bits used
6 Correct 251 ms 208620 KB Output is correct - 125000 bits used
7 Correct 233 ms 208548 KB Output is correct - 124828 bits used
8 Correct 260 ms 208624 KB Output is correct - 124910 bits used
9 Correct 239 ms 208704 KB Output is correct - 125000 bits used
10 Correct 212 ms 208600 KB Output is correct - 125000 bits used