답안 #774435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
774435 2023-07-05T17:57:03 Z lollipop 최후의 만찬 (IOI12_supper) C++17
0 / 100
206 ms 142752 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++) sol[i] = false;
	for (int i = 0; i < N; i++) las[i] = N + K;
	for (int i = 0; i < v.size(); i++) {
		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 {
			//printf("inside %d\n", x); fflush(stdout);
			sol[las[x]] = true;
			s.erase({-q[x].front(), x});
			q[x].pop();
			s.insert({-q[x].front(), x});
		}
		las[x] = i;
	}
	for (auto iter : s) sol[las[iter.second]] = true;
	for (int i = 0; i < v.size(); i++) WriteAdvice(sol[i]);
}
//#include "grader.h"
#include "assistant.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
//#define int long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod =  1000000007 ;
const int mod1 = 998244353 ;
const int N = 2e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;
int pos[ N ] ;
void Assist(unsigned char *a, int n, int r, int rr){
     set < int > act , non ;
     int cnt = 0 ; 
     FOR( i , r ){
     	if( a[ i ] == 1 ) act.insert( i ) ;
		else non.insert( i ) ; 
	    pos[ i ] = i ;  
	    cnt ++ ; 
	 }
	 FOR( i , N ){
	 	int x = GetRequest() ;
	 	if( act.find( x ) != act.end() ){
	 	    pos[ x ] = cnt ; cnt ++ ; 
			if( a[ pos[ x ] ] == 0 ){
				act.erase( act.find( x ) ) ;
				non.insert( x ) ;
			} 	
			continue ; 
		}
		int X = *non.begin() ;
		non.erase( non.begin() ) ; 
		PutBack( X ) ;
		pos[ x ] = cnt ; cnt ++ ; 
		if( a[ pos[ x ] ] == 1 ) act.insert( x ) ;
		else non.insert( x ) ; 
	 }
    
}

//void PutBack(int T);
//
//int GetRequest();




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++) sol[i] = false;
      |                  ~~^~~~~~~~~~
advisor.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
advisor.cpp:31:8: warning: unused variable 'tr' [-Wunused-variable]
   31 |    int tr = s.begin()->second;
      |        ^~
advisor.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for (int i = 0; i < v.size(); i++) WriteAdvice(sol[i]);
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 65 ms 135116 KB Error - Too many requests
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 94 ms 136144 KB Error - Too many requests
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 155 ms 141000 KB Error - Too many requests
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 135560 KB Error - Too many requests
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 181 ms 142120 KB Error - Too many requests
2 Incorrect 177 ms 142360 KB Error - Too many requests
3 Incorrect 190 ms 142580 KB Error - Too many requests
4 Incorrect 206 ms 142604 KB Error - Too many requests
5 Incorrect 184 ms 142524 KB Error - Too many requests
6 Incorrect 197 ms 142624 KB Error - Too many requests
7 Incorrect 202 ms 142752 KB Error - Too many requests
8 Incorrect 180 ms 142528 KB Error - Too many requests
9 Incorrect 184 ms 142540 KB Error - Too many requests
10 Incorrect 186 ms 142580 KB Error - Too many requests