답안 #1076884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076884 2024-08-26T17:57:30 Z Half 최후의 만찬 (IOI12_supper) C++17
0 / 100
2500 ms 25256 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

void ComputeAdvice(int *C, int n, int k, int m) {
  int inf = 2*n;
  set<int> cur;
  set<pair<int, int>> pri;
  vector<set<int>> nxt(n), nxtcp(n);
  for(int i = 0; i < n; ++i){
    nxt[C[i]].insert(i);
    nxtcp[C[i]].insert(i);
  }
  for(int i = 0; i < n; ++i){
    nxt[i].insert(inf);
  }
  for(int i = 0; i < k; ++i)
    cur.insert(k);
  vector<int> rem(n);
  for(int i = 0; i < n; ++i){
    int c = C[i];
    if(cur.find(c) != cur.end()){
      rem[i] = -1;
      pri.erase({-*nxt[c].begin(),c});
      nxt[c].erase(nxt[c].begin());
      pri.insert({-*nxt[c].begin(),c});
    }else{
      auto[x, cr] = *pri.begin();
      rem[i] = cr;
      pri.erase(pri.begin());
      cur.erase(cr);
      pri.insert({-*nxt[c].begin(),c});
      nxt[c].erase(nxt[c].begin());
      cur.insert(c);
    }
  }
  vector<int> lst(n, -1);
  vector<unsigned char> sol(n+k, 0);
  for(int i = 0; i < k; ++i){
    lst[i] = i;
  }
  for(int i = 0; i < n; ++i){
    int c = C[i];
    int r = rem[i];
    if(r == -1){
      sol[lst[c]] = 1;
    }else{
      sol[lst[r]] = 0;
    }
    lst[c] = i+k;
  }
  for(unsigned char bit : sol)
    WriteAdvice(bit);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

void Assist(unsigned char *A, int n, int k, int r) {

  int i;
  set<pair<unsigned char, int>> shelf;
  for(i = 0; i < k; i++){
    shelf.insert({A[i], i});
  }
  for (i = 0; i < n; i++) {
    int c = GetRequest();
    if(shelf.find({1, c}) != shelf.end()){
      shelf.erase({1, c});
      shelf.insert({A[i+k], c});
      continue;
    }
    PutBack(shelf.begin()->second);
    shelf.erase(shelf.begin());
    shelf.insert({A[i+k], c});
  }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2578 ms 2908 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2557 ms 20308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2502 ms 1368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2567 ms 25172 KB Time limit exceeded
2 Execution timed out 2523 ms 25180 KB Time limit exceeded
3 Execution timed out 2544 ms 25180 KB Time limit exceeded
4 Execution timed out 2558 ms 25132 KB Time limit exceeded
5 Execution timed out 2546 ms 25256 KB Time limit exceeded
6 Execution timed out 2553 ms 25124 KB Time limit exceeded
7 Execution timed out 2564 ms 25128 KB Time limit exceeded
8 Execution timed out 2551 ms 25172 KB Time limit exceeded
9 Execution timed out 2520 ms 25168 KB Time limit exceeded
10 Execution timed out 2520 ms 25052 KB Time limit exceeded