답안 #70039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70039 2018-08-22T09:40:21 Z Abelyan 최후의 만찬 (IOI12_supper) C++17
0 / 100
117 ms 8536 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

const int N=100006;
int a[N],han[N],mp[N];
bool pas[N];

void ComputeAdvice(int *c, int n, int k, int m) {
    for (int i=n-1;i>=0;i--){
        a[i]=mp[c[i]]-1;
        if (mp[c[i]]==0)a[i]=2*n;
        mp[c[i]]=i+1;
    }
    priority_queue<pair<int,int> > pq;
    for (int i=0;i<k;i++){
        if (mp[i]==0)mp[i]=2*N;
        pq.push({mp[i],i});
    }
    for (int i=0;i<n;i++){
        han[i]=pq.top().second;
        pq.pop();
        pq.push({a[i],c[i]});
    }
    vector<int> v;
    for (int i=n-1;i>=0;i--){
        if (pas[c[i]])v.push_back(1);
        else v.push_back(0);
        pas[han[i]]=false;
        pas[c[i]]=true;
    }
    for (int i=k-1;i>=0;i--){
        if (pas[i])v.push_back(1);
        else v.push_back(0);
    }
    reverse(v.begin(),v.end());
    for (int i=0;i<v.size();i++){
        WriteAdvice(v[i]);
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

const int N=100006;
stack<int> s;
bool onsc[N];

void Assist(unsigned char *A, int n, int k, int R) {
  assert(n<=10);
    for (int i=0;i<k;i++){
        if (!A[i])s.push(i);
        onsc[i]=true;
    }
    for (int i=0;i<n;i++){
        int k=GetRequest();
        if (onsc[k])continue;
        PutBack(s.top());
        onsc[s.top()]=false;
        s.pop();
        if (!A[i+k])s.push(k);
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v.size();i++){
                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 840 KB Output is correct
2 Runtime error 8 ms 1072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 1968 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 76 ms 5960 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 5960 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 86 ms 7264 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 87 ms 8512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 110 ms 8512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 106 ms 8512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 103 ms 8512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 103 ms 8536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 95 ms 8536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 113 ms 8536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 117 ms 8536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 81 ms 8536 KB Execution killed with signal 11 (could be triggered by violating memory limits)