답안 #589370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
589370 2022-07-04T14:08:46 Z Koosha_mv 최후의 만찬 (IOI12_supper) C++14
100 / 100
86 ms 7892 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=2e5+99;

int n,k,a[N],nxt[N],last[N],ans[N];

void ComputeAdvice(int *C, int n, int k, int M){
  iota(last,last+n,n);
  f_(i,n-1,0){
    nxt[i]=last[C[i]];
    last[C[i]]=i;
  }
  set<int> s;
  f(i,0,k) s.insert(last[i]);
  fill(last,last+n,-1);
  f(i,0,n){
    if(*s.lower_bound(i)==i){
      s.erase(i);
    }
    else{
      int col;
      if(*s.rbegin()>=n){
        col=*s.rbegin()-n;
      }
      else{
        col=C[*s.rbegin()];
      }
      s.erase(*s.rbegin());
      if(last[col]==-1){
        ans[col]=1;
      }
      else{
        ans[k+last[col]]=1;
      }
    }
    s.insert(nxt[i]);
    last[C[i]]=i;
  }
  f(i,0,n+k) WriteAdvice(ans[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=2e5+99;

int p[N],mark[N];

void Assist(unsigned char *s, int n, int k, int R) {
  vector<int> vec;
  f(i,0,k){
    mark[i]=1;
    if(s[i]==1){
      vec.pb(i);
    }
  }
  f(i,0,n){
    int col=GetRequest();
    if(mark[col]==0){
      int x=vec.back();
      vec.pop_back();
      mark[x]=0;
      mark[col]=1;
      PutBack(x);
    }
    if(s[i+k]==1){
      vec.pb(col);
    }
  }
}
/*
4 2 65000
2 0 3 0
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 524 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 3 ms 660 KB Output is correct
4 Correct 3 ms 644 KB Output is correct
5 Correct 3 ms 944 KB Output is correct
6 Correct 4 ms 964 KB Output is correct
7 Correct 3 ms 956 KB Output is correct
8 Correct 4 ms 956 KB Output is correct
9 Correct 4 ms 956 KB Output is correct
10 Correct 4 ms 972 KB Output is correct
11 Correct 4 ms 936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1156 KB Output is correct
2 Correct 35 ms 3628 KB Output is correct
3 Correct 78 ms 7892 KB Output is correct
4 Correct 50 ms 5900 KB Output is correct
5 Correct 53 ms 5916 KB Output is correct
6 Correct 69 ms 6160 KB Output is correct
7 Correct 74 ms 7124 KB Output is correct
8 Correct 60 ms 6388 KB Output is correct
9 Correct 50 ms 5888 KB Output is correct
10 Correct 79 ms 7736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 5640 KB Output is correct
2 Correct 78 ms 7328 KB Output is correct
3 Correct 81 ms 7400 KB Output is correct
4 Correct 79 ms 7360 KB Output is correct
5 Correct 75 ms 7108 KB Output is correct
6 Correct 77 ms 7392 KB Output is correct
7 Correct 79 ms 7448 KB Output is correct
8 Correct 68 ms 7244 KB Output is correct
9 Correct 71 ms 7376 KB Output is correct
10 Correct 78 ms 7464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 936 KB Output is correct
2 Correct 3 ms 956 KB Output is correct
3 Correct 3 ms 964 KB Output is correct
4 Correct 3 ms 968 KB Output is correct
5 Correct 3 ms 956 KB Output is correct
6 Correct 3 ms 916 KB Output is correct
7 Correct 4 ms 952 KB Output is correct
8 Correct 4 ms 964 KB Output is correct
9 Correct 4 ms 964 KB Output is correct
10 Correct 4 ms 1076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 6580 KB Output is correct - 120000 bits used
2 Correct 86 ms 6728 KB Output is correct - 122000 bits used
3 Correct 81 ms 6820 KB Output is correct - 125000 bits used
4 Correct 75 ms 6832 KB Output is correct - 125000 bits used
5 Correct 79 ms 6756 KB Output is correct - 125000 bits used
6 Correct 79 ms 6780 KB Output is correct - 125000 bits used
7 Correct 75 ms 6752 KB Output is correct - 124828 bits used
8 Correct 81 ms 6784 KB Output is correct - 124910 bits used
9 Correct 79 ms 6788 KB Output is correct - 125000 bits used
10 Correct 74 ms 6712 KB Output is correct - 125000 bits used