Submission #231102

# Submission time Handle Problem Language Result Execution time Memory
231102 2020-05-12T17:18:37 Z CaroLinda Last supper (IOI12_supper) C++14
0 / 100
152 ms 18672 KB
#include "advisor.h"
#include <bits/stdc++.h>

#define lp(i,a,b) for(int i = a ; i < b ; i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define ff first
#define ss second

const int MAXN = 1e5+10 ;
const int inf = 1e9+10 ;

using namespace std ;

bool is_active[MAXN*2] , scaffold[MAXN] ;
vector<int> cores[MAXN] ;
int ptr[MAXN] , active[MAXN] ;
set<pii> s ;

int get_next(int cor)
{
	if( ptr[cor] >= (int)cores[cor].size() ) return inf ;
	return cores[cor][ ptr[cor]++ ] ;
}

void ComputeAdvice(int *C, int N, int K, int M) 
{


	lp(i,0,N) cores[ C[i] ].pb( i ) ;
	lp(i,0,K) s.insert( mk( get_next(i) , i ) ) , scaffold[i] = true , active[i] = N+i ;

	for(int i = 0 ; i < N ; i++ )
	{
		active[ C[i] ] = i ;

		if( scaffold[ C[i] ] )
		{
			s.erase( s.find( mk( i , C[i] ) ) ) ;
			s.insert( mk( get_next(C[i]) , C[i] ) ) ;

			continue ;
		}

		auto par = *prev(s.end()) ;
		s.erase( prev( s.end() ) ) ;

		scaffold[ par.ss ] = false ;
		scaffold[ C[i] ] = true ;

		is_active[ active[par.ss] ] = true ;

		get_next(C[i]) ;

		s.insert( mk( get_next(C[i]) , C[i] ) ) ;

	}

	lp(i,0,K) WriteAdvice( is_active[N+i]  ) ;
	lp(i,0,N) WriteAdvice( is_active[i] ) ;

}
#include <bits/stdc++.h>
#include "assistant.h"

#define lp(i,a,b) for(int i = a ; i < b ; i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define ff first
#define ss second

const int MAXN = 1e5+10 ;

using namespace std ;	

set<int> actives ;
bool scaff[MAXN] ;

void Assist(unsigned char *A, int N, int K, int R)
{

	int idx = -1 ;

	lp(i,0,K) 
	{
		scaff[i] = true ;
		if( A[++idx] ) actives.insert(i) ;
	}

	lp(i,0,N)
	{
		int x = GetRequest() ;
		if( scaff[x] ) 
		{
			if( A[++idx] ) actives.insert( x ) ;
			continue ;
		}

		scaff[x] = true ;

		int toErase = *actives.begin() ;
		actives.erase( actives.begin() ) ;

		scaff[ toErase ] = false ;

		PutBack(toErase) ;

		if( A[++idx] ) actives.insert(x) ;

	}
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5376 KB Output is correct
2 Correct 10 ms 5376 KB Output is correct
3 Correct 12 ms 5632 KB Output is correct
4 Runtime error 11 ms 5504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 6272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 119 ms 14184 KB Output is correct
2 Correct 145 ms 17648 KB Output is correct
3 Correct 148 ms 17664 KB Output is correct
4 Correct 152 ms 17136 KB Output is correct
5 Runtime error 77 ms 13180 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 5888 KB Output is correct
2 Correct 15 ms 6144 KB Output is correct
3 Correct 17 ms 5888 KB Output is correct
4 Runtime error 15 ms 5760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 76 ms 14236 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Correct 151 ms 16216 KB Output is correct - 122000 bits used
3 Correct 142 ms 16448 KB Output is correct - 125000 bits used
4 Correct 149 ms 16368 KB Output is correct - 125000 bits used
5 Correct 143 ms 16368 KB Output is correct - 125000 bits used
6 Correct 136 ms 16368 KB Output is correct - 125000 bits used
7 Correct 138 ms 16368 KB Output is correct - 124828 bits used
8 Correct 140 ms 16616 KB Output is correct - 124910 bits used
9 Correct 140 ms 16368 KB Output is correct - 125000 bits used
10 Correct 120 ms 18672 KB Output is correct - 125000 bits used