답안 #789456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
789456 2023-07-21T12:05:08 Z Ronin13 최후의 만찬 (IOI12_supper) C++17
0 / 100
2500 ms 7292 KB
#include <bits/stdc++.h>
#include "advisor.h"
#define ll long long 
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
void ComputeAdvice(int *c, int n, int k, int m) {
    int ans[n + k];
    vector <int> used(n, -1);
    fill(ans, ans + n + k, 1);
  set <pii, greater <pii> > pq;
    int nx[n + k];
    int last[n];
    fill(nx, nx + n + k, 1e9);
    fill(last, last + n, 1e9);
    for(int i = n - 1; i >= 0; i--){
        nx[i + k] = last[c[i]];
        last[c[i]] = i + k;
    }
    for(int i = k - 1; i >= 0; i--){
        nx[i] = last[i];
        last[i] = i;
        pq.insert({nx[i], i});
        used[i] = i;
    }
    
    for(int i=  0; i < n; i++){
          if(used[c[i]] == -1){
         int o = pq.begin()->s;
       //  cout << nx[o] << ' ';
        // cout << o << ' ';
         int vv;
         if(o < k) vv = o;
         else vv = c[o];
         used[vv] = -1;
          pq.erase(pq.begin());
          ans[o] = 0;
          }
          pq.erase({i + k, used[c[i]]});
          
          used[c[i]] = i + k;
          pq.insert({nx[i + k], i + k});
      
    }
    for(int i = 0; i < n + k; i++)
      WriteAdvice(ans[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"
#define ll long long 
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

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

       set <int> x, y;
      int cur[k];
      int pos[n];
      for(int i = 0; i < k; i++){
          if(a[i] == 0) y.insert(i);
          x.insert(i);
          cur[i] =i;
          pos[i] = i;
      }
      for(int i = 0; i < n; i++){
          int val = GetRequest();
          if(x.find(val) != x.end()){
              if(a[i + k] == 0) y.insert(pos[val]);
          }
          else{
              int ops = *y.begin();
              y.erase(y.begin());
              PutBack(cur[ops]);
              x.erase(cur[ops]);
              pos[val] = ops;
              cur[ops] = val;
              if(a[i + k] == 0)
                y.insert(ops);
               x.insert(val);
          }
      }
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 3 ms 780 KB Output is correct
4 Execution timed out 2588 ms 676 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 992 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 5880 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 952 KB Output is correct
2 Correct 4 ms 920 KB Output is correct
3 Runtime error 2 ms 596 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 28 ms 6732 KB Execution killed with signal 11
2 Runtime error 30 ms 6940 KB Execution killed with signal 11
3 Runtime error 37 ms 7292 KB Execution killed with signal 11
4 Runtime error 32 ms 7244 KB Execution killed with signal 11
5 Runtime error 30 ms 7180 KB Execution killed with signal 11
6 Runtime error 31 ms 7212 KB Execution killed with signal 11
7 Runtime error 30 ms 7208 KB Execution killed with signal 11
8 Runtime error 29 ms 7220 KB Execution killed with signal 11
9 Runtime error 31 ms 7228 KB Execution killed with signal 11
10 Runtime error 23 ms 7220 KB Execution killed with signal 11